hotgo2.1.3版本发布

This commit is contained in:
孟帅
2023-02-09 13:53:19 +08:00
parent 255b411eb7
commit 1efbf698e2
30 changed files with 340 additions and 850 deletions

View File

@@ -49,36 +49,11 @@ func TableColumns(ctx context.Context, in sysin.GenCodesColumnListInp) (fields [
func TableSelects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error) {
res = new(sysin.GenCodesSelectsModel)
for k, v := range consts.GenCodesTypeNameMap {
row := &sysin.GenTypeSelect{
Value: k,
Name: v,
Label: v,
Templates: make(form.Selects, 0),
}
confName, ok := consts.GenCodesTypeConfMap[k]
if ok {
var temps []*model.GenerateAppCrudTemplate
err = g.Cfg().MustGet(ctx, "hggen.application."+confName+".templates").Scan(&temps)
if err != nil {
return
}
if len(temps) > 0 {
for index, temp := range temps {
row.Templates = append(row.Templates, &form.Select{
Value: index,
Label: temp.Group,
Name: temp.Group,
})
}
sort.Sort(row.Templates)
}
}
res.GenType = append(res.GenType, row)
res.GenType, err = GenTypeSelect(ctx)
if err != nil {
return
}
sort.Sort(res.GenType)
res.Db = DbSelect(ctx)
for k, v := range consts.GenCodesStatusNameMap {
@@ -126,9 +101,12 @@ func TableSelects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.
}
sort.Sort(res.FormRole)
dictMode, _ := service.SysDictType().TreeSelect(ctx, sysin.DictTreeSelectInp{})
dictMode, err := service.SysDictType().TreeSelect(ctx, sysin.DictTreeSelectInp{})
if err != nil {
return
}
res.DictMode = dictMode
for _, v := range views.WhereModes {
res.WhereMode = append(res.WhereMode, &form.Select{
Value: v,
@@ -140,6 +118,42 @@ func TableSelects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.
return
}
// GenTypeSelect 获取生成类型选项
func GenTypeSelect(ctx context.Context) (res sysin.GenTypeSelects, err error) {
for k, v := range consts.GenCodesTypeNameMap {
row := &sysin.GenTypeSelect{
Value: k,
Name: v,
Label: v,
Templates: make(form.Selects, 0),
}
confName, ok := consts.GenCodesTypeConfMap[k]
if ok {
var temps []*model.GenerateAppCrudTemplate
err = g.Cfg().MustGet(ctx, "hggen.application."+confName+".templates").Scan(&temps)
if err != nil {
return
}
if len(temps) > 0 {
for index, temp := range temps {
row.Templates = append(row.Templates, &form.Select{
Value: index,
Label: temp.Group,
Name: temp.Group,
})
}
sort.Sort(row.Templates)
}
}
res = append(res, row)
}
sort.Sort(res)
return
}
// DbSelect db选项
func DbSelect(ctx context.Context) (res form.Selects) {
dbs := g.Cfg().MustGet(ctx, "hggen.selectDbs")

View File

@@ -146,14 +146,17 @@ func (s *sAdminNotice) Status(ctx context.Context, in adminin.NoticeStatusInp) (
}
// MaxSort 最大排序
func (s *sAdminNotice) MaxSort(ctx context.Context, in adminin.NoticeMaxSortInp) (*adminin.NoticeMaxSortModel, error) {
var res adminin.NoticeMaxSortModel
if err := s.Model(ctx).Order("sort desc").Scan(&res); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return nil, err
func (s *sAdminNotice) MaxSort(ctx context.Context, in adminin.NoticeMaxSortInp) (res *adminin.NoticeMaxSortModel, err error) {
if err = dao.AdminNotice.Ctx(ctx).Order("sort desc").Scan(&res); err != nil {
return
}
if res == nil {
res = new(adminin.NoticeMaxSortModel)
}
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
return &res, nil
return
}
// View 获取指定字典类型信息

View File

@@ -13,6 +13,7 @@ import (
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/internal/dao"
@@ -22,6 +23,13 @@ import (
"hotgo/internal/service"
)
var MaskDemoField = []string{
"smtpUser", "smtpPass", // 邮箱
"uploadUCloudPublicKey", "uploadUCloudPrivateKey", // 云存储
"geoAmapWebKey", // 地图
"smsAliyunAccessKeyID", "smsAliyunAccessKeySecret", // 短信
}
type sSysConfig struct{}
func NewSysConfig() *sSysConfig {
@@ -156,7 +164,12 @@ func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp
return nil, err
}
res.List[v.Key] = val
if isDemo.Bool() && (v.Key == "smtpUser" || v.Key == "smtpPass") {
//if isDemo.Bool() && (v.Key == "smtpUser" || v.Key == "smtpPass") {
// res.List[v.Key] = consts.DemoTips
// res.List[v.Key] = consts.DemoTips
//}
if isDemo.Bool() && gstr.InArray(MaskDemoField, v.Key) {
res.List[v.Key] = consts.DemoTips
res.List[v.Key] = consts.DemoTips
}

View File

@@ -162,6 +162,34 @@ func (s *sSysGenCodes) List(ctx context.Context, in sysin.GenCodesListInp) (list
return list, totalCount, err
}
typeSelect, err := hggen.GenTypeSelect(ctx)
if err != nil {
return
}
getTemplateGroup := func(row *sysin.GenCodesListModel) string {
if row == nil {
return ""
}
for _, v := range typeSelect {
if v.Value == int(row.GenType) {
for index, template := range v.Templates {
if index == row.GenTemplate {
return template.Label
}
}
}
}
return ""
}
if len(list) > 0 {
for _, v := range list {
v.GenTemplateGroup = getTemplateGroup(v)
}
}
return list, totalCount, err
}

View File

@@ -55,6 +55,7 @@ type GenCodesListInp struct {
type GenCodesListModel struct {
entity.SysGenCodes
GenTemplateGroup string `json:"genTemplateGroup" dc:"生成模板组名"`
}
// GenCodesStatusInp 更新状态