package customerApp
import (
"appPlatform/api/version1/customerform"
datacenter "appPlatform/api/version1/dataCenter"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 05 - 29 16 : 34 : 23
@ 功能 : 鉴定当权人员是否有权限使用
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) AppJwtPower ( c * gin . Context ) {
var requestData JwtPower
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 ) //当前操作人
if userCont . Role != "" {
roleAry := strings . Split ( userCont . Role , "," )
if len ( roleAry ) > 0 {
if publicmethod . IsInTrue [ string ] ( "1" , roleAry ) {
publicmethod . Result ( 0 , true , c )
return
}
}
}
var custFormInfo modelAppPlatform . CustomerForm
err = custFormInfo . GetCont ( map [ string ] interface { } { "`signCode`" : requestData . Id } , "`id`" , "`appManager`" , "`appRoleManager`" , "`appOrgMan`" , "`userpermit`" , "`postpermit`" , "`orgpermit`" )
if err != nil {
publicmethod . Result ( 0 , false , c )
return
}
if requestData . Types == 2 {
//操作权限
var jwtIsTrue TreeJwtPower
if custFormInfo . AppRoleManager != "" {
syncSeting . Add ( 1 )
go jwtIsTrue . JwtRoleViewsIsTrue ( custFormInfo . AppRoleManager , userCont . Role )
}
if custFormInfo . AppOrgMan != "" {
syncSeting . Add ( 1 )
go jwtIsTrue . JwtOrgViewsIsTrue ( custFormInfo . OrgPermit , userCont . AdminOrg )
}
if custFormInfo . AppManager != "" {
userKey := strconv . FormatInt ( userCont . Key , 10 )
syncSeting . Add ( 1 )
go jwtIsTrue . JwtPeopleViewsIsTrue ( custFormInfo . AppManager , userKey )
}
syncSeting . Wait ( )
if jwtIsTrue . Role || jwtIsTrue . Org || jwtIsTrue . People {
publicmethod . Result ( 0 , true , c )
return
} else {
publicmethod . Result ( 0 , false , c )
return
}
} else {
//可见范围
var jwtIsTrue TreeJwtPower
if custFormInfo . PostPermit != "" {
syncSeting . Add ( 1 )
go jwtIsTrue . JwtRoleViewsIsTrue ( custFormInfo . PostPermit , userCont . Role )
}
if custFormInfo . OrgPermit != "" {
syncSeting . Add ( 1 )
go jwtIsTrue . JwtOrgViewsIsTrue ( custFormInfo . OrgPermit , userCont . AdminOrg )
}
if custFormInfo . UserPermit != "" {
userKey := strconv . FormatInt ( userCont . Key , 10 )
syncSeting . Add ( 1 )
go jwtIsTrue . JwtPeopleViewsIsTrue ( custFormInfo . UserPermit , userKey )
}
syncSeting . Wait ( )
if jwtIsTrue . Role || jwtIsTrue . Org || jwtIsTrue . People {
publicmethod . Result ( 0 , true , c )
return
} else {
publicmethod . Result ( 0 , false , c )
return
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 05 - 30 0 8 : 10 : 32
@ 功能 : 使用人鉴权
@ 参数
# jwpUser 使用人员
# userKEy 个人权限
@ 返回值
#
@ 方法原型
#
* /
func ( t * TreeJwtPower ) JwtPeopleViewsIsTrue ( jwpUser , userKEy string ) {
defer syncSeting . Done ( )
if jwpUser == "" {
t . People = true
} else {
if userKEy == "" {
t . People = false
} else {
jwtRoleAry := strings . Split ( jwpUser , "," )
if publicmethod . IsInTrue [ string ] ( userKEy , jwtRoleAry ) {
t . People = true
} else {
t . People = false
}
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 05 - 30 0 8 : 24 : 55
@ 功能 : 鉴定行政组织授权
@ 参数
# jwpRoel 应用行政组织
# userRole 个人行政组织
@ 返回值
#
@ 方法原型
#
* /
func ( t * TreeJwtPower ) JwtOrgViewsIsTrue ( jwpOrg string , userOrg int64 ) {
if jwpOrg == "" {
t . Org = true
} else {
if userOrg == 0 {
t . Org = false
} else {
var allOrg [ ] int64
jwtOrgAry := strings . Split ( jwpOrg , "," )
for _ , v := range jwtOrgAry {
orgId , _ := strconv . ParseInt ( v , 10 , 64 )
var sunOrg publicmethod . GetOrgAllParent
sunOrg . GetOrgSonAllId ( orgId )
allOrg = append ( allOrg , orgId )
allOrg = append ( allOrg , sunOrg . Id ... )
}
if publicmethod . IsInTrue [ int64 ] ( userOrg , allOrg ) {
t . Org = true
} else {
t . Org = false
}
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 05 - 30 0 8 : 10 : 32
@ 功能 : 角色鉴权
@ 参数
# jwpRoel 应用权限
# userRole 个人权限
@ 返回值
#
@ 方法原型
#
* /
func ( t * TreeJwtPower ) JwtRoleViewsIsTrue ( jwpRoel , userRole string ) {
defer syncSeting . Done ( )
if jwpRoel == "" {
t . Role = true
} else {
if userRole == "" {
t . Role = false
} else {
jwtRoleAry := strings . Split ( jwpRoel , "," )
userRoleAry := strings . Split ( userRole , "," )
t . Role = false
for _ , v := range userRoleAry {
if publicmethod . IsInTrue [ string ] ( v , jwtRoleAry ) {
t . Role = true
}
}
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 10 - 31 13 : 33 : 16
@ 功能 : 获取此应用的所有表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetAllAppTableForm ( c * gin . Context ) {
var requestData GainAppForm
c . ShouldBindJSON ( & requestData )
if requestData . Id == "" {
publicmethod . Result ( 102 , requestData , c )
return
}
if requestData . Types == 0 {
requestData . Types = 1
}
if requestData . Page == 0 {
requestData . Page = 1
}
if requestData . PageSize == 0 {
if requestData . Types != 2 {
requestData . PageSize = 20
} else {
requestData . PageSize = 6
}
}
var appMenusList [ ] SendAppForm
gormDb := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . Appmenus { } ) . Where ( "`state` = 1 AND `type` = 2 AND `isLock` = 2 AND `appkey` = ?" , requestData . Id )
if requestData . Types == 2 {
gormDb = gormDb . Where ( "`wapIsShow` = ?" , 1 )
} else {
gormDb = gormDb . Where ( "`pcIsShow` = ?" , 1 )
}
var total int64
totalErr := gormDb . Count ( & total ) . Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod . PageTurningSettings ( gormDb , requestData . Page , requestData . PageSize )
gormDb . Order ( "`sort` DESC" ) . Find ( & appMenusList )
for i , v := range appMenusList {
appMenusList [ i ] . IdStr = strconv . FormatInt ( v . Id , 10 )
appMenusList [ i ] . AppkStr = strconv . FormatInt ( v . Appkey , 10 )
appMenusList [ i ] . ParentStr = strconv . FormatInt ( v . Parent , 10 )
appMenusList [ i ] . CreaterStr = strconv . FormatInt ( v . Creater , 10 )
var tableFormInfo modelAppPlatform . CustomerFormView
err := tableFormInfo . GetCont ( map [ string ] interface { } { "`status`" : 1 , "`signCode`" : v . Id } , "`id`" , "`cfid`" , "`time`" , "`icon`" , "`listjson`" )
if err == nil {
if tableFormInfo . ListJson != "" {
appMenusList [ i ] . IsList = true
} else {
appMenusList [ i ] . IsList = false
}
appMenusList [ i ] . VersionId = strconv . FormatInt ( tableFormInfo . Id , 10 )
appMenusList [ i ] . TableId = strconv . FormatInt ( tableFormInfo . CfId , 10 )
var usInfo modelshr . PersonArchives //获取创建人
usInfo . GetCont ( map [ string ] interface { } { "`key`" : v . Creater } , "`name`" , "`number`" )
appMenusList [ i ] . Founder = fmt . Sprintf ( "%v(%v)" , usInfo . Name , usInfo . Number )
appMenusList [ i ] . CreateDate = publicmethod . UnixTimeToDay ( tableFormInfo . CreaterTime , 14 )
appMenusList [ i ] . Icon = tableFormInfo . Icon
}
}
publicmethod . ResultList ( 0 , requestData . Page , requestData . PageSize , total , int64 ( len ( appMenusList ) ) , appMenusList , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 10 - 31 15 : 38 : 32
@ 功能 : 计算待办事宜 , 已办事宜 , 我创建的 , 抄送我的数量
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) CalculateQuantityOption ( c * gin . Context ) {
var requestData AppIdType
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 ) //当前操作人
var taskItem [ ] modelAppPlatform . Appmenus
gormDb := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . Appmenus { } ) . Where ( "`isLock` = 1 AND `type` = 2 AND `state` = 1 AND `appkey` = ?" , requestData . Id )
if requestData . Types == 2 {
gormDb = gormDb . Where ( "`wapIsShow` = 1" )
} else {
gormDb = gormDb . Where ( "`pcIsShow` = 1" )
}
gormDb . Order ( "`sort` ASC" ) . Find ( & taskItem )
var StatisTaskPage StatisTaskCount
StatisTaskPage . userCont = userCont
for _ , v := range taskItem {
StatisTaskPage . Types = v . IsMain
syncSeting . Add ( 1 )
go StatisTaskPage . GetTotalPAge ( requestData . Id , v . IsMain )
}
syncSeting . Wait ( )
var sendData [ ] SendStatisInfo
for _ , v := range taskItem {
var sendInfo SendStatisInfo
sendInfo . Lable = v . Label
sendInfo . Icon = v . Svg
sendInfo . Sort = v . IsMain
switch v . IsMain {
case 1 : //待办事宜
sendInfo . Count = StatisTaskPage . ToDoCount
case 2 : //已办事宜
sendInfo . Count = StatisTaskPage . AlreadyDoneCount
case 5 : //草稿箱
sendInfo . Count = StatisTaskPage . DraftsCount
case 3 : //抄送我的
sendInfo . Count = StatisTaskPage . CopyForCount
default : //我的请求
sendInfo . Count = StatisTaskPage . MyCreateCount
}
// if i < 4 {
// sendData = append(sendData, sendInfo)
// }
sendData = append ( sendData , sendInfo )
}
sort . Slice ( sendData , func ( i , j int ) bool {
return sendData [ i ] . Sort < sendData [ j ] . Sort
} )
publicmethod . Result ( 0 , sendData , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 10 - 31 15 : 48 : 44
@ 功能 : 协程处理数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( s * StatisTaskCount ) GetTotalPAge ( appk string , types int ) {
defer syncSeting . Done ( )
// fmt.Printf("s.Types:%v\n", types)
gormDb := overall . CONSTANT_DB_CustomerForm . Model ( & customerForm . RunFlowTask { } ) . Select ( "`id`" ) . Where ( "appKey = ?" , appk )
gormDbEs := overall . CONSTANT_DB_CustomerForm . Model ( & customerForm . TaskRecord { } ) . Select ( "`id`" ) . Where ( "appKey = ?" , appk )
switch types {
case 1 : //待办事宜
gormDb = gormDb . Where ( "`status` = 3 AND FIND_IN_SET(?,`next_executor`)" , s . userCont . Key )
case 2 : //已办事宜
gormDb = gormDb . Where ( "`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?" , s . userCont . Key , s . userCont . Key , s . userCont . Key )
case 5 : //草稿箱
gormDb = gormDb . Where ( "`status` = 1 AND `creater` = ?" , s . userCont . Key )
gormDbEs = gormDbEs . Where ( "`status` = 1 AND `creater` = ?" , s . userCont . Key )
case 3 : //抄送我的
gormDb = gormDb . Where ( "`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)" , s . userCont . Key )
default : //我的请求
// gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", s.userCont.Key)
gormDbEs = gormDbEs . Where ( "`status` IN (1,2,3,4) AND `creater` = ?" , s . userCont . Key )
}
var total int64
var totales int64
gormDb . Count ( & total )
gormDbEs . Count ( & totales )
switch types {
case 1 : //待办事宜
s . ToDoCount = total
case 2 : //已办事宜
s . AlreadyDoneCount = total
case 5 : //草稿箱
s . DraftsCount = totales
case 3 : //抄送我的
s . CopyForCount = total
default : //我的请求
s . MyCreateCount = totales
}
} / * *
@ 作者 : 秦东
@ 时间 : 2024 - 11 - 0 8 13 : 34 : 24
@ 功能 : 根据分组获取App列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetAppList ( 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 list [ ] SendAppInfo
overall . CONSTANT_DB_AppPlatform . Where ( "`classify` = 3 AND `states` = 1 AND `groupid` = ?" , requestData . Id ) . Limit ( 10 ) . Order ( "`creater_time` DESC" ) . Find ( & list )
for i , v := range list {
list [ i ] . SignCodeStr = strconv . FormatInt ( v . SignCode , 10 )
list [ i ] . GroupIdStr = strconv . FormatInt ( v . Groupid , 10 )
list [ i ] . FlowkeyStr = strconv . FormatInt ( v . FlowKey , 10 )
}
publicmethod . Result ( 0 , list , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 11 - 12 13 : 46 : 28
@ 功能 : 获取分组及App
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetGroupAndApp ( c * gin . Context ) {
var appGroup [ ] modelAppPlatform . CustomerFormGroup
overall . CONSTANT_DB_AppPlatform . Where ( "`state` = 1" ) . Find ( & appGroup )
var sendList [ ] SendGroupAppList
if len ( appGroup ) < 1 {
publicmethod . Result ( 0 , sendList , c )
return
}
var xieChengchuli XiechengApp
for _ , v := range appGroup {
syncSeting . Add ( 1 )
go xieChengchuli . GainAppList ( v . Id )
}
syncSeting . Wait ( )
for _ , v := range appGroup {
var sendInfo SendGroupAppList
sendInfo . Id = v . Id //
sendInfo . Title = v . Title //分组名称
sendInfo . Superior = v . Superior //父级
sendInfo . Sort = v . Sort //排序
sendInfo . Ordid = v . Ordid //归属行政组织
sendInfo . State = v . State //显示状态(1:启用;2:禁用,3:删除)
sendInfo . Time = v . Time //创建时间"`
sendInfo . Icon = v . Icon //图标
for _ , vv := range xieChengchuli . Child {
if v . Id == vv . GroupKey {
sendInfo . Child = vv . List
}
}
sendList = append ( sendList , sendInfo )
}
sort . Slice ( sendList , func ( i , j int ) bool {
return sendList [ i ] . Sort < sendList [ j ] . Sort
} )
publicmethod . Result ( 0 , sendList , c )
}
func ( x * XiechengApp ) GainAppList ( id int64 ) {
defer syncSeting . Done ( )
var appList [ ] AppListCont
overall . CONSTANT_DB_AppPlatform . Where ( "`classify` = 3 AND `states` = 1 AND `groupid` = ?" , id ) . Find ( & appList )
if len ( appList ) > 0 {
for i , v := range appList {
appList [ i ] . SignCodeStr = strconv . FormatInt ( v . SignCode , 10 )
}
var childInfo XiechengAppEs
childInfo . GroupKey = id
childInfo . List = appList
// for _,v := range appList {}
x . Child = append ( x . Child , childInfo )
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 11 - 27 0 8 : 41 : 06
@ 功能 : 按菜单顶级分组和表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GainMenuGroupForm ( c * gin . Context ) {
var requestData AppIdType
c . ShouldBindJSON ( & requestData )
if requestData . Id == "" {
publicmethod . Result ( 1021 , requestData , c )
return
}
var topIdAry [ ] modelAppPlatform . Appmenus
gormDb := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . Appmenus { } ) . Select ( "`id`,`label`" ) . Where ( "`state` = 1 AND `type` = 1 AND `isLock` = 2 AND `appkey` = ? AND `parent` = ?" , requestData . Id , requestData . Id )
if requestData . Types == 2 {
gormDb = gormDb . Where ( "`wapIsShow` = ?" , 1 )
} else {
gormDb = gormDb . Where ( "`pcIsShow` = ?" , 1 )
}
err := gormDb . Order ( "`sort` DESC" ) . Find ( & topIdAry ) . Error
if err != nil || len ( topIdAry ) < 1 {
publicmethod . Result ( 10001 , topIdAry , c )
return
}
appKey , _ := strconv . ParseInt ( requestData . Id , 10 , 64 )
var appMenu AppMenuList
for _ , v := range topIdAry {
syncSeting . Add ( 1 )
go appMenu . AppMenuContent ( appKey , v )
}
syncSeting . Wait ( )
var sendData [ ] MenuGroupList
for _ , sv := range appMenu . List {
var sendInfo MenuGroupList
sendInfo . MenuAppId = sv . MenuAppId
sendInfo . MenuAppTitle = sv . MenuAppTitle
sendInfo . List = append ( sendInfo . List , GainTableList ( sv . SunId , requestData . Types ) ... )
sendData = append ( sendData , sendInfo )
}
var otherIdAry [ ] SendAppForm
gormDbOther := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . Appmenus { } ) . Select ( "`id`,`label`" ) . Where ( "`state` = 1 AND `type` = 2 AND `isLock` = 2 AND `appkey` = ? AND `parent` = ?" , requestData . Id , requestData . Id )
if requestData . Types == 2 {
gormDbOther = gormDbOther . Where ( "`wapIsShow` = ?" , 1 )
} else {
gormDbOther = gormDbOther . Where ( "`pcIsShow` = ?" , 1 )
}
gormDbOther . Order ( "`sort` DESC" ) . Find ( & otherIdAry )
if len ( otherIdAry ) > 0 {
for i , v := range otherIdAry {
otherIdAry [ i ] . IdStr = strconv . FormatInt ( v . Id , 10 )
otherIdAry [ i ] . AppkStr = strconv . FormatInt ( v . Appkey , 10 )
otherIdAry [ i ] . ParentStr = strconv . FormatInt ( v . Parent , 10 )
otherIdAry [ i ] . CreaterStr = strconv . FormatInt ( v . Creater , 10 )
var tableFormInfo modelAppPlatform . CustomerFormView
err := tableFormInfo . GetCont ( map [ string ] interface { } { "`status`" : 1 , "`signCode`" : v . Id } , "`id`" , "`cfid`" , "`time`" , "`icon`" , "`listjson`" )
if err == nil {
if tableFormInfo . ListJson != "" {
otherIdAry [ i ] . IsList = true
} else {
otherIdAry [ i ] . IsList = false
}
otherIdAry [ i ] . VersionId = strconv . FormatInt ( tableFormInfo . Id , 10 )
otherIdAry [ i ] . TableId = strconv . FormatInt ( tableFormInfo . CfId , 10 )
var usInfo modelshr . PersonArchives //获取创建人
usInfo . GetCont ( map [ string ] interface { } { "`key`" : v . Creater } , "`name`" , "`number`" )
otherIdAry [ i ] . Founder = fmt . Sprintf ( "%v(%v)" , usInfo . Name , usInfo . Number )
otherIdAry [ i ] . CreateDate = publicmethod . UnixTimeToDay ( tableFormInfo . CreaterTime , 14 )
otherIdAry [ i ] . Icon = tableFormInfo . Icon
}
}
var sendInfo MenuGroupList
sendInfo . MenuAppId = requestData . Id
sendInfo . MenuAppTitle = "默认分组"
sendInfo . List = append ( sendInfo . List , otherIdAry ... )
sendData = append ( sendData , sendInfo )
}
publicmethod . Result ( 0 , sendData , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 11 - 27 10 : 22 : 16
@ 功能 : 获取操作表
* /
func GainTableList ( parent [ ] int64 , types int ) [ ] SendAppForm {
var appMenusList [ ] SendAppForm
gormDb := overall . CONSTANT_DB_AppPlatform . Model ( & modelAppPlatform . Appmenus { } ) . Where ( "`state` = 1 AND `type` = 2 AND `isLock` = 2 AND `parent` IN ?" , parent )
if types == 2 {
gormDb = gormDb . Where ( "`wapIsShow` = ?" , 1 )
} else {
gormDb = gormDb . Where ( "`pcIsShow` = ?" , 1 )
}
gormDb . Order ( "`sort` DESC" ) . Find ( & appMenusList )
for i , v := range appMenusList {
appMenusList [ i ] . IdStr = strconv . FormatInt ( v . Id , 10 )
appMenusList [ i ] . AppkStr = strconv . FormatInt ( v . Appkey , 10 )
appMenusList [ i ] . ParentStr = strconv . FormatInt ( v . Parent , 10 )
appMenusList [ i ] . CreaterStr = strconv . FormatInt ( v . Creater , 10 )
var tableFormInfo modelAppPlatform . CustomerFormView
err := tableFormInfo . GetCont ( map [ string ] interface { } { "`status`" : 1 , "`signCode`" : v . Id } , "`id`" , "`cfid`" , "`time`" , "`icon`" , "`listjson`" )
if err == nil {
if tableFormInfo . ListJson != "" {
appMenusList [ i ] . IsList = true
} else {
appMenusList [ i ] . IsList = false
}
appMenusList [ i ] . VersionId = strconv . FormatInt ( tableFormInfo . Id , 10 )
appMenusList [ i ] . TableId = strconv . FormatInt ( tableFormInfo . CfId , 10 )
var usInfo modelshr . PersonArchives //获取创建人
usInfo . GetCont ( map [ string ] interface { } { "`key`" : v . Creater } , "`name`" , "`number`" )
appMenusList [ i ] . Founder = fmt . Sprintf ( "%v(%v)" , usInfo . Name , usInfo . Number )
appMenusList [ i ] . CreateDate = publicmethod . UnixTimeToDay ( tableFormInfo . CreaterTime , 14 )
appMenusList [ i ] . Icon = tableFormInfo . Icon
}
}
return appMenusList
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 11 - 27 0 9 : 27 : 51
@ 功能 : 获取所有子类
* /
func ( a * AppMenuList ) AppMenuContent ( appKey int64 , menuInfo modelAppPlatform . Appmenus ) {
defer syncSeting . Done ( )
var menuCont AppMenuListInfo
menuCont . MenuAppId = strconv . FormatInt ( menuInfo . Id , 10 )
menuCont . MenuAppTitle = menuInfo . Label
var menuSun publicmethod . GetOrgAllParent
menuSun . GetAppMenuSun ( appKey , menuInfo . Id )
menuCont . SunId = append ( menuCont . SunId , menuInfo . Id )
menuCont . SunId = append ( menuCont . SunId , menuSun . Id ... )
a . List = append ( a . List , menuCont )
fmt . Printf ( "获取所有子类:%v\n" , a )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2025 - 01 - 03 14 : 42 : 36
@ 功能 : 获取有源数据表字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GainDataStorceAllField ( c * gin . Context ) {
var requestData DatabaseConfig
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . SqlType == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . Name == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . TableName == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . Host == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . Port == 0 {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . User == "" {
publicmethod . Result ( 200 , err , c )
return
}
if requestData . Password == "" {
publicmethod . Result ( 200 , err , c )
return
}
var sqlDb datacenter . DataBastType
sqlDb . Type = requestData . SqlType
sqlDb . Ip = requestData . Host
sqlDb . DataBaseName = requestData . Name
sqlDb . Port = requestData . Port
sqlDb . UserName = requestData . User
sqlDb . Pwd = requestData . Password
sqlDborm , err := sqlDb . StartDataBast ( )
if err != nil {
sqlDborm , err = datacenter . GainDataStorce ( requestData . Id )
if err != nil {
publicmethod . Result ( 0 , sqlDb , c )
return
}
}
fieldList , err := customerform . GainFormAllField ( sqlDborm , requestData . TableName )
if err != nil {
publicmethod . Result ( 0 , err , c )
return
}
publicmethod . Result ( 0 , fieldList , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2025 - 02 - 18 0 9 : 42 : 49
@ 功能 : 获取所有自定义App
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GaveAllApp ( c * gin . Context ) {
var list [ ] modelAppPlatform . CustomerForm
overall . CONSTANT_DB_AppPlatform . Where ( "`classify` = 3 AND `states` = 1" ) . Find ( & list )
var sendData [ ] DiaobanTable
if len ( list ) > 0 {
for _ , v := range list {
var sendInfo DiaobanTable
sendInfo . AppId = strconv . FormatInt ( v . Id , 10 )
sendInfo . AppName = v . Name
sendInfo . List = GetAppForm ( v . SignCode , 2 )
sendInfo . SignCode = strconv . FormatInt ( v . SignCode , 10 )
sendData = append ( sendData , sendInfo )
}
}
publicmethod . Result ( 0 , sendData , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2025 - 02 - 18 10 : 20 : 51
@ 功能 : 获取流程表单
* /
func GetAppForm ( appId int64 , types int ) ( tableForm [ ] TableInfo ) {
var formVersion [ ] modelAppPlatform . CustomerFormView
overall . CONSTANT_DB_AppPlatform . Where ( "`classify` = ? AND `states` = 1 AND `groupid` = ?" , types , appId ) . Find ( & formVersion )
for _ , v := range formVersion {
if v . MastesFormJson != "" {
var formJsonCont customerform . CustomerFormMaster
json . Unmarshal ( [ ] byte ( v . MastesFormJson ) , & formJsonCont )
var tableFormInfo TableInfo
tableFormInfo . SqlType = formJsonCont . Form . DataSourceConfig . DSN . SqlType
tableFormInfo . Ip = formJsonCont . Form . DataSourceConfig . DSN . Ip
tableFormInfo . DataBaseName = formJsonCont . Form . DataSourceConfig . DSN . DataBaseName
tableFormInfo . Port = formJsonCont . Form . DataSourceConfig . DSN . Port
tableFormInfo . UserName = formJsonCont . Form . DataSourceConfig . DSN . UserName
tableFormInfo . Password = formJsonCont . Form . DataSourceConfig . DSN . Password
tableFormInfo . DataSource = formJsonCont . Form . DataSource //是不是引用外部数据源
tableFormInfo . TableName = v . Name //数据表名称
tableFormInfo . TableKey = strconv . FormatInt ( v . SignCode , 10 )
tableFormInfo . SourceId = formJsonCont . Form . DataSourceConfig . Id
tableForm = append ( tableForm , tableFormInfo )
}
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2025 - 02 - 18 13 : 28 : 32
@ 功能 : 获取已经设定好的参数
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GinTeamRule ( c * gin . Context ) {
var dbSetupInfo customerForm . DiaoBanSetup
overall . CONSTANT_DB_AppPlatform . First ( & dbSetupInfo )
publicmethod . Result ( 0 , dbSetupInfo , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2025 - 02 - 18 13 : 52 : 46
@ 功能 : 设定取值
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) SetupRulerForm ( c * gin . Context ) {
var requestData TableFormDnsConfig
c . ShouldBindJSON ( & requestData )
overall . CONSTANT_DB_AppPlatform . Exec ( "TRUNCATE diaoBanSetup" )
var diaoIno customerForm . DiaoBanSetup
diaoIno . Appid , _ = strconv . ParseInt ( requestData . AppId , 10 , 64 ) //归属哪个app"`
diaoIno . Source = requestData . DataSource //是否引用数据源(yes ; no)"`
diaoIno . Ip = requestData . Ip //数据源地址"`
diaoIno . DataBaseName = requestData . DataBaseName //是否引用数据源(yes ; no)"`
diaoIno . SqlType = requestData . SqlType //数据库类型"`:数据表名称"`
diaoIno . UserName = requestData . UserName //';comment:数据库用户名"`
diaoIno . Pwd = requestData . Password //数据库密码"`
diaoIno . Time = time . Now ( ) . Unix ( ) //not null;comment:创建时间"`
diaoIno . TableKey = requestData . TableKey
diaoIno . TableNames = requestData . TableName
diaoIno . SourceId = requestData . SourceId
diaoIno . Port = requestData . Port
overall . CONSTANT_DB_AppPlatform . Create ( & diaoIno )
publicmethod . Result ( 0 , requestData , c )
}