
* beta:2.7.8-a 增加自动化创建树形结构 (#1941) * feat: 支持创建树形结构 --------- Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com> * 优化user store部分写法 * Update user.js * feat: 升级版本号 * Dev 278 beta2 (#1954) * 在关闭详情弹窗后 detailFrom为空对象,arr为undefined 使用slice控制台会报错 * 查询不重置pageSize * 优化主题模式相关内容 * 优化弹窗手机端显示 * bugfix:PostgreSQL initdb (#1953) * bugfix:postgresql增加显示指定template --------- Co-authored-by: PiexlMax(奇淼 <165128580+pixelmaxQm@users.noreply.github.com> --------- Co-authored-by: zayn <972858472@qq.com> Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: Qing Liang <106448173+xue-ding-e@users.noreply.github.com> * docs:调整部分代码注释以及代码格式 * feat: 自动化代码字典支持多选 * fix:调整值接收器和指针接收器 * feat: 支持导出表格复制,优化增加方法页面。 * chore:初始化代码规范化。 --------- Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com> Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: zayn <972858472@qq.com> Co-authored-by: Qing Liang <106448173+xue-ding-e@users.noreply.github.com> Co-authored-by: cjb <75364055@qq.com>
120 lines
3.7 KiB
Go
120 lines
3.7 KiB
Go
package system
|
||
|
||
import (
|
||
"fmt"
|
||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||
"github.com/gin-gonic/gin"
|
||
"go.uber.org/zap"
|
||
)
|
||
|
||
type AutoCodePluginApi struct{}
|
||
|
||
// Install
|
||
// @Tags AutoCodePlugin
|
||
// @Summary 安装插件
|
||
// @Security ApiKeyAuth
|
||
// @accept multipart/form-data
|
||
// @Produce application/json
|
||
// @Param plug formData file true "this is a test file"
|
||
// @Success 200 {object} response.Response{data=[]interface{},msg=string} "安装插件成功"
|
||
// @Router /autoCode/installPlugin [post]
|
||
func (a *AutoCodePluginApi) Install(c *gin.Context) {
|
||
header, err := c.FormFile("plug")
|
||
if err != nil {
|
||
response.FailWithMessage(err.Error(), c)
|
||
return
|
||
}
|
||
web, server, err := autoCodePluginService.Install(header)
|
||
webStr := "web插件安装成功"
|
||
serverStr := "server插件安装成功"
|
||
if web == -1 {
|
||
webStr = "web端插件未成功安装,请按照文档自行解压安装,如果为纯后端插件请忽略此条提示"
|
||
}
|
||
if server == -1 {
|
||
serverStr = "server端插件未成功安装,请按照文档自行解压安装,如果为纯前端插件请忽略此条提示"
|
||
}
|
||
if err != nil {
|
||
response.FailWithMessage(err.Error(), c)
|
||
return
|
||
}
|
||
response.OkWithData([]interface{}{
|
||
gin.H{
|
||
"code": web,
|
||
"msg": webStr,
|
||
},
|
||
gin.H{
|
||
"code": server,
|
||
"msg": serverStr,
|
||
}}, c)
|
||
}
|
||
|
||
// Packaged
|
||
// @Tags AutoCodePlugin
|
||
// @Summary 打包插件
|
||
// @Security ApiKeyAuth
|
||
// @accept application/json
|
||
// @Produce application/json
|
||
// @Param plugName query string true "插件名称"
|
||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "打包插件成功"
|
||
// @Router /autoCode/pubPlug [post]
|
||
func (a *AutoCodePluginApi) Packaged(c *gin.Context) {
|
||
plugName := c.Query("plugName")
|
||
zipPath, err := autoCodePluginService.PubPlug(plugName)
|
||
if err != nil {
|
||
global.GVA_LOG.Error("打包失败!", zap.Error(err))
|
||
response.FailWithMessage("打包失败"+err.Error(), c)
|
||
return
|
||
}
|
||
response.OkWithMessage(fmt.Sprintf("打包成功,文件路径为:%s", zipPath), c)
|
||
}
|
||
|
||
// InitMenu
|
||
// @Tags AutoCodePlugin
|
||
// @Summary 打包插件
|
||
// @Security ApiKeyAuth
|
||
// @accept application/json
|
||
// @Produce application/json
|
||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "打包插件成功"
|
||
// @Router /autoCode/initMenu [post]
|
||
func (a *AutoCodePluginApi) InitMenu(c *gin.Context) {
|
||
var menuInfo request.InitMenu
|
||
err := c.ShouldBindJSON(&menuInfo)
|
||
if err != nil {
|
||
response.FailWithMessage(err.Error(), c)
|
||
return
|
||
}
|
||
err = autoCodePluginService.InitMenu(menuInfo)
|
||
if err != nil {
|
||
global.GVA_LOG.Error("创建初始化Menu失败!", zap.Error(err))
|
||
response.FailWithMessage("创建初始化Menu失败"+err.Error(), c)
|
||
return
|
||
}
|
||
response.OkWithMessage("文件变更成功", c)
|
||
}
|
||
|
||
// InitAPI
|
||
// @Tags AutoCodePlugin
|
||
// @Summary 打包插件
|
||
// @Security ApiKeyAuth
|
||
// @accept application/json
|
||
// @Produce application/json
|
||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "打包插件成功"
|
||
// @Router /autoCode/initAPI [post]
|
||
func (a *AutoCodePluginApi) InitAPI(c *gin.Context) {
|
||
var apiInfo request.InitApi
|
||
err := c.ShouldBindJSON(&apiInfo)
|
||
if err != nil {
|
||
response.FailWithMessage(err.Error(), c)
|
||
return
|
||
}
|
||
err = autoCodePluginService.InitAPI(apiInfo)
|
||
if err != nil {
|
||
global.GVA_LOG.Error("创建初始化API失败!", zap.Error(err))
|
||
response.FailWithMessage("创建初始化API失败"+err.Error(), c)
|
||
return
|
||
}
|
||
response.OkWithMessage("文件变更成功", c)
|
||
}
|