You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2448 lines
69 KiB
2448 lines
69 KiB
package customerApp
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
datacenter "appPlatform/api/version1/dataCenter"
|
|
"appPlatform/api/version1/publicapi"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/models/modelssystempermission"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 10:13:39
|
|
@ 功能: 创建APP
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) CreateApp(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
uuid := publicmethod.GetUUid(1)
|
|
createrTime := time.Now().Unix()
|
|
appKey := fmt.Sprintf("app_%v", uuid)
|
|
appName := fmt.Sprintf("未命名应用_%v", uuid)
|
|
//应用主体
|
|
var formInfo modelAppPlatform.CustomerForm
|
|
formInfo.Name = appName //表单名称"`
|
|
formInfo.TableNames = appKey //创建表单名称"`
|
|
formInfo.Classify = 3 //分类1:表单;2:流程表单; 3: 应用; 4: 应用中的表单'
|
|
formInfo.States = 1 //显示状态(1:启用;2:禁用,3:删除)"`
|
|
formInfo.CreaterTime = createrTime //创建时间"`
|
|
formInfo.EditTime = createrTime //编辑时间"`
|
|
groupIdInt, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
formInfo.Groupid = groupIdInt //分组Id"`
|
|
formInfo.Icon = "https://docu.hxgk.group/images/2024_04/482167d1bf2b75a5717bcf68e18235f7.png" //图标"`
|
|
formInfo.FlowIsOpen = 2
|
|
formInfo.SignCode = uuid //是否开启工作流(1:启用;2:禁用)"`
|
|
//应用版本
|
|
var appVersion modelAppPlatform.CustomerFormVersion
|
|
appVersion.TableKey = appKey //表单标识符"`
|
|
appVersion.Version = 1 //版本号"`
|
|
appVersion.Status = 1 //显示状态(1:启用;2:禁用,3:删除)"`
|
|
appVersion.Creater = userCont.Key //创建人"`
|
|
appVersion.CreaterTime = createrTime //创建时间"`
|
|
appVersion.EditTime = createrTime //编辑时间"`
|
|
appVersion.Visibility = 1 //1、所有人,2、自定义"`
|
|
appVersion.SignCode = uuid
|
|
//基本菜单
|
|
var menuKey []int64
|
|
for {
|
|
if len(menuKey) >= 5 {
|
|
break
|
|
}
|
|
menuUUid := publicmethod.GetUUid(2)
|
|
if !publicmethod.IsInTrue[int64](menuUUid, menuKey) {
|
|
menuKey = append(menuKey, menuUUid)
|
|
}
|
|
}
|
|
var appMenuList []modelAppPlatform.Appmenus
|
|
var daiWoChuLi modelAppPlatform.Appmenus
|
|
daiWoChuLi.Id = menuKey[0] //
|
|
daiWoChuLi.Label = "代办事宜" //节点名称"`
|
|
daiWoChuLi.Types = 2 //节点类型 1:目录;2:菜单"`
|
|
daiWoChuLi.Svg = "daiWoCuLi" //图标"`
|
|
daiWoChuLi.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
daiWoChuLi.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
daiWoChuLi.Parent = uuid //上级"`
|
|
daiWoChuLi.Appkey = uuid //归属哪个应用"`
|
|
daiWoChuLi.CreaterTime = createrTime //创建时间"`
|
|
daiWoChuLi.EditTime = createrTime //编辑时间"`
|
|
daiWoChuLi.Creater = userCont.Key //创建人"`
|
|
daiWoChuLi.IsLock = 1 //是否为固定菜单(1:是;2:否)"`
|
|
daiWoChuLi.Sort = 1
|
|
daiWoChuLi.State = 1
|
|
daiWoChuLi.IsMain = 1
|
|
appMenuList = append(appMenuList, daiWoChuLi)
|
|
var woYiChuLi modelAppPlatform.Appmenus
|
|
woYiChuLi.Id = menuKey[1] //
|
|
woYiChuLi.Label = "已办事宜" //节点名称"`
|
|
woYiChuLi.Types = 2 //节点类型 1:目录;2:菜单"`
|
|
woYiChuLi.Svg = "woYiChuLi" //图标"`
|
|
woYiChuLi.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
woYiChuLi.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
woYiChuLi.Parent = uuid //上级"`
|
|
woYiChuLi.Appkey = uuid //归属哪个应用"`
|
|
woYiChuLi.CreaterTime = createrTime //创建时间"`
|
|
woYiChuLi.EditTime = createrTime //编辑时间"`
|
|
woYiChuLi.Creater = userCont.Key //创建人"`
|
|
woYiChuLi.IsLock = 1 //是否为固定菜单(1:是;2:否)"`
|
|
woYiChuLi.Sort = 2
|
|
woYiChuLi.State = 1
|
|
woYiChuLi.IsMain = 2
|
|
appMenuList = append(appMenuList, woYiChuLi)
|
|
var caoSongWoDe modelAppPlatform.Appmenus
|
|
caoSongWoDe.Id = menuKey[2] //
|
|
caoSongWoDe.Label = "抄送我的" //节点名称"`
|
|
caoSongWoDe.Types = 2 //节点类型 1:目录;2:菜单"`
|
|
caoSongWoDe.Svg = "chaoSongWoDe" //图标"`
|
|
caoSongWoDe.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
caoSongWoDe.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
caoSongWoDe.Parent = uuid //上级"`
|
|
caoSongWoDe.Appkey = uuid //归属哪个应用"`
|
|
caoSongWoDe.CreaterTime = createrTime //创建时间"`
|
|
caoSongWoDe.EditTime = createrTime //编辑时间"`
|
|
caoSongWoDe.Creater = userCont.Key //创建人"`
|
|
caoSongWoDe.IsLock = 1 //是否为固定菜单(1:是;2:否)"`
|
|
caoSongWoDe.Sort = 3
|
|
caoSongWoDe.State = 1
|
|
caoSongWoDe.IsMain = 3
|
|
appMenuList = append(appMenuList, caoSongWoDe)
|
|
var woChuangJianDe modelAppPlatform.Appmenus
|
|
woChuangJianDe.Id = menuKey[3] //
|
|
woChuangJianDe.Label = "我创建的" //节点名称"`
|
|
woChuangJianDe.Types = 2 //节点类型 1:目录;2:菜单"`
|
|
woChuangJianDe.Svg = "woChuangJianDe" //图标"`
|
|
woChuangJianDe.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
woChuangJianDe.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
woChuangJianDe.Parent = uuid //上级"`
|
|
woChuangJianDe.Appkey = uuid //归属哪个应用"`
|
|
woChuangJianDe.CreaterTime = createrTime //创建时间"`
|
|
woChuangJianDe.EditTime = createrTime //编辑时间"`
|
|
woChuangJianDe.Creater = userCont.Key //创建人"`
|
|
woChuangJianDe.IsLock = 1 //是否为固定菜单(1:是;2:否)"`
|
|
woChuangJianDe.Sort = 4
|
|
woChuangJianDe.State = 1
|
|
woChuangJianDe.IsMain = 4
|
|
appMenuList = append(appMenuList, woChuangJianDe)
|
|
|
|
var myDrafts modelAppPlatform.Appmenus
|
|
myDrafts.Id = menuKey[4] //
|
|
myDrafts.Label = "草稿箱" //节点名称"`
|
|
myDrafts.Types = 2 //节点类型 1:目录;2:菜单"`
|
|
myDrafts.Svg = "caogaoxiang(1)" //图标"`
|
|
myDrafts.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
myDrafts.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
myDrafts.Parent = uuid //上级"`
|
|
myDrafts.Appkey = uuid //归属哪个应用"`
|
|
myDrafts.CreaterTime = createrTime //创建时间"`
|
|
myDrafts.EditTime = createrTime //编辑时间"`
|
|
myDrafts.Creater = userCont.Key //创建人"`
|
|
myDrafts.IsLock = 1 //是否为固定菜单(1:是;2:否)"`
|
|
myDrafts.Sort = 5
|
|
myDrafts.State = 1
|
|
myDrafts.IsMain = 5
|
|
appMenuList = append(appMenuList, myDrafts)
|
|
|
|
menusTreeList := AppTreeMenus(uuid, appMenuList)
|
|
menuTreeJson, _ := json.Marshal(menusTreeList)
|
|
formInfo.ListJson = string(menuTreeJson)
|
|
|
|
appErr := overall.CONSTANT_DB_AppPlatform.Create(&formInfo).Error
|
|
appVerErr := overall.CONSTANT_DB_AppPlatform.Create(&appVersion).Error
|
|
appMenuErr := overall.CONSTANT_DB_AppPlatform.Create(&appMenuList).Error
|
|
if appErr != nil || appVerErr != nil || appMenuErr != nil {
|
|
formInfo.DelCont(map[string]interface{}{"tablename": appKey})
|
|
appVersion.DelCont(map[string]interface{}{"tablekey": appKey})
|
|
var delMenuCont modelAppPlatform.Appmenus
|
|
delMenuCont.DelCont(map[string]interface{}{"appkey": uuid})
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
sort.Slice(appMenuList, func(i, j int) bool {
|
|
return appMenuList[i].Sort < appMenuList[j].Sort
|
|
})
|
|
sendInfo := publicmethod.MapOut[string]()
|
|
sendInfo["appName"] = appName
|
|
sendInfo["appKey"] = appKey
|
|
sendInfo["uuid"] = strconv.FormatInt(uuid, 10)
|
|
sendInfo["state"] = 1
|
|
sendInfo["appSvg"] = "ziJianApp"
|
|
sendInfo["menuTree"] = menusTreeList
|
|
publicmethod.Result(0, sendInfo, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 13:42:51
|
|
@ 功能: App菜单树处理
|
|
*/
|
|
func AppTreeMenus(parentId int64, menuList []modelAppPlatform.Appmenus) (menusTree []AppMenuTree) {
|
|
for _, v := range menuList {
|
|
if v.Parent == parentId {
|
|
var menuCont AppMenuTree
|
|
menuCont.Id = strconv.FormatInt(v.Id, 10) //
|
|
menuCont.Label = v.Label // 节点名称"`
|
|
menuCont.Types = v.Types // 节点类型 1:目录;2:菜单"`
|
|
menuCont.Svg = v.Svg // 图标"`
|
|
menuCont.PcIsShow = v.PcIsShow // pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
menuCont.WapIsShow = v.WapIsShow // 移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
menuCont.Parent = strconv.FormatInt(v.Parent, 10) // 上级"`
|
|
menuCont.Appkey = strconv.FormatInt(v.Appkey, 10) // 归属哪个应用"`
|
|
// menuCont.CreaterTime = strconv.FormatInt(v.CreaterTime, 10) // 创建时间"`
|
|
// menuCont.EditTime = strconv.FormatInt(v.EditTime, 10) // 编辑时间"`
|
|
// menuCont.Creater = strconv.FormatInt(v.Creater, 10) // 创建人"`
|
|
menuCont.IsLock = v.IsLock // 是否为固定菜单(1:是;2:否)"`
|
|
menuCont.Sort = v.Sort // 排序"`
|
|
menuCont.State = v.State
|
|
menuCont.IsMain = v.IsMain
|
|
menuCont.Icon = gainMenuIcon(v.Id)
|
|
menuCont.Children = AppTreeMenus(v.Id, menuList)
|
|
menusTree = append(menusTree, menuCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-02-26 11:22:18
|
|
@ 功能: 获取上传的图片
|
|
*/
|
|
func gainMenuIcon(id int64) (img string) {
|
|
fmt.Printf("获取上传的图片--->%v\n\n\n", id)
|
|
var custForm modelAppPlatform.CustomerForm
|
|
custForm.GetCont(map[string]interface{}{"`signCode`": id}, "`icon`")
|
|
img = custForm.Icon
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 14:35:27
|
|
@ 功能: 获取应用编辑页面信息
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainAppEditPsge(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var appCont modelAppPlatform.CustomerFormView
|
|
err = appCont.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.Id})
|
|
if err != nil {
|
|
publicmethod.Result(105, err, c)
|
|
return
|
|
}
|
|
|
|
sendInfo := publicmethod.MapOut[string]()
|
|
sendInfo["appName"] = appCont.Name
|
|
sendInfo["appKey"] = appCont.TableKey
|
|
sendInfo["uuid"] = strconv.FormatInt(appCont.SignCode, 10)
|
|
sendInfo["state"] = appCont.Status
|
|
sendInfo["appSvg"] = appCont.Icon
|
|
sendInfo["describe"] = appCont.Describe
|
|
if appCont.ListJson != "" {
|
|
var menuTerr []AppMenuTree
|
|
json.Unmarshal([]byte(appCont.ListJson), &menuTerr)
|
|
sendInfo["menuTree"] = menuTerr
|
|
} else {
|
|
syncSeting.Add(1)
|
|
sendInfo["menuTree"] = GainAppMenuTree(appCont.SignCode)
|
|
syncSeting.Wait()
|
|
}
|
|
publicmethod.Result(0, sendInfo, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 14:53:56
|
|
@ 功能: 获取菜单
|
|
@ 参数
|
|
|
|
#key 应用唯一识别符
|
|
|
|
@ 返回值
|
|
|
|
#menusTree 应用菜单树
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainAppMenuTree(key int64) (menusTree []AppMenuTree) {
|
|
defer syncSeting.Done()
|
|
if key == 0 {
|
|
return
|
|
}
|
|
var menuList []modelAppPlatform.Appmenus
|
|
err := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1 AND `appkey` = ?", key).Find(&menuList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].EditTime < menuList[j].EditTime
|
|
})
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].Sort < menuList[j].Sort
|
|
})
|
|
menusTree = AppTreeMenus(key, menuList)
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 16:47:00
|
|
@ 功能: 获取除固定菜单以外的数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GinOthenMenuTree(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var menuTreeMap []AppMenuTree
|
|
uuid, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
syncSeting.Add(1)
|
|
menuTreeMap = GainAppMenuOtherTree(uuid)
|
|
syncSeting.Wait()
|
|
publicmethod.Result(0, menuTreeMap, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-24 09:07:14
|
|
@ 功能: 获取除固定菜单以外的数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainAppMenuOtherTree(key int64) (menusTree []AppMenuTree) {
|
|
defer syncSeting.Done()
|
|
if key == 0 {
|
|
return
|
|
}
|
|
var menuList []modelAppPlatform.Appmenus
|
|
err := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1 AND `isLock` = 2 AND `appkey` = ?", key).Find(&menuList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].EditTime < menuList[j].EditTime
|
|
})
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].Sort < menuList[j].Sort
|
|
})
|
|
menusTree = AppTreeMenus(key, menuList)
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-24 09:46:09
|
|
@ 功能: 新增菜单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SaveAppMenu(c *gin.Context) {
|
|
var requestData AppMenuInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Group == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Appkey == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 1
|
|
}
|
|
svgName := "dict_item"
|
|
switch requestData.Types {
|
|
case 2:
|
|
svgName = "gd"
|
|
default:
|
|
svgName = "dict_item"
|
|
}
|
|
var count int64
|
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where(" `appkey` = ?", requestData.Appkey).Count(&count)
|
|
if count < 1 {
|
|
count = 50
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
createrTime := time.Now().Unix()
|
|
parentId, _ := strconv.ParseInt(requestData.Group, 10, 64)
|
|
appKeyId, _ := strconv.ParseInt(requestData.Appkey, 10, 64)
|
|
menuUUid := publicmethod.GetUUid(2)
|
|
var daiWoChuLi modelAppPlatform.Appmenus
|
|
daiWoChuLi.Id = menuUUid //
|
|
daiWoChuLi.Label = requestData.Name //节点名称"`
|
|
daiWoChuLi.Types = requestData.Types //节点类型 1:目录;2:菜单"`
|
|
daiWoChuLi.Svg = svgName //图标"`
|
|
daiWoChuLi.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
daiWoChuLi.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
daiWoChuLi.Parent = parentId //上级"`
|
|
daiWoChuLi.Appkey = appKeyId //归属哪个应用"`
|
|
daiWoChuLi.CreaterTime = createrTime //创建时间"`
|
|
daiWoChuLi.EditTime = createrTime //编辑时间"`
|
|
daiWoChuLi.Creater = userCont.Key //创建人"`
|
|
daiWoChuLi.IsLock = 2 //是否为固定菜单(1:是;2:否)"`
|
|
daiWoChuLi.Sort = count
|
|
daiWoChuLi.State = 1
|
|
err = overall.CONSTANT_DB_AppPlatform.Create(&daiWoChuLi).Error
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
var newAppMenu []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenu = GainAppMenuTree(appKeyId)
|
|
syncSeting.Wait()
|
|
saveData := publicmethod.MapOut[string]()
|
|
menuTreeJson, _ := json.Marshal(newAppMenu)
|
|
saveData["listjson"] = string(menuTreeJson)
|
|
saveData["edit_time"] = createrTime
|
|
var formInfo modelAppPlatform.CustomerForm
|
|
formInfo.EiteCont(map[string]interface{}{"signCode": appKeyId}, saveData)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-24 13:31:08
|
|
@ 功能: 获取完整APP菜单树
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainAllAppMenu(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
|
|
var appCont modelAppPlatform.CustomerFormView
|
|
err = appCont.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.Id}, "`listjson`", "`signCode`")
|
|
if err != nil {
|
|
publicmethod.Result(105, err, c)
|
|
return
|
|
}
|
|
var menuTreeMap []AppMenuTree
|
|
if appCont.ListJson != "" {
|
|
json.Unmarshal([]byte(appCont.ListJson), &menuTreeMap)
|
|
} else {
|
|
syncSeting.Add(1)
|
|
menuTreeMap = GainAppMenuTree(appCont.SignCode)
|
|
syncSeting.Wait()
|
|
}
|
|
|
|
// uuid, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
// syncSeting.Add(1)
|
|
// menuTreeMap = GainAppMenuTree(uuid)
|
|
// syncSeting.Wait()
|
|
publicmethod.Result(0, menuTreeMap, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-24 13:54:42
|
|
@ 功能: 修改App菜单结构
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditAppMenuCont(c *gin.Context) {
|
|
var requestData AppMenuTreeSave
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var custForm modelAppPlatform.CustomerForm
|
|
if len(requestData.MenuTree) < 1 {
|
|
custForm.EiteCont(map[string]interface{}{"`signCode`": requestData.Id}, map[string]interface{}{"`listjson`": "", "edit_time": time.Now().Unix()})
|
|
publicmethod.Result(0, err, c)
|
|
return
|
|
}
|
|
menuStr, _ := json.Marshal(requestData.MenuTree)
|
|
custForm.EiteCont(map[string]interface{}{"`signCode`": requestData.Id}, map[string]interface{}{"`listjson`": string(menuStr), "edit_time": time.Now().Unix()})
|
|
DiGuiAppMenuEdit(requestData.Id, requestData.MenuTree)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
func DiGuiAppMenuEdit(prientKey string, menuTree []AppMenuTree) {
|
|
if len(menuTree) > 0 {
|
|
for _, v := range menuTree {
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["`parent`"] = prientKey
|
|
saveData["`edit_time`"] = time.Now().Unix()
|
|
var menuInfo modelAppPlatform.Appmenus
|
|
menuInfo.EiteCont(map[string]interface{}{"`id`": v.Id}, saveData)
|
|
if len(v.Children) > 0 {
|
|
DiGuiAppMenuEdit(v.Id, v.Children)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-25 14:00:28
|
|
@ 功能: 修改菜单名称
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditAppMenuLable(c *gin.Context) {
|
|
var requestData EditAppMenuNAme
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Label == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var oldMenuInfo modelAppPlatform.Appmenus
|
|
err = oldMenuInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`type`", `appkey`)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveMenu := publicmethod.MapOut[string]()
|
|
saveMenu["`label`"] = requestData.Label
|
|
saveMenu["`edit_time`"] = time.Now().Unix()
|
|
err = oldMenuInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveMenu)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
editForm := publicmethod.MapOut[string]()
|
|
var cusForm modelAppPlatform.CustomerForm
|
|
err = cusForm.GetCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, "`listjson`")
|
|
if oldMenuInfo.Types != 1 {
|
|
if err == nil {
|
|
// editForm["`name`"] = requestData.Label
|
|
EditAppMenuFormName(oldMenuInfo.Id, requestData.Label)
|
|
}
|
|
}
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(oldMenuInfo.Appkey)
|
|
syncSeting.Wait()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
editForm["listjson"] = string(menuTreeJson)
|
|
editForm["edit_time"] = time.Now().Unix()
|
|
cusForm.EiteCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, editForm)
|
|
|
|
//
|
|
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-17 15:39:28
|
|
@ 功能: 修改表单名称
|
|
*/
|
|
func EditAppMenuFormName(signCode int64, title string) {
|
|
editForm := publicmethod.MapOut[string]()
|
|
editForm["`name`"] = title
|
|
editForm["edit_time"] = time.Now().Unix()
|
|
var formVersion modelAppPlatform.CustomerForm
|
|
formVersion.EiteCont(map[string]interface{}{"`signCode`": signCode}, editForm)
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-07 09:34:27
|
|
@ 功能: 显示和隐藏菜单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AppMenuShowOrHide(c *gin.Context) {
|
|
var requestData HideOrShowAppMenu
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 1
|
|
}
|
|
if requestData.MenuInfo.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var oldMenuInfo modelAppPlatform.Appmenus
|
|
err = oldMenuInfo.GetCont(map[string]interface{}{"`id`": requestData.MenuInfo.Id}, "`type`", `appkey`, `pcIsShow`, `wapIsShow`)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveMenu := publicmethod.MapOut[string]()
|
|
if requestData.Types == 1 {
|
|
if oldMenuInfo.PcIsShow == 1 {
|
|
saveMenu["`pcIsShow`"] = 2
|
|
} else {
|
|
saveMenu["`pcIsShow`"] = 1
|
|
}
|
|
} else {
|
|
if oldMenuInfo.WapIsShow == 1 {
|
|
saveMenu["`wapIsShow`"] = 2
|
|
} else {
|
|
saveMenu["`wapIsShow`"] = 1
|
|
}
|
|
}
|
|
|
|
saveMenu["`edit_time`"] = time.Now().Unix()
|
|
err = oldMenuInfo.EiteCont(map[string]interface{}{"`id`": requestData.MenuInfo.Id}, saveMenu)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
editForm := publicmethod.MapOut[string]()
|
|
var cusForm modelAppPlatform.CustomerForm
|
|
err = cusForm.GetCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, "`listjson`")
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(oldMenuInfo.Appkey)
|
|
syncSeting.Wait()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
editForm["listjson"] = string(menuTreeJson)
|
|
editForm["edit_time"] = time.Now().Unix()
|
|
cusForm.EiteCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, editForm)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-07 10:09:30
|
|
@ 功能: 删除app菜单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) DelAppMenu(c *gin.Context) {
|
|
var requestData publicmethod.PublicStates
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Status == 0 {
|
|
requestData.Status = 1
|
|
}
|
|
var oldMenuInfo modelAppPlatform.Appmenus
|
|
err = oldMenuInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`type`", `appkey`)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveMenu := publicmethod.MapOut[string]()
|
|
saveMenu["`state`"] = requestData.Status
|
|
saveMenu["`edit_time`"] = time.Now().Unix()
|
|
err = oldMenuInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveMenu)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
editForm := publicmethod.MapOut[string]()
|
|
var cusForm modelAppPlatform.CustomerForm
|
|
err = cusForm.GetCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, "`listjson`")
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(oldMenuInfo.Appkey)
|
|
syncSeting.Wait()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
editForm["listjson"] = string(menuTreeJson)
|
|
editForm["edit_time"] = time.Now().Unix()
|
|
cusForm.EiteCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, editForm)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-15 14:27:49
|
|
@ 功能: 创建App表单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) CreateAppForm(c *gin.Context) {
|
|
var requestData AddAppFormPageInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.AppKey == "" {
|
|
publicmethod.Result(1, err, c, "未知应用!不可添加")
|
|
return
|
|
}
|
|
if requestData.GroupKey == "" {
|
|
publicmethod.Result(1, err, c, "未知分组!不可添加!")
|
|
return
|
|
}
|
|
if requestData.Data == "" {
|
|
publicmethod.Result(1, err, c, "自定义表单错误!")
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if requestData.Classify == 0 {
|
|
requestData.Classify = 1
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 4
|
|
}
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(requestData.JsonData), &formJsonCont)
|
|
if formJsonCont.Form.FormName == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if formJsonCont.Form.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单标识!")
|
|
return
|
|
}
|
|
//获取人员信息
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context)
|
|
cureeTime := time.Now().Unix()
|
|
|
|
var customerFormCont modelAppPlatform.CustomerForm
|
|
err = customerFormCont.GetCont(map[string]interface{}{"`tablename`": formJsonCont.Form.Name}, "`id`")
|
|
if err == nil || customerFormCont.Id != 0 {
|
|
publicmethod.Result(1, err, c, "已有相同表单标识!请更换后再提交!")
|
|
return
|
|
}
|
|
customerFormCont.Name = formJsonCont.Form.FormName //表单名称"`
|
|
customerFormCont.TableNames = formJsonCont.Form.Name //创建表单名称"`
|
|
customerFormCont.Classify = requestData.Types //分类 1表单 2列表 3:app 4:app表单
|
|
customerFormCont.Permit = "" //授权范围"`
|
|
customerFormCont.States = 1 //显示状态(1:启用;2:禁用,3:删除)"`
|
|
customerFormCont.CreaterTime = cureeTime //创建时间"`
|
|
customerFormCont.EditTime = cureeTime //编辑时间"`
|
|
customerFormCont.Icon = formJsonCont.Config.ImageUrl
|
|
groupId, _ := strconv.ParseInt(requestData.AppKey, 10, 64)
|
|
customerFormCont.Groupid = groupId
|
|
|
|
signCode, _ := strconv.ParseInt(requestData.SignCode, 10, 64)
|
|
if requestData.SignCode == "" {
|
|
signCode = 0
|
|
}
|
|
customerFormCont.SignCode = signCode
|
|
var formVersion modelAppPlatform.CustomerFormVersion
|
|
formVersion.TableKey = formJsonCont.Form.Name //default:'';not null;comment:表单标识符"`
|
|
varsionNum := customerform.HageFormVersionNum(formJsonCont.Form.Name)
|
|
formVersion.Version = varsionNum //1;not null;comment:版本号"`
|
|
if varsionNum > 1 {
|
|
formVersion.Status = 2
|
|
} else {
|
|
formVersion.Status = 1 //not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
|
|
}
|
|
formVersion.MastesForm = requestData.Data //';comment:表单结构"`
|
|
formVersion.MastesFormJson = requestData.JsonData //efault:'';comment:表单结构json"`
|
|
formVersion.Creater = userCont.Key //ult:0;not null;comment:创建人"`
|
|
formVersion.CreaterTime = cureeTime //not null;comment:创建时间"`
|
|
formVersion.EditTime = cureeTime //efault:0;not null;comment:编辑时间"`
|
|
formVersion.Dict = requestData.Dict //字表结构"`
|
|
// return
|
|
fmt.Printf("进行数据源操作------------>%v\n", formJsonCont.Form)
|
|
if formJsonCont.Form.DataSource == "yes" { //进行数据源操作
|
|
var sqlDb datacenter.DataBastType
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
if err != nil {
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
if err != nil {
|
|
publicmethod.Result(0, sqlDb, c)
|
|
return
|
|
}
|
|
}
|
|
mastSql, _ := formJsonCont.CreateActiveFormTable(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
formVersion.TableStructure = mastSql //;default:'';comment:字表结构"`
|
|
// publicmethod.Result(0, mastSql, c)
|
|
} else { //无数据源操作
|
|
|
|
// mastSql, _ := formJsonCont.CreateFormDatabaseTable()
|
|
// mastSql, _ := formJsonCont.DisassembleForm()
|
|
mastSql, _ := formJsonCont.CreateFormTable()
|
|
formVersion.TableStructure = mastSql //;default:'';comment:字表结构"`
|
|
|
|
}
|
|
|
|
createDb := overall.CONSTANT_DB_AppPlatform.Begin()
|
|
errMain := createDb.Create(&customerFormCont).Error
|
|
errVer := createDb.Create(&formVersion).Error
|
|
sendErr := publicmethod.MapOut[string]()
|
|
if errMain != nil || errVer != nil {
|
|
createDb.Rollback()
|
|
sendErr := publicmethod.MapOut[string]()
|
|
sendErr["errMain"] = errMain
|
|
sendErr["errVer"] = errVer
|
|
publicmethod.Result(104, sendErr, c)
|
|
return
|
|
}
|
|
err = createDb.Commit().Error
|
|
sendErr["err"] = err
|
|
sendErr["customerFormCont"] = customerFormCont
|
|
sendErr["formVersion"] = formVersion
|
|
// err = createDb.Create(&customerFormCont).Error
|
|
// if err != nil {
|
|
// publicmethod.Result(104, customerFormCont, c)
|
|
// return
|
|
// }
|
|
parentId, _ := strconv.ParseInt(requestData.MenuId, 10, 64)
|
|
if parentId == 0 {
|
|
parentId = groupId
|
|
}
|
|
SaveAppFormMenu(signCode, groupId, parentId, userCont.Key, cureeTime, 2, requestData.Name)
|
|
publicmethod.Result(0, sendErr, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-20 16:31:26
|
|
@ 功能: 保存新版本
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SaveOtherVersion(c *gin.Context) {
|
|
var requestData AddAppFormPageInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.AppKey == "" {
|
|
publicmethod.Result(1, err, c, "未知应用!不可添加")
|
|
return
|
|
}
|
|
if requestData.GroupKey == "" {
|
|
publicmethod.Result(1, err, c, "未知分组!不可添加!")
|
|
return
|
|
}
|
|
if requestData.Data == "" {
|
|
publicmethod.Result(1, err, c, "自定义表单错误!")
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if requestData.Classify == 0 {
|
|
requestData.Classify = 1
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 4
|
|
}
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(requestData.JsonData), &formJsonCont)
|
|
if formJsonCont.Form.FormName == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if formJsonCont.Form.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单标识!")
|
|
return
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context)
|
|
cureeTime := time.Now().Unix()
|
|
var customerFormCont modelAppPlatform.CustomerForm
|
|
err = customerFormCont.GetCont(map[string]interface{}{"`tablename`": formJsonCont.Form.Name})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
mainData := publicmethod.MapOut[string]()
|
|
if formJsonCont.Config.ImageUrl != "" && formJsonCont.Config.ImageUrl != customerFormCont.Icon {
|
|
mainData["`icon`"] = formJsonCont.Config.ImageUrl
|
|
|
|
}
|
|
if formJsonCont.Form.FormName != "" && formJsonCont.Form.FormName != customerFormCont.Name {
|
|
mainData["`name`"] = formJsonCont.Form.FormName
|
|
var appMenuCont modelAppPlatform.Appmenus
|
|
appMenuCont.GetCont(map[string]interface{}{"`id`": customerFormCont.SignCode}, "`parent`")
|
|
SaveAppFormMenu(customerFormCont.SignCode, customerFormCont.Groupid, appMenuCont.Parent, userCont.Key, cureeTime, 2, formJsonCont.Form.FormName)
|
|
}
|
|
groupIdStr := strconv.FormatInt(customerFormCont.Groupid, 10)
|
|
if formJsonCont.Config.GroupKey != "" && formJsonCont.Config.GroupKey != groupIdStr {
|
|
groupId, _ := strconv.ParseInt(formJsonCont.Config.GroupKey, 10, 64)
|
|
mainData["`groupid`"] = groupId
|
|
}
|
|
if len(mainData) > 0 {
|
|
mainData["`edit_time`"] = cureeTime
|
|
customerFormCont.EiteCont(map[string]interface{}{"`id`": customerFormCont.Id}, mainData)
|
|
}
|
|
var formVersion modelAppPlatform.CustomerFormVersion
|
|
formVersion.TableKey = customerFormCont.TableNames //default:'';not null;comment:表单标识符"`
|
|
varsionNum := customerform.HageFormVersionNum(customerFormCont.TableNames)
|
|
formVersion.Version = varsionNum //1;not null;comment:版本号"`
|
|
if varsionNum > 1 {
|
|
formVersion.Status = 2
|
|
} else {
|
|
formVersion.Status = 1 //not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
|
|
}
|
|
formVersion.MastesForm = requestData.Data //';comment:表单结构"`
|
|
formVersion.MastesFormJson = requestData.JsonData //efault:'';comment:表单结构json"`
|
|
formVersion.Creater = userCont.Key //ult:0;not null;comment:创建人"`
|
|
formVersion.CreaterTime = cureeTime //not null;comment:创建时间"`
|
|
formVersion.EditTime = cureeTime //efault:0;not null;comment:编辑时间"`
|
|
// mastSql, _ := formJsonCont.CreateFormDatabaseTable()
|
|
// mastSql, _ := formJsonCont.DisassembleForm()
|
|
|
|
if formJsonCont.Form.DataSource == "yes" { //进行数据源操作
|
|
var sqlDb datacenter.DataBastType
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
if err != nil {
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
if err != nil {
|
|
publicmethod.Result(0, sqlDb, c)
|
|
return
|
|
}
|
|
}
|
|
mastSql, _ := formJsonCont.CreateActiveFormTable(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
formVersion.TableStructure = mastSql //;default:'';comment:字表结构"`
|
|
} else { //无数据源操作
|
|
mastSql, _ := formJsonCont.CreateFormTable()
|
|
formVersion.TableStructure = mastSql //;default:'';comment:字表结构"`
|
|
|
|
}
|
|
|
|
// mastSql, _ := formJsonCont.CreateFormTable()
|
|
// formVersion.TableStructure = mastSql //;default:'';comment:字表结构"`
|
|
|
|
formVersion.Dict = requestData.Dict //字表结构"`
|
|
errVer := overall.CONSTANT_DB_AppPlatform.Create(&formVersion).Error
|
|
if errVer != nil {
|
|
publicmethod.Result(104, customerFormCont, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, formVersion, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-20 15:21:51
|
|
@ 功能:编辑App表单数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditAppPageInfo(c *gin.Context) {
|
|
var requestData EditAppFormPageInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.AppKey == "" {
|
|
publicmethod.Result(1, err, c, "未知应用!不可添加")
|
|
return
|
|
}
|
|
if requestData.GroupKey == "" {
|
|
publicmethod.Result(1, err, c, "未知分组!不可添加!")
|
|
return
|
|
}
|
|
if requestData.Data == "" {
|
|
publicmethod.Result(1, err, c, "自定义表单错误!")
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(1, err, c, "未知表单!")
|
|
return
|
|
}
|
|
if requestData.Version == "" {
|
|
publicmethod.Result(1, err, c, "未知表单!")
|
|
return
|
|
}
|
|
if requestData.MenuId == "" {
|
|
publicmethod.Result(1, err, c, "未知表单!")
|
|
return
|
|
}
|
|
if requestData.Classify == 0 {
|
|
requestData.Classify = 1
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 4
|
|
}
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(requestData.JsonData), &formJsonCont)
|
|
if formJsonCont.Form.FormName == "" {
|
|
publicmethod.Result(1, err, c, "未知表单名称!")
|
|
return
|
|
}
|
|
if formJsonCont.Form.Name == "" {
|
|
publicmethod.Result(1, err, c, "未知表单标识!")
|
|
return
|
|
}
|
|
var customerFormCont modelAppPlatform.CustomerForm
|
|
err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`tablename`", "`signCode`", "`classify`", "`listjson`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context)
|
|
cureeTime := time.Now().Unix()
|
|
mainData := publicmethod.MapOut[string]()
|
|
mainData["`name`"] = formJsonCont.Form.FormName
|
|
mainData["`classify`"] = requestData.Types
|
|
mainData["`edit_time`"] = cureeTime
|
|
if formJsonCont.Config.ImageUrl != "" {
|
|
mainData["`icon`"] = formJsonCont.Config.ImageUrl
|
|
}
|
|
groupId, _ := strconv.ParseInt(formJsonCont.Config.GroupKey, 10, 64)
|
|
mainData["`groupid`"] = groupId
|
|
if customerFormCont.Classify == 4 && customerFormCont.ListJson != "" {
|
|
|
|
listjson, isTrue := ListFields(customerFormCont.ListJson, formJsonCont.List)
|
|
if isTrue {
|
|
mainData["`listjson`"] = listjson
|
|
}
|
|
// fmt.Printf("searchMap-->%v\n", searchMap)
|
|
}
|
|
customerFormCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, mainData)
|
|
versionData := publicmethod.MapOut[string]()
|
|
versionData["`mastesform`"] = requestData.Data
|
|
versionData["`mastesformjson`"] = requestData.JsonData
|
|
versionData["`creater`"] = userCont.Key
|
|
// mastSql, _ := formJsonCont.DisassembleForm()
|
|
// mastSql, _ := formJsonCont.CreateFormDatabaseTable()
|
|
|
|
if formJsonCont.Form.DataSource == "yes" { //进行数据源操作
|
|
var sqlDb datacenter.DataBastType
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
if err != nil {
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
if err != nil {
|
|
publicmethod.Result(0, sqlDb, c)
|
|
return
|
|
}
|
|
}
|
|
mastSql, _ := formJsonCont.CreateActiveFormTable(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
versionData["`table_structure`"] = mastSql
|
|
} else { //无数据源操作
|
|
mastSql, _ := formJsonCont.CreateFormTable()
|
|
versionData["`table_structure`"] = mastSql
|
|
|
|
}
|
|
|
|
// mastSql, _ := formJsonCont.CreateFormTable()
|
|
// versionData["`table_structure`"] = mastSql
|
|
|
|
versionData["`dict`"] = requestData.Dict
|
|
var formVersion modelAppPlatform.CustomerFormVersion
|
|
formVersion.EiteCont(map[string]interface{}{"`id`": requestData.Version}, versionData)
|
|
var appMenuCont modelAppPlatform.Appmenus
|
|
appMenuCont.GetCont(map[string]interface{}{"`id`": customerFormCont.SignCode}, "`parent`")
|
|
SaveAppFormMenu(customerFormCont.SignCode, groupId, appMenuCont.Parent, userCont.Key, cureeTime, 2, formJsonCont.Form.FormName)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-09-14 08:33:50
|
|
@ 功能: 处理列表字段名称变更
|
|
*/
|
|
func ListFields(list string, ComponentList []customerform.MasterStruct) (listString string, isTrue bool) {
|
|
if list == "" {
|
|
isTrue = false
|
|
return
|
|
}
|
|
var searchMap map[string]interface{}
|
|
json.Unmarshal([]byte(list), &searchMap)
|
|
if searchData, isOk := searchMap["searchData"]; isOk {
|
|
if searchDataAry, isOk := searchData.([]interface{}); isOk {
|
|
var fileAry []interface{}
|
|
|
|
for _, v := range searchDataAry {
|
|
|
|
// fmt.Printf("处理列表字段名称变更:%v\n", v)
|
|
fieldKey, isTrue := WordToFile(v, ComponentList)
|
|
// WordToFile(v,ComponentList)
|
|
if isTrue {
|
|
fileAry = append(fileAry, fieldKey)
|
|
}
|
|
|
|
}
|
|
|
|
searchMap["searchData"] = fileAry
|
|
}
|
|
}
|
|
if tableData, isOk := searchMap["tableData"]; isOk {
|
|
if tableMap, isOk := tableData.(map[string]interface{}); isOk {
|
|
tableMapInfo := publicmethod.MapOut[string]()
|
|
if columns, isOk := tableMap["columns"]; isOk {
|
|
fmt.Printf("搜索列表字段-1->%T-->%v\n", columns, columns)
|
|
if columnsAry, isOk := columns.([]interface{}); isOk {
|
|
var fileTableAry []interface{}
|
|
for _, v := range columnsAry {
|
|
fieldKey, isTrue := WordToFile(v, ComponentList)
|
|
if isTrue {
|
|
fileTableAry = append(fileTableAry, fieldKey)
|
|
}
|
|
}
|
|
tableMapInfo["columns"] = fileTableAry
|
|
}
|
|
}
|
|
if config, isOk := tableMap["config"]; isOk {
|
|
tableMapInfo["config"] = config
|
|
}
|
|
if controlBtn, isOk := tableMap["controlBtn"]; isOk {
|
|
tableMapInfo["controlBtn"] = controlBtn
|
|
}
|
|
if operateBtn, isOk := tableMap["operateBtn"]; isOk {
|
|
tableMapInfo["operateBtn"] = operateBtn
|
|
}
|
|
searchMap["tableData"] = tableMapInfo
|
|
}
|
|
}
|
|
fileAryJson, _ := json.Marshal(searchMap)
|
|
fmt.Printf("搜索列表字段-7->%T-->%v\n", fileAryJson, string(fileAryJson))
|
|
listString = string(fileAryJson)
|
|
isTrue = true
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-09-14 08:46:39
|
|
@ 功能: 字段比对
|
|
*/
|
|
func WordToFile(filedInfo interface{}, ComponentList []customerform.MasterStruct) (interface{}, bool) {
|
|
// var fileName string
|
|
// filedMap := publicmethod.MapOut[string]()
|
|
isTrue := false
|
|
if filedMap, isOk := filedInfo.(map[string]interface{}); isOk {
|
|
if fileNames, isok := filedMap["id"]; isok {
|
|
if fliedString, isOk := fileNames.(string); isOk {
|
|
// fileName = fliedString
|
|
if publicmethod.IsInTrue[string](fliedString, []string{"checkbox", "serialNumber", "operate", "id", "masters_key", "creater", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"}) {
|
|
isTrue = true
|
|
} else {
|
|
for _, v := range ComponentList {
|
|
if v.Name == fliedString {
|
|
// fmt.Printf("搜索列表字段-5->%T-->%v\n", v.Item.Label, v.Item.Label)
|
|
filedMap["label"] = v.Item.Label
|
|
isTrue = true
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("搜索列表字段-4->%T-->%v\n", fliedString, fliedString)
|
|
|
|
// fmt.Printf("搜索列表字段-6->%T-->%v\n", filedMap, filedMap)
|
|
return filedMap, isTrue
|
|
|
|
}
|
|
}
|
|
}
|
|
return filedInfo, isTrue
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-17 08:44:07
|
|
@ 功能: 写入菜单
|
|
@ 参数
|
|
|
|
#menuId 菜单唯一识别符
|
|
#appkey 归属应用
|
|
#parent 上级
|
|
#creater 创建人
|
|
#cureeTime 时间
|
|
#class 菜单类型
|
|
#title 菜单名称
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#func SaveAppFormMenu(menuId, appkey, parent, creater, cureeTime int64, class int, title string)
|
|
*/
|
|
func SaveAppFormMenu(menuId, appkey, parent, creater, cureeTime int64, class int, title string) (errEnd error) {
|
|
var appMenuInfo modelAppPlatform.Appmenus
|
|
err := appMenuInfo.GetCont(map[string]interface{}{"`id`": menuId})
|
|
errEnd = nil
|
|
if err != nil {
|
|
var sortAll int64
|
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where(map[string]interface{}{"`appkey`": appkey}).Count(&sortAll)
|
|
//记录不错在即新建
|
|
appMenuInfo.Id = menuId //
|
|
appMenuInfo.Label = title //节点名称"`
|
|
appMenuInfo.Types = class //节点类型 1:目录;2:菜单"`
|
|
appMenuInfo.Svg = "gd" //图标"`
|
|
appMenuInfo.PcIsShow = 1 //pc端显示与隐藏(1:显示;非1:隐藏)"`
|
|
appMenuInfo.WapIsShow = 1 //移动端显示与隐藏(1:显示;非1:隐藏)"`
|
|
if parent != 0 {
|
|
appMenuInfo.Parent = parent //上级"`
|
|
} else {
|
|
appMenuInfo.Parent = appkey //上级"`
|
|
}
|
|
|
|
appMenuInfo.Appkey = appkey //归属哪个应用"`
|
|
appMenuInfo.CreaterTime = cureeTime //创建时间"`
|
|
appMenuInfo.EditTime = cureeTime //编辑时间"`
|
|
appMenuInfo.Creater = creater //创建人"`
|
|
appMenuInfo.IsLock = 2 //是否为固定菜单(1:是;2:否)"`
|
|
appMenuInfo.Sort = sortAll + 1 //排序"`
|
|
appMenuInfo.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
errEnd = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Create(&appMenuInfo).Error
|
|
} else {
|
|
saveData := publicmethod.MapOut[string]()
|
|
if title != appMenuInfo.Label {
|
|
saveData["`label`"] = title
|
|
}
|
|
if appkey != appMenuInfo.Appkey {
|
|
saveData["`appkey`"] = appkey
|
|
}
|
|
if parent != appMenuInfo.Parent {
|
|
saveData["`parent`"] = parent
|
|
}
|
|
if creater != appMenuInfo.Creater {
|
|
saveData["`creater`"] = creater
|
|
}
|
|
if class != appMenuInfo.Types {
|
|
saveData["`type`"] = class
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`edit_time`"] = cureeTime
|
|
errEnd = appMenuInfo.EiteCont(map[string]interface{}{"`id`": menuId}, saveData)
|
|
}
|
|
}
|
|
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(appkey)
|
|
syncSeting.Wait()
|
|
editForm := publicmethod.MapOut[string]()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
editForm["listjson"] = string(menuTreeJson)
|
|
editForm["`edit_time`"] = cureeTime
|
|
var appCont modelAppPlatform.CustomerForm
|
|
appCont.EiteCont(map[string]interface{}{"`signCode`": appkey}, editForm)
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-18 14:06:55
|
|
@ 功能: 获取app页面综合信息
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainAppPageInfo(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var appFormPage modelAppPlatform.CustomerFormView
|
|
err = appFormPage.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.Id})
|
|
if err != nil {
|
|
publicmethod.Result(105, err, c)
|
|
return
|
|
}
|
|
|
|
// publicmethod.Result(105, appFormPage, c)
|
|
// return
|
|
sendData := publicmethod.MapOut[string]()
|
|
sendData["appForm"] = appFormPage
|
|
sendData["versionId"] = strconv.FormatInt(appFormPage.Id, 10)
|
|
sendData["flowkey"] = strconv.FormatInt(appFormPage.Flowkey, 10)
|
|
sendData["groupid"] = strconv.FormatInt(appFormPage.Groupid, 10)
|
|
sendData["signCode"] = strconv.FormatInt(appFormPage.SignCode, 10)
|
|
|
|
if appFormPage.MastesForm == "" && appFormPage.MastesFormJson == "" {
|
|
sendData["page"] = false
|
|
} else {
|
|
sendData["page"] = true
|
|
}
|
|
if appFormPage.ListJson == "" {
|
|
sendData["pageList"] = false
|
|
} else {
|
|
sendData["pageList"] = true
|
|
}
|
|
sendData["appFlow"] = false
|
|
if appFormPage.FlowIsOpen == 1 {
|
|
|
|
var appFormFlow modelAppPlatform.FlowVersion
|
|
err = appFormFlow.GetCont(map[string]interface{}{"`state`": 1, "`key`": appFormPage.Flowkey}, "`content`")
|
|
if err != nil {
|
|
sendData["workFlow"] = ""
|
|
} else {
|
|
var flowInfor interface{}
|
|
err = json.Unmarshal([]byte(appFormFlow.Content), &flowInfor)
|
|
if err != nil {
|
|
sendData["workFlow"] = ""
|
|
} else {
|
|
sendData["workFlow"] = flowInfor
|
|
sendData["appFlow"] = true
|
|
}
|
|
}
|
|
|
|
} else {
|
|
sendData["workFlow"] = ""
|
|
}
|
|
var fieldList []string
|
|
if appFormPage.TableKey != "" {
|
|
masterFieldAry, mastErr := customerform.ReadDatabaseForm(appFormPage.TableKey)
|
|
if mastErr == nil {
|
|
for _, v := range masterFieldAry {
|
|
if !publicmethod.IsInTrue[string](v.Field, fieldList) {
|
|
fieldList = append(fieldList, v.Field)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if appFormPage.TableStructure != "" {
|
|
var sunTable map[string]string
|
|
err = json.Unmarshal([]byte(appFormPage.TableStructure), &sunTable)
|
|
if err == nil {
|
|
for _, v := range sunTable {
|
|
sonFieldAry, sunErr := customerform.ReadDatabaseForm(v)
|
|
if sunErr == nil {
|
|
for _, v := range sonFieldAry {
|
|
if !publicmethod.IsInTrue[string](v.Field, fieldList) {
|
|
fieldList = append(fieldList, v.Field)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sendData["formField"] = fieldList
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-21 08:31:45
|
|
@ 功能: 预览App多版本表单页面
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) PreviewAppFormVersion(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var appFormSersion LookCustomerFormInfo
|
|
err = appFormSersion.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
appFormSersion.GroupKey = strconv.FormatInt(appFormSersion.Groupid, 10)
|
|
json.Unmarshal([]byte(appFormSersion.Permit), &appFormSersion.PermitList)
|
|
if appFormSersion.TableKey != "" {
|
|
masterFieldAry, mastErr := customerform.ReadDatabaseForm(appFormSersion.TableKey)
|
|
if mastErr == nil {
|
|
for _, v := range masterFieldAry {
|
|
if !publicmethod.IsInTrue[string](v.Field, appFormSersion.FormField) {
|
|
appFormSersion.FormField = append(appFormSersion.FormField, v.Field)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if appFormSersion.TableStructure != "" {
|
|
var sunTable map[string]string
|
|
err = json.Unmarshal([]byte(appFormSersion.TableStructure), &sunTable)
|
|
if err == nil {
|
|
for _, v := range sunTable {
|
|
sonFieldAry, sunErr := customerform.ReadDatabaseForm(v)
|
|
appFormSersion.TableStructureMap = append(appFormSersion.TableStructureMap, v)
|
|
if sunErr == nil {
|
|
for _, v := range sonFieldAry {
|
|
if !publicmethod.IsInTrue[string](v.Field, appFormSersion.FormField) {
|
|
appFormSersion.FormField = append(appFormSersion.FormField, v.Field)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
publicmethod.Result(0, appFormSersion, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-22 16:38:17
|
|
@ 功能: 设置App基础
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AppBasicSettings(c *gin.Context) {
|
|
var requestData AppSetupInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Title == "" {
|
|
publicmethod.Result(1, err, c, "请输入App名称!")
|
|
return
|
|
}
|
|
if requestData.GroupKey == "" {
|
|
publicmethod.Result(1, err, c, "请选择App归属分组!")
|
|
return
|
|
}
|
|
var appInfo modelAppPlatform.CustomerForm
|
|
err = appInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveInfo := publicmethod.MapOut[string]()
|
|
if requestData.Title != appInfo.Name {
|
|
saveInfo["`name`"] = requestData.Title
|
|
}
|
|
if requestData.AppSvg != appInfo.Icon {
|
|
saveInfo["`icon`"] = requestData.AppSvg
|
|
}
|
|
groupKey, _ := strconv.ParseInt(requestData.GroupKey, 10, 64)
|
|
if groupKey != appInfo.Groupid {
|
|
saveInfo["`groupid`"] = groupKey
|
|
}
|
|
if requestData.Appdescribe != appInfo.Describe {
|
|
saveInfo["`describe`"] = requestData.Appdescribe
|
|
}
|
|
if len(saveInfo) > 0 {
|
|
saveInfo["`states`"] = 1
|
|
saveInfo["`edit_time`"] = time.Now().Unix()
|
|
err = appInfo.EiteCont(map[string]interface{}{"`signCode`": requestData.Id}, saveInfo)
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 08:14:10
|
|
@ 功能: 设置可见范围
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SetLookViews(c *gin.Context) {
|
|
var requestData SetAppLookViews
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var custFormInfo modelAppPlatform.CustomerForm
|
|
err = custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`userpermit`", "`postpermit`", "`orgpermit`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
if len(requestData.OrgRoleUs) <= 0 {
|
|
saveData["userpermit"] = ""
|
|
saveData["postpermit"] = ""
|
|
saveData["orgpermit"] = ""
|
|
} else {
|
|
var usAry []string
|
|
var orgAry []string
|
|
var roleAry []string
|
|
for _, v := range requestData.OrgRoleUs {
|
|
switch v.Types {
|
|
case 1:
|
|
if !publicmethod.IsInTrue[string](v.Id, usAry) {
|
|
usAry = append(usAry, v.Id)
|
|
}
|
|
case 2:
|
|
if !publicmethod.IsInTrue[string](v.Id, orgAry) {
|
|
orgAry = append(orgAry, v.Id)
|
|
}
|
|
case 3:
|
|
if !publicmethod.IsInTrue[string](v.Id, roleAry) {
|
|
roleAry = append(roleAry, v.Id)
|
|
}
|
|
default:
|
|
}
|
|
}
|
|
saveData["userpermit"] = strings.Join(usAry, ",")
|
|
saveData["postpermit"] = strings.Join(roleAry, ",")
|
|
saveData["orgpermit"] = strings.Join(orgAry, ",")
|
|
}
|
|
saveData["edit_time"] = time.Now().Unix()
|
|
err = custFormInfo.EiteCont(map[string]interface{}{"`id`": custFormInfo.Id}, saveData)
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 08:42:08
|
|
@ 功能: 设置管理使用人员
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SetAppManagerInfo(c *gin.Context) {
|
|
var requestData SetAppLookViews
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var custFormInfo modelAppPlatform.CustomerForm
|
|
err = custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`appManager`", "`appRoleManager`", "`appOrgMan`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
if len(requestData.OrgRoleUs) <= 0 {
|
|
saveData["appManager"] = ""
|
|
saveData["appRoleManager"] = ""
|
|
saveData["appOrgMan"] = ""
|
|
} else {
|
|
var usAry []string
|
|
var orgAry []string
|
|
var roleAry []string
|
|
for _, v := range requestData.OrgRoleUs {
|
|
switch v.Types {
|
|
case 1:
|
|
if !publicmethod.IsInTrue[string](v.Id, usAry) {
|
|
usAry = append(usAry, v.Id)
|
|
}
|
|
case 2:
|
|
if !publicmethod.IsInTrue[string](v.Id, orgAry) {
|
|
orgAry = append(orgAry, v.Id)
|
|
}
|
|
case 3:
|
|
if !publicmethod.IsInTrue[string](v.Id, roleAry) {
|
|
roleAry = append(roleAry, v.Id)
|
|
}
|
|
default:
|
|
}
|
|
}
|
|
saveData["appManager"] = strings.Join(usAry, ",")
|
|
saveData["appRoleManager"] = strings.Join(roleAry, ",")
|
|
saveData["appOrgMan"] = strings.Join(orgAry, ",")
|
|
}
|
|
saveData["edit_time"] = time.Now().Unix()
|
|
err = custFormInfo.EiteCont(map[string]interface{}{"`id`": custFormInfo.Id}, saveData)
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 10:35:20
|
|
@ 功能: 获取可见范围数据及应用管理
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainLookViews(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var custFormInfo modelAppPlatform.CustomerForm
|
|
err = custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`appManager`", "`appRoleManager`", "`appOrgMan`", "`userpermit`", "`postpermit`", "`orgpermit`")
|
|
saveData := make(map[string][]publicapi.UserOrgRole)
|
|
if err != nil {
|
|
var empty []publicapi.UserOrgRole
|
|
saveData["appLookView"] = empty
|
|
saveData["appManager"] = empty
|
|
publicmethod.Result(104, saveData, c)
|
|
return
|
|
}
|
|
var sendList CallBackAppOrgRoleUs
|
|
if custFormInfo.AppManager != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppUserList(custFormInfo.AppManager, 1)
|
|
}
|
|
if custFormInfo.AppOrgMan != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppOrgList(custFormInfo.AppOrgMan, 1)
|
|
}
|
|
if custFormInfo.AppRoleManager != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppRoleList(custFormInfo.AppRoleManager, 1)
|
|
}
|
|
|
|
if custFormInfo.UserPermit != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppUserList(custFormInfo.UserPermit, 2)
|
|
}
|
|
if custFormInfo.OrgPermit != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppOrgList(custFormInfo.OrgPermit, 2)
|
|
}
|
|
if custFormInfo.PostPermit != "" {
|
|
syncSeting.Add(1)
|
|
go sendList.GainAppRoleList(custFormInfo.PostPermit, 2)
|
|
}
|
|
syncSeting.Wait()
|
|
|
|
if len(sendList.AppOrgMan) > 0 {
|
|
saveData["appManager"] = append(saveData["appManager"], sendList.AppOrgMan...)
|
|
}
|
|
if len(sendList.AppRoleManager) > 0 {
|
|
saveData["appManager"] = append(saveData["appManager"], sendList.AppRoleManager...)
|
|
}
|
|
if len(sendList.AppManager) > 0 {
|
|
saveData["appManager"] = append(saveData["appManager"], sendList.AppManager...)
|
|
}
|
|
|
|
if len(sendList.PostPermit) > 0 {
|
|
saveData["appLookView"] = append(saveData["appLookView"], sendList.PostPermit...)
|
|
}
|
|
if len(sendList.OrgPermit) > 0 {
|
|
saveData["appLookView"] = append(saveData["appLookView"], sendList.OrgPermit...)
|
|
}
|
|
if len(sendList.UserPermit) > 0 {
|
|
saveData["appLookView"] = append(saveData["appLookView"], sendList.UserPermit...)
|
|
}
|
|
sort.Slice(saveData["appLookView"], func(i, j int) bool {
|
|
return saveData["appLookView"][i].Types > saveData["appLookView"][j].Types
|
|
})
|
|
sort.Slice(saveData["appManager"], func(i, j int) bool {
|
|
return saveData["appManager"][i].Types > saveData["appManager"][j].Types
|
|
})
|
|
publicmethod.Result(0, saveData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 11:13:47
|
|
@ 功能: 获取App角色
|
|
@val 关键字
|
|
@class 1:应用管理,2:可见范围
|
|
*/
|
|
func (c *CallBackAppOrgRoleUs) GainAppRoleList(val string, class int) {
|
|
defer syncSeting.Done()
|
|
if val != "" {
|
|
valAry := strings.Split(val, ",")
|
|
if len(valAry) > 0 {
|
|
var infoList []modelssystempermission.SystemRole
|
|
err := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`,`name`").Where("`id` IN ?", valAry).Find(&infoList).Error
|
|
if err == nil {
|
|
for _, v := range infoList {
|
|
var info publicapi.UserOrgRole
|
|
info.Id = strconv.FormatInt(v.Id, 10)
|
|
info.Title = v.Name
|
|
info.Img = ""
|
|
info.IsPick = 1
|
|
info.Types = 3
|
|
|
|
if class == 1 {
|
|
c.AppRoleManager = append(c.AppRoleManager, info)
|
|
} else {
|
|
c.PostPermit = append(c.PostPermit, info)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 10:43:42
|
|
@ 功能: 获取人员信息
|
|
@val 关键字
|
|
@class 1:应用管理,2:可见范围
|
|
*/
|
|
func (c *CallBackAppOrgRoleUs) GainAppUserList(val string, class int) {
|
|
defer syncSeting.Done()
|
|
if val != "" {
|
|
valAry := strings.Split(val, ",")
|
|
if len(valAry) > 0 {
|
|
var infoList []modelshr.PersonArchives
|
|
err := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`,`icon`,`icon_photo`").Where("`key` IN ?", valAry).Find(&infoList).Error
|
|
if err == nil {
|
|
for _, v := range infoList {
|
|
var info publicapi.UserOrgRole
|
|
info.Id = strconv.FormatInt(v.Key, 10)
|
|
info.Title = v.Name
|
|
info.Img = v.Icon
|
|
if v.IconPhoto != "" {
|
|
info.Img = v.IconPhoto
|
|
}
|
|
info.IsPick = 1
|
|
info.Types = 1
|
|
if class == 1 {
|
|
c.AppManager = append(c.AppManager, info)
|
|
} else {
|
|
c.UserPermit = append(c.UserPermit, info)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-28 11:04:09
|
|
@ 功能: 获取行政组织
|
|
@val 关键字
|
|
@class 1:应用管理,2:可见范围
|
|
*/
|
|
func (c *CallBackAppOrgRoleUs) GainAppOrgList(val string, class int) {
|
|
defer syncSeting.Done()
|
|
if val != "" {
|
|
valAry := strings.Split(val, ",")
|
|
if len(valAry) > 0 {
|
|
var infoList []modelshr.AdministrativeOrganization
|
|
err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`id` IN ?", valAry).Find(&infoList).Error
|
|
if err == nil {
|
|
for _, v := range infoList {
|
|
var info publicapi.UserOrgRole
|
|
info.Id = strconv.FormatInt(v.Id, 10)
|
|
info.Title = v.Name
|
|
info.Img = ""
|
|
info.IsPick = 1
|
|
info.Types = 2
|
|
|
|
if class == 1 {
|
|
c.AppOrgMan = append(c.AppOrgMan, info)
|
|
} else {
|
|
c.OrgPermit = append(c.OrgPermit, info)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-29 09:53:52
|
|
@ 功能: 获取应用下属表单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GianAppFormTable(c *gin.Context) {
|
|
var requestData SearchAppTable
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.PageSize == 0 {
|
|
requestData.PageSize = 10
|
|
}
|
|
if requestData.Page == 0 {
|
|
requestData.Page = 1
|
|
}
|
|
var formList []customerform.SendCustomerForm
|
|
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`states` = 1 AND `groupid` = ?", requestData.Id)
|
|
if requestData.Name != "" {
|
|
gormDb = gormDb.Where("`name` LIKE ? OR `tablename` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%")
|
|
}
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
err = gormDb.Order("`id` DESC").Find(&formList).Error
|
|
if err != nil && len(formList) < 1 {
|
|
publicmethod.Result(0, err, c)
|
|
return
|
|
}
|
|
for i, v := range formList {
|
|
userCont := customerform.HaveCustomerFormCreaterUs(v.TableNames)
|
|
if v.FlowKey != 0 {
|
|
formList[i].FlowKeyStr = strconv.FormatInt(v.FlowKey, 10)
|
|
}
|
|
formList[i].IdStr = strconv.FormatInt(v.Id, 10)
|
|
formList[i].CreaterName = userCont.Name
|
|
formList[i].CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
|
|
var versionInfo modelAppPlatform.CustomerFormVersion
|
|
versionInfo.GetCont(map[string]interface{}{"`status`": 1, "`tablekey`": v.TableNames}, "`id`")
|
|
formList[i].VersionId = strconv.FormatInt(versionInfo.Id, 10)
|
|
formList[i].SignCodeStr = strconv.FormatInt(v.SignCode, 10)
|
|
}
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-29 14:02:28
|
|
@ 功能: 设置自定义表单状态
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SetCustomerFormState(c *gin.Context) {
|
|
var requestData publicmethod.PublicState
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, requestData, c)
|
|
return
|
|
}
|
|
if requestData.IsTrue == 0 {
|
|
requestData.IsTrue = 2
|
|
}
|
|
if requestData.State == 0 {
|
|
requestData.IsTrue = 1
|
|
}
|
|
var custFormInfo modelAppPlatform.CustomerForm
|
|
err := custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`states`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["`states`"] = requestData.State
|
|
saveData["`edit_time`"] = time.Now().Unix()
|
|
err = custFormInfo.EiteCont(map[string]interface{}{"`signCode`": requestData.Id}, saveData)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-08-08 14:01:47
|
|
@ 功能: 编辑APP菜单图标
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditAppMenusIcon(c *gin.Context) {
|
|
var requestData EditAppMenuNAme
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
if requestData.Label == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var oldMenuInfo modelAppPlatform.Appmenus
|
|
err = oldMenuInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`svg`", "`type`", `appkey`)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveMenu := publicmethod.MapOut[string]()
|
|
saveMenu["`svg`"] = requestData.Label
|
|
saveMenu["`edit_time`"] = time.Now().Unix()
|
|
err = oldMenuInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveMenu)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
editForm := publicmethod.MapOut[string]()
|
|
var cusForm modelAppPlatform.CustomerForm
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(oldMenuInfo.Appkey)
|
|
syncSeting.Wait()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
editForm["listjson"] = string(menuTreeJson)
|
|
editForm["edit_time"] = time.Now().Unix()
|
|
cusForm.EiteCont(map[string]interface{}{"`signCode`": oldMenuInfo.Appkey}, editForm)
|
|
|
|
//
|
|
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-18 09:05:47
|
|
@ 功能: 获取分组App菜单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainAppGroupMenus(c *gin.Context) {
|
|
var appGroupList []modelAppPlatform.CustomerFormGroup
|
|
overall.CONSTANT_DB_AppPlatform.Where("`state` = 1").Order("`sort` DESC").Order("`id` ASC").Find(&appGroupList)
|
|
|
|
var appList GroupAppList
|
|
var sendList []interface{}
|
|
if len(appGroupList) > 0 {
|
|
|
|
for _, v := range appGroupList {
|
|
syncSeting.Add(1)
|
|
go appList.GroupAppList(v.Id)
|
|
}
|
|
syncSeting.Wait()
|
|
if len(appList.List) > 0 {
|
|
for _, v := range appList.List {
|
|
syncSeting.Add(1)
|
|
appKey, _ := strconv.ParseInt(v.Id, 10, 64)
|
|
var appMenu AppMenuTree
|
|
appMenu.Id = v.Id //id"`
|
|
appMenu.Label = v.Name //label"`
|
|
appMenu.Types = 3 //type"`
|
|
appMenu.Svg = "" //svg" `
|
|
appMenu.PcIsShow = 1 //pcIsShow"`
|
|
appMenu.WapIsShow = 1 //wapIsShow"`
|
|
appMenu.Parent = v.GroupId //parent"`
|
|
appMenu.Appkey = v.GroupId //appkey"`
|
|
appMenu.IsLock = 2 //isLock"`
|
|
appMenu.Sort = 1 //sort"`
|
|
appMenu.State = 1 //state"`
|
|
appMenu.IsMain = 1 //isMain"`
|
|
appMenu.Icon = "" //icon"`
|
|
appMenu.Children = GainAppTree(appKey) //children"`
|
|
sendList = append(sendList, appMenu)
|
|
}
|
|
syncSeting.Wait()
|
|
}
|
|
|
|
}
|
|
// syncSeting.Add(1)
|
|
// sendInfo["menuTree"] = GainAppMenuTree(appCont.SignCode)
|
|
syncSeting.Wait()
|
|
publicmethod.Result(0, sendList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-18 13:38:30
|
|
@ 功能: 获取分组下得App列表
|
|
*/
|
|
func (g *GroupAppList) GroupAppList(id int64) {
|
|
defer syncSeting.Done()
|
|
if id == 0 {
|
|
return
|
|
} else {
|
|
var formList []modelAppPlatform.CustomerForm
|
|
overall.CONSTANT_DB_AppPlatform.Where("`states` = 1 AND `classify` = 3 AND `groupid` = ?", id).Find(&formList)
|
|
if len(formList) > 0 {
|
|
for _, v := range formList {
|
|
var formApp TransferMenu
|
|
formApp.Id = strconv.FormatInt(v.SignCode, 10)
|
|
formApp.Name = v.Name
|
|
formApp.GroupId = strconv.FormatInt(id, 10)
|
|
g.List = append(g.List, formApp)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
func GainAppTree(key int64) (menusTree []AppMenuTree) {
|
|
defer syncSeting.Done()
|
|
if key == 0 {
|
|
return
|
|
}
|
|
var menuList []modelAppPlatform.Appmenus
|
|
err := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1 AND `isLock` = 2 AND `appkey` = ?", key).Find(&menuList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].EditTime < menuList[j].EditTime
|
|
})
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].Sort < menuList[j].Sort
|
|
})
|
|
menusTree = AppTreeMenus(key, menuList)
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-19 07:56:31
|
|
@ 功能: 移动栏目
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) MoveAppMenus(c *gin.Context) {
|
|
var requestData MoveAppMenusId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.MenuId == "" || requestData.OldMenuId == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var newAppkey int64
|
|
var oldAppkey int64
|
|
//Step 1:获取愿菜单基本信息
|
|
var oldAppMenus modelAppPlatform.Appmenus
|
|
err = oldAppMenus.GetCont(map[string]interface{}{"`id`": requestData.OldMenuId})
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "数据错误!请重新操作!")
|
|
return
|
|
}
|
|
oldAppkey = oldAppMenus.Appkey
|
|
//Step 2:获取旧菜单是否有子菜单
|
|
var sunAppId AppSunMenus
|
|
sunAppId.HaveMenuSun(oldAppMenus.Id)
|
|
|
|
var newFormInfo modelAppPlatform.CustomerForm
|
|
err = newFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.MenuId})
|
|
//修改主应用表
|
|
var mastMenuEdit modelAppPlatform.CustomerForm
|
|
editMenuInfo := publicmethod.MapOut[string]()
|
|
editMenuInfo["groupid"] = newFormInfo.Groupid
|
|
editMenuInfo["edit_time"] = time.Now().Unix()
|
|
err = mastMenuEdit.EiteCont(map[string]interface{}{"`signCode`": requestData.OldMenuId}, editMenuInfo)
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "数据错误!请重新操作!")
|
|
return
|
|
}
|
|
sunEditMenu := publicmethod.MapOut[string]()
|
|
|
|
//修改主菜单信息
|
|
var mastAppMenuEdit modelAppPlatform.Appmenus
|
|
editAppMenuInfo := publicmethod.MapOut[string]()
|
|
editAppMenuInfo["edit_time"] = time.Now().Unix()
|
|
editAppMenuInfo["parent"] = requestData.MenuId
|
|
if newFormInfo.Classify != 3 {
|
|
var newParentMenu modelAppPlatform.Appmenus
|
|
newParentMenu.GetCont(map[string]interface{}{"`id`": requestData.MenuId})
|
|
editAppMenuInfo["appkey"] = newParentMenu.Appkey
|
|
sunEditMenu["appkey"] = newParentMenu.Appkey
|
|
newAppkey = newParentMenu.Appkey
|
|
} else {
|
|
editAppMenuInfo["appkey"] = newFormInfo.SignCode
|
|
sunEditMenu["appkey"] = newFormInfo.SignCode
|
|
newAppkey = newFormInfo.SignCode
|
|
}
|
|
err = mastAppMenuEdit.EiteCont(map[string]interface{}{"`id`": requestData.OldMenuId}, editAppMenuInfo)
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "数据错误!请重新操作!")
|
|
return
|
|
}
|
|
if len(sunAppId.Key) > 0 {
|
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`signCode` IN ?", sunAppId.Key).Updates(editMenuInfo)
|
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where("`id` IN ?", sunAppId.Key).Updates(sunEditMenu)
|
|
}
|
|
|
|
//目标App菜单重组
|
|
var newAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
newAppMenuJson = GainAppMenuTree(newAppkey)
|
|
syncSeting.Wait()
|
|
menuTreeJson, _ := json.Marshal(newAppMenuJson)
|
|
sunEditMenuJson := publicmethod.MapOut[string]()
|
|
sunEditMenuJson["listjson"] = string(menuTreeJson)
|
|
var newMoveFormInfo modelAppPlatform.CustomerForm
|
|
newMoveFormInfo.EiteCont(map[string]interface{}{"`signCode`": newAppkey}, sunEditMenuJson)
|
|
if newAppkey != oldAppkey {
|
|
var oldAppMenuJson []AppMenuTree
|
|
syncSeting.Add(1)
|
|
oldAppMenuJson = GainAppMenuTree(oldAppkey)
|
|
syncSeting.Wait()
|
|
menuTreeJsonOld, _ := json.Marshal(oldAppMenuJson)
|
|
sunoldEditMenuJson := publicmethod.MapOut[string]()
|
|
sunoldEditMenuJson["listjson"] = string(menuTreeJsonOld)
|
|
var newMoveFormInfo modelAppPlatform.CustomerForm
|
|
newMoveFormInfo.EiteCont(map[string]interface{}{"`signCode`": oldAppkey}, sunoldEditMenuJson)
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-19 08:19:48
|
|
@ 功能: 递归获取子级菜单目录
|
|
*/
|
|
func (a *AppSunMenus) HaveMenuSun(prentId int64) {
|
|
if prentId != 0 {
|
|
var appMenus []modelAppPlatform.Appmenus
|
|
overall.CONSTANT_DB_AppPlatform.Where("`parent` = ?", prentId).Find(&appMenus)
|
|
if len(appMenus) > 0 {
|
|
for _, v := range appMenus {
|
|
a.Key = append(a.Key, v.Id)
|
|
a.HaveMenuSun(v.Id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|