update: 发布dev2.7.6Beta版本 (#1908)
* feat: 优化菜单管理的路径选择框 * fixed: 修复错误的文件命名 * feat: 增加参数管理功能,调整菜单选择组件。 * feat: 恢复config.yaml * feat: 更新AI功能 * feat: 增加API自动填充功能 * feat: 增加AI自动填充表格导出模板 * feat: 增加AI自动填充表格导出模板和AI自动模板填充 * feat: 新增方法支持选择是否鉴权 --------- Co-authored-by: Azir <2075125282@qq.com>
This commit is contained in:
@@ -308,7 +308,13 @@ func (s *autoCodeTemplate) getTemplateStr(t string, info request.AutoFunc) (stri
|
||||
func (s *autoCodeTemplate) addTemplateToAst(t string, info request.AutoFunc) error {
|
||||
tPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "router", info.Package, info.HumpPackageName+".go")
|
||||
funcName := fmt.Sprintf("Init%sRouter", info.StructName)
|
||||
stmtStr := fmt.Sprintf("%sRouterWithoutAuth.%s(\"%s\", %sApi.%s)", info.Abbreviation, info.Method, info.Router, info.Abbreviation, info.FuncName)
|
||||
|
||||
routerStr := "RouterWithoutAuth"
|
||||
if info.IsAuth {
|
||||
routerStr = "Router"
|
||||
}
|
||||
|
||||
stmtStr := fmt.Sprintf("%s%s.%s(\"%s\", %sApi.%s)", info.Abbreviation, routerStr, info.Method, info.Router, info.Abbreviation, info.FuncName)
|
||||
if info.IsPlugin {
|
||||
tPath = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin", info.Package, "router", info.HumpPackageName+".go")
|
||||
stmtStr = fmt.Sprintf("group.%s(\"%s\", api%s.%s)", info.Method, info.Router, info.StructName, info.FuncName)
|
||||
@@ -324,13 +330,25 @@ func (s *autoCodeTemplate) addTemplateToAst(t string, info request.AutoFunc) err
|
||||
funcDecl := utilsAst.FindFunction(astFile, funcName)
|
||||
stmtNode := utilsAst.CreateStmt(stmtStr)
|
||||
|
||||
for i := len(funcDecl.Body.List) - 1; i >= 0; i-- {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
if info.IsAuth {
|
||||
for i := 0; i < len(funcDecl.Body.List); i++ {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for i := len(funcDecl.Body.List) - 1; i >= 0; i-- {
|
||||
st := funcDecl.Body.List[i]
|
||||
// 使用类型断言来检查stmt是否是一个块语句
|
||||
if blockStmt, ok := st.(*ast.BlockStmt); ok {
|
||||
// 如果是,插入代码 跳出
|
||||
blockStmt.List = append(blockStmt.List, stmtNode)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ type ServiceGroup struct {
|
||||
DictionaryDetailService
|
||||
AuthorityBtnService
|
||||
SysExportTemplateService
|
||||
|
||||
SysParamsService
|
||||
AutoCodePlugin autoCodePlugin
|
||||
AutoCodePackage autoCodePackage
|
||||
AutoCodeHistory autoCodeHistory
|
||||
|
82
server/service/system/sys_params.go
Normal file
82
server/service/system/sys_params.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
)
|
||||
|
||||
type SysParamsService struct{}
|
||||
|
||||
// CreateSysParams 创建参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) CreateSysParams(sysParams *system.SysParams) (err error) {
|
||||
err = global.GVA_DB.Create(sysParams).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteSysParams 删除参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) DeleteSysParams(ID string) (err error) {
|
||||
err = global.GVA_DB.Delete(&system.SysParams{}, "id = ?", ID).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteSysParamsByIds 批量删除参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) DeleteSysParamsByIds(IDs []string) (err error) {
|
||||
err = global.GVA_DB.Delete(&[]system.SysParams{}, "id in ?", IDs).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateSysParams 更新参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) UpdateSysParams(sysParams system.SysParams) (err error) {
|
||||
err = global.GVA_DB.Model(&system.SysParams{}).Where("id = ?", sysParams.ID).Updates(&sysParams).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// GetSysParams 根据ID获取参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParams(ID string) (sysParams system.SysParams, err error) {
|
||||
err = global.GVA_DB.Where("id = ?", ID).First(&sysParams).Error
|
||||
return
|
||||
}
|
||||
|
||||
// GetSysParamsInfoList 分页获取参数记录
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParamsInfoList(info systemReq.SysParamsSearch) (list []system.SysParams, total int64, err error) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
db := global.GVA_DB.Model(&system.SysParams{})
|
||||
var sysParamss []system.SysParams
|
||||
// 如果有条件搜索 下方会自动创建搜索语句
|
||||
if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
|
||||
db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
|
||||
}
|
||||
if info.Name != "" {
|
||||
db = db.Where("name LIKE ?", "%"+info.Name+"%")
|
||||
}
|
||||
if info.Key != "" {
|
||||
db = db.Where("key LIKE ?", "%"+info.Key+"%")
|
||||
}
|
||||
err = db.Count(&total).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if limit != 0 {
|
||||
db = db.Limit(limit).Offset(offset)
|
||||
}
|
||||
|
||||
err = db.Find(&sysParamss).Error
|
||||
return sysParamss, total, err
|
||||
}
|
||||
|
||||
// GetSysParam 根据key获取参数value
|
||||
// Author [Mr.奇淼](https://github.com/pixelmaxQm)
|
||||
func (sysParamsService *SysParamsService) GetSysParam(key string) (param system.SysParams, err error) {
|
||||
err = global.GVA_DB.Where(system.SysParams{Key: key}).First(¶m).Error
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user