35 changed files with 5429 additions and 106 deletions
File diff suppressed because it is too large
@ -0,0 +1,226 @@ |
|||
package customerApp |
|||
|
|||
import ( |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"strconv" |
|||
"strings" |
|||
|
|||
"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 08: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 08: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 08: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 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
package customerApp |
|||
|
|||
import ( |
|||
"appPlatform/api/version1/publicapi" |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/overall/publicmethod" |
|||
"sync" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
// 协程设置
|
|||
var syncSeting = sync.WaitGroup{} |
|||
|
|||
type ApiMethod struct{} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-04-23 10:09:05 |
|||
@ 功能: 自定义App入口 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "自定义App入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-04-23 13:40:21 |
|||
@ 功能: App菜单树 |
|||
*/ |
|||
type AppMenuTree struct { |
|||
Id string `json:"id"` |
|||
Label string `json:"label"` |
|||
Types int `json:"type"` |
|||
Svg string `json:"svg" ` |
|||
PcIsShow int `json:"pcIsShow"` |
|||
WapIsShow int `json:"wapIsShow"` |
|||
Parent string `json:"parent"` |
|||
Appkey string `json:"appkey"` |
|||
IsLock int `json:"isLock"` |
|||
Sort int64 `json:"sort"` |
|||
State int `json:"state"` |
|||
IsMain int `json:"isMain"` |
|||
Children []AppMenuTree `json:"children"` |
|||
} |
|||
|
|||
// app菜单参数
|
|||
type AppMenuInfo struct { |
|||
publicmethod.PublicName |
|||
Appkey string `json:"appkey"` |
|||
Types int `json:"type"` |
|||
Group string `json:"group"` |
|||
} |
|||
|
|||
// 接收菜单树'=
|
|||
type AppMenuTreeSave struct { |
|||
publicmethod.PublicId |
|||
MenuTree []AppMenuTree `json:"menuTree"` |
|||
} |
|||
|
|||
// 修改名称
|
|||
type EditAppMenuNAme struct { |
|||
Id string `json:"id"` |
|||
Label string `json:"label"` |
|||
} |
|||
|
|||
// 循环菜单树
|
|||
type XunhuanMenuTree struct { |
|||
MenuTree []AppMenuTree `json:"menuTree"` |
|||
} |
|||
|
|||
// 显示和隐藏App菜单项
|
|||
type HideOrShowAppMenu struct { |
|||
Types int `json:"types"` |
|||
MenuInfo AppMenuTree `json:"menuInfo"` |
|||
} |
|||
|
|||
// App表单通用参数
|
|||
type AppFormPageInfo struct { |
|||
Types int `json:"type"` // 1表单 2列表 3:app 4:app表单
|
|||
Name string `json:"name"` // 表单名称,用于在显示所有已创建的表单列表里显示
|
|||
Source string `json:"source"` // 数据源允许在表单属性设置里修改的
|
|||
Dict string `json:"dict"` //表单校正参数
|
|||
Data string `json:"data"` //表单数据
|
|||
JsonData string `json:"jsondata"` //json化表单数据
|
|||
Classify int `json:"classify"` //分类1:表单;2:流程表单" 3:应用
|
|||
} |
|||
|
|||
// 添加App表单接收参数
|
|||
type AddAppFormPageInfo struct { |
|||
AppKey string `json:"appKey"` //app标识符
|
|||
GroupKey string `json:"groupKey"` //归属分组
|
|||
MenuId string `json:"menuId"` //归属菜单
|
|||
SignCode string `json:"appSignCode"` //表单唯一识别符号
|
|||
AppFormPageInfo |
|||
} |
|||
|
|||
// 编辑App表单接收参数
|
|||
type EditAppFormPageInfo struct { |
|||
Id string `json:"id"` //App表单ID
|
|||
Version string `json:"version"` //app表单版本Id
|
|||
AppKey string `json:"appKey"` //app标识符
|
|||
GroupKey string `json:"groupKey"` //归属分组
|
|||
MenuId string `json:"menuId"` //归属菜单
|
|||
SignCode string `json:"signCode"` //表单唯一识别符号
|
|||
AppFormPageInfo |
|||
} |
|||
type LookCustomerFormInfo struct { |
|||
modelAppPlatform.CustomerFormView |
|||
States int `json:"states" gorm:"-"` |
|||
GroupKey string `json:"groupKey" gorm:"-"` |
|||
PermitList [][]int64 `json:"permit_list" gorm:"-"` |
|||
FormField []string `json:"formField" gorm:"-"` |
|||
} |
|||
|
|||
// app基础设置参数
|
|||
type AppSetupInfo struct { |
|||
publicmethod.PublicId |
|||
Title string `json:"title"` |
|||
GroupKey string `json:"groupKey"` |
|||
AppSvg string `json:"appSvg"` |
|||
Appdescribe string `json:"appdescribe"` |
|||
} |
|||
|
|||
// 设置可见人员
|
|||
type SetAppLookViews struct { |
|||
publicmethod.PublicId |
|||
OrgRoleUs []publicapi.UserOrgRole `json:"orgRoleUs"` |
|||
} |
|||
|
|||
// app管理员这只是称呼
|
|||
type AppAdminKey struct { |
|||
Key []string `json:"key"` |
|||
} |
|||
|
|||
// 返回管理人员
|
|||
type CallBackAppOrgRoleUs struct { |
|||
AppOrgMan []publicapi.UserOrgRole `json:"orgRoleUs"` //应用管理行政组织
|
|||
AppRoleManager []publicapi.UserOrgRole `json:"appRoleManager"` //应用管理角色
|
|||
AppManager []publicapi.UserOrgRole `json:"appManager"` //应用管理员
|
|||
OrgPermit []publicapi.UserOrgRole `json:"orgPermit"` //授权范围可见行政组织
|
|||
PostPermit []publicapi.UserOrgRole `json:"postPermit"` //授权范围可见角色
|
|||
UserPermit []publicapi.UserOrgRole `json:"userPermit"` //授权范围可见人员
|
|||
} |
|||
|
|||
// 搜索应用下得表单
|
|||
type SearchAppTable struct { |
|||
publicmethod.PublicId |
|||
publicmethod.PublicName |
|||
publicmethod.PagesTurn |
|||
} |
|||
|
|||
// Jwt鉴权
|
|||
type JwtPower struct { |
|||
publicmethod.PublicId |
|||
Types int `json:"types"` //1:可见范围;2:操作权限
|
|||
} |
|||
|
|||
// 三方鉴权
|
|||
type TreeJwtPower struct { |
|||
Role bool |
|||
Org bool |
|||
People bool |
|||
} |
|||
@ -0,0 +1,819 @@ |
|||
package customerform |
|||
|
|||
import ( |
|||
"appPlatform/models/customerForm" |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"strconv" |
|||
"strings" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-08 15:41:37 |
|||
@ 功能: 多视图数据处理 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) MultiViewPAge(c *gin.Context) { |
|||
var requestData ViewListSearch |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.FormId == "" { |
|||
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!2") |
|||
return |
|||
} |
|||
if requestData.Page == 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.Page = 20 |
|||
} |
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
var formInfo modelAppPlatform.CustomerFormView |
|||
err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`") |
|||
if err != nil { |
|||
publicmethod.Result(1, err, c, "未知表单!无法获取字段!") |
|||
return |
|||
} |
|||
var formList []map[string]interface{} |
|||
sendListInfo := publicmethod.MapOut[string]() |
|||
var sendTimeList []interface{} |
|||
tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey) |
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId") |
|||
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key") |
|||
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key) |
|||
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) |
|||
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
switch requestData.ViewClass.Class { |
|||
case "date": |
|||
gormDb = gormDb.Order("`id` DESC") |
|||
case "time": |
|||
if requestData.ViewClass.SortWord != "" { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord)) |
|||
} else { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord)) |
|||
} |
|||
} else { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order("`id` DESC") |
|||
} else { |
|||
gormDb = gormDb.Order("`id` ASC") |
|||
} |
|||
} |
|||
case "gantt": |
|||
if requestData.ViewClass.SortWord != "" { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord)) |
|||
} else { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord)) |
|||
} |
|||
} else { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order("`id` DESC") |
|||
} else { |
|||
gormDb = gormDb.Order("`id` ASC") |
|||
} |
|||
} |
|||
case "map": |
|||
if requestData.ViewClass.SortWord != "" { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord)) |
|||
} else { |
|||
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord)) |
|||
} |
|||
} else { |
|||
if requestData.ViewClass.Sort == 1 { |
|||
gormDb = gormDb.Order("`id` DESC") |
|||
} else { |
|||
gormDb = gormDb.Order("`id` ASC") |
|||
} |
|||
} |
|||
default: |
|||
gormDb = gormDb.Order("`id` DESC") |
|||
} |
|||
err = gormDb.Find(&formList).Error |
|||
if err != nil && len(formList) < 1 { |
|||
publicmethod.Result(0, err, c) |
|||
return |
|||
} |
|||
// pageMyTola := len()
|
|||
// fmt.Printf("列表数据解析---1->%v\n", formInfo.ListJson)
|
|||
|
|||
//获取任务状态
|
|||
for i, v := range formList { |
|||
formList[i]["isRetract"] = false |
|||
if mastrKey, ok := v["runFlowId"]; ok { |
|||
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
|
|||
var runFlowInfo customerForm.RunWorkflow |
|||
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`") |
|||
formList[i]["runFlowInfo"] = strconv.FormatInt(runFlowInfo.Id, 10) |
|||
formList[i]["runFlowId"] = strconv.FormatInt(runFlowInfo.Id, 10) |
|||
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
|
|||
if stateVal, ok := v["taskStatus"]; ok { |
|||
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
|
|||
if stauval, ok := stateVal.(string); ok { |
|||
if stauval == "3" && runFlowInfo.NextStep != 0 { |
|||
|
|||
if runFlowInfo.CurrentStep == 1 { |
|||
if createrName, ok := formList[i]["creater"].(string); ok { |
|||
if createrName == userCont.Name { |
|||
formList[i]["isRetract"] = true |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
if mastrKeyVal, ok := v["masters_key"]; ok { |
|||
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
|
|||
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok { |
|||
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10) |
|||
} |
|||
} |
|||
} |
|||
|
|||
if requestData.OlaData != "" { |
|||
var oldDataAry interface{} |
|||
err = json.Unmarshal([]byte(requestData.OlaData), &oldDataAry) |
|||
if err == nil { |
|||
if oldVal, ok := oldDataAry.([]interface{}); ok { |
|||
var oldList []map[string]interface{} |
|||
for _, v := range oldVal { |
|||
if mv, mvOk := v.(map[string]interface{}); mvOk { |
|||
if mvla, isOk := mv["class_type$unit"]; isOk { |
|||
timeInt, _ := publicmethod.StringToInt64(mvla) |
|||
if timeInt != 1 { |
|||
oldInfo := publicmethod.MapOut[string]() |
|||
for key, val := range mv { |
|||
if key != "class_type$unit" { |
|||
oldInfo[key] = val |
|||
} |
|||
if key == "creater_time" { |
|||
// creTime, _ := publicmethod.StringToInt64(mvla)
|
|||
// oldInfo[key] =
|
|||
if sVal, isTrue := val.(string); isTrue { |
|||
var creTimeAll publicmethod.DateTimeTotimes |
|||
creTimeAll.BaisStrToTime(sVal) |
|||
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime) |
|||
oldInfo[key] = creTime |
|||
} |
|||
// fmt.Printf("formList----> %T----> %v\n", val, val)
|
|||
} |
|||
if key == "edit_time" { |
|||
if sVal, isTrue := val.(string); isTrue { |
|||
var creTimeAll publicmethod.DateTimeTotimes |
|||
creTimeAll.BaisStrToTime(sVal) |
|||
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime) |
|||
oldInfo[key] = creTime |
|||
} |
|||
} |
|||
} |
|||
oldList = append(oldList, oldInfo) |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
// fmt.Printf("mvla----> %T----> %v\n", oldList, oldList)
|
|||
if len(oldList) > 0 { |
|||
oldList = append(oldList, formList...) |
|||
formList = oldList |
|||
} |
|||
} |
|||
} |
|||
} |
|||
// fmt.Printf("formList----> %v----> %v\n", len(formList), formList)
|
|||
if formInfo.ListJson != "" { |
|||
var listFieldsMap ListPageFields |
|||
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) |
|||
// fmt.Printf("列表数据解析---->%v\n", err)
|
|||
if err == nil { |
|||
lik, formListAry, dayAry := listFieldsMap.TimeViewWordHandle(formList, requestData.ViewClass) |
|||
// timeAry := publicmethod.MapOut[string]()
|
|||
sendListInfo["listInfo"] = formListAry |
|||
sendListInfo["dayList"] = dayAry |
|||
sendListInfo["lik"] = lik |
|||
for _, lv := range lik { |
|||
if len(lv.List) > 0 { |
|||
for _, lvlv := range lv.List { |
|||
sendTimeList = append(sendTimeList, lvlv) |
|||
} |
|||
// sendTimeList = append(sendTimeList, lv)
|
|||
} |
|||
} |
|||
|
|||
// formList = appenlikd(formList, timeAry)
|
|||
} |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), sendTimeList, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-09 08:57:05 |
|||
@ 功能: 时间轴视图数据输出 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, viewCalss ViewKeyType) ([]TimeFenGe, []map[string]interface{}, []string) { |
|||
|
|||
// fmt.Printf("TimeViewWordHandle:%v------------>%v\n", len(listData), listData)
|
|||
|
|||
var sendList []map[string]interface{} |
|||
var dayAry []string |
|||
var lik []TimeFenGe |
|||
switch viewCalss.Class { |
|||
case "date": |
|||
|
|||
case "time": |
|||
_, _, listTime := l.GainStartOrEndTime(listData, viewCalss) |
|||
lik = listTime |
|||
// startTime := int64(0)
|
|||
// endTime := int64(0)
|
|||
// sendInfo := publicmethod.MapOut[string]()
|
|||
// for _, lv := range listData {
|
|||
|
|||
// for mi, mv := range lv {
|
|||
// if mi == viewCalss.SortWord {
|
|||
// mvInt, _ := publicmethod.StringToInt64(mv)
|
|||
// if startTime == 0 && endTime == 0 {
|
|||
// startTime = mvInt
|
|||
// endTime = mvInt
|
|||
// } else {
|
|||
// if startTime <= mvInt {
|
|||
// startTime = mvInt
|
|||
// }
|
|||
// if endTime >= mvInt {
|
|||
// endTime = mvInt
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
|
|||
// }
|
|||
// jsondd, _ := json.Marshal(listTime)
|
|||
// fmt.Printf("猎头结果:%v================%v================%v\n", len(listTime), string(jsondd), listTime)
|
|||
for _, v := range listTime { |
|||
if len(v.List) > 0 { |
|||
info := publicmethod.MapOut[string]() |
|||
info[v.DateTime] = v.List |
|||
sendList = append(sendList, info) |
|||
dayAry = append(dayAry, v.DateTime) |
|||
// for _, lv := range v.List {
|
|||
// sendList = append(sendList, lv)
|
|||
// }
|
|||
} |
|||
} |
|||
// sendList = listTime
|
|||
case "gantt": |
|||
|
|||
case "map": |
|||
|
|||
default: |
|||
sendList = l.DevelopSpecificationsSend(listData) |
|||
} |
|||
// fmt.Printf("获取起止时间--->%v---->%v\n", len(lik), lik)
|
|||
return lik, sendList, dayAry |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-09 10:14:44 |
|||
@ 功能: 获取起止时间 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (l *ListPageFields) GainStartOrEndTime(listData []map[string]interface{}, viewCalss ViewKeyType) (startTime, endTime int64, sendTime []TimeFenGe) { |
|||
for _, lv := range listData { |
|||
for mi, mv := range lv { |
|||
if mi == viewCalss.SortWord { |
|||
mvInt, _ := publicmethod.StringToInt64(mv) |
|||
if startTime == 0 && endTime == 0 { |
|||
startTime = mvInt |
|||
endTime = mvInt |
|||
} else { |
|||
if startTime <= mvInt { |
|||
startTime = mvInt |
|||
} |
|||
if endTime >= mvInt { |
|||
endTime = mvInt |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
tianShu, _ := publicmethod.DayBetweenDate(publicmethod.UnixTimeToDay(startTime, 14), publicmethod.UnixTimeToDay(endTime, 14)) |
|||
fmt.Printf("天数: %v\n", tianShu) |
|||
if viewCalss.Sort == 1 { |
|||
beginTime := publicmethod.TimeUnixToTime(startTime, "s") |
|||
for i := 0; i <= tianShu; i++ { |
|||
yesterday := beginTime.AddDate(0, 0, -i) |
|||
var timeInfo TimeFenGe |
|||
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14) |
|||
timeInfo.DateTime = riqi |
|||
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi) |
|||
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18) |
|||
timeInfo.Stor = i |
|||
timeInfo.TimeUnix = yesterday.Unix() |
|||
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix()) |
|||
timeInfo.StartAndEnd.Start = begin |
|||
timeInfo.StartAndEnd.End = end |
|||
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData) |
|||
if len(listAry) > 0 { |
|||
gd := make(map[string]interface{}) |
|||
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40) |
|||
gd["weekDay"], _ = publicmethod.GetWeekday(riqi) |
|||
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18) |
|||
gd["class_type$unit"] = 1 |
|||
timeInfo.List = append(timeInfo.List, gd) |
|||
timeInfo.List = append(timeInfo.List, listAry...) |
|||
} else { |
|||
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData) |
|||
} |
|||
|
|||
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
|
|||
sendTime = append(sendTime, timeInfo) |
|||
} |
|||
} else { |
|||
beginTime := publicmethod.TimeUnixToTime(endTime, "s") |
|||
for i := 0; i <= tianShu; i++ { |
|||
yesterday := beginTime.AddDate(0, 0, -i) |
|||
var timeInfo TimeFenGe |
|||
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14) |
|||
timeInfo.DateTime = riqi |
|||
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi) |
|||
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18) |
|||
timeInfo.Stor = i |
|||
timeInfo.TimeUnix = yesterday.Unix() |
|||
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix()) |
|||
timeInfo.StartAndEnd.Start = begin |
|||
timeInfo.StartAndEnd.End = end |
|||
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData) |
|||
if len(listAry) > 0 { |
|||
gd := make(map[string]interface{}) |
|||
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40) |
|||
gd["weekDay"], _ = publicmethod.GetWeekday(riqi) |
|||
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18) |
|||
gd["class_type$unit"] = 1 |
|||
timeInfo.List = append(timeInfo.List, gd) |
|||
timeInfo.List = append(timeInfo.List, listAry...) |
|||
} else { |
|||
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData) |
|||
} |
|||
|
|||
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
|
|||
sendTime = append(sendTime, timeInfo) |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-09 11:39:52 |
|||
@ 功能: 打包数据 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (l *ListPageFields) DaBaoShuJu(sortWord string, startTime, endTime int64, listData []map[string]interface{}) (sendData []interface{}) { |
|||
// fmt.Printf("打包--->%v\n", sortWord)
|
|||
sc := make([]interface{}, 0) |
|||
for _, v := range listData { |
|||
if mv, ok := v[sortWord]; ok { |
|||
// fmt.Printf("打包--1->%v->%T\n", mv, mv)
|
|||
idInt, _ := publicmethod.StringToInt64(mv) |
|||
// fmt.Printf("打包--1->%v->%T->%v->%T\n", mv, mv, idInt, idInt)
|
|||
if idInt >= startTime && idInt <= endTime { |
|||
v[sortWord] = publicmethod.UnixTimeToDay(idInt, 11) |
|||
v["class_type$unit"] = 2 |
|||
for mi, mv := range v { |
|||
switch mi { |
|||
case "creater": |
|||
if sortWord != "creater" { |
|||
var myInfo modelshr.PersonArchives |
|||
myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`") |
|||
v[mi] = myInfo.Name |
|||
} |
|||
|
|||
case "creater_time": |
|||
if sortWord != "creater_time" { |
|||
timeInt, _ := publicmethod.StringToInt64(mv) |
|||
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11) |
|||
} |
|||
case "edit_time": |
|||
if sortWord != "edit_time" { |
|||
timeInt, _ := publicmethod.StringToInt64(mv) |
|||
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11) |
|||
} |
|||
default: |
|||
_, v[mi] = l.BaseTableAttrViewField(mi, mv) |
|||
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
|
|||
} |
|||
|
|||
} |
|||
sc = append(sc, v) |
|||
// sendData = append(sendData, sc)
|
|||
} |
|||
} |
|||
} |
|||
if len(sc) > 0 { |
|||
// sendVal := publicmethod.MapOut[string]()
|
|||
// sendVal[riqi] = sc
|
|||
sendData = sc |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-04-02 08:14:10 |
|||
@ 功能: 按照制定列表字段输出(视图) |
|||
*/ |
|||
func (l *ListPageFields) DevelopSpecificViewSend(listData []map[string]interface{}) []map[string]interface{} { |
|||
var sendList []map[string]interface{} |
|||
for _, v := range listData { |
|||
sendInfo := publicmethod.MapOut[string]() |
|||
for mi, mv := range v { |
|||
fmt.Printf("%v = %v\n", mi, mv) |
|||
// switch mi {
|
|||
// case "creater":
|
|||
// var myInfo modelshr.PersonArchives
|
|||
// myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`")
|
|||
// sendInfo["创建人"] = myInfo.Name
|
|||
// case "creater_time":
|
|||
// timeInt, _ := publicmethod.StringToInt64(mv)
|
|||
// sendInfo["创建时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|||
// case "edit_time":
|
|||
// timeInt, _ := publicmethod.StringToInt64(mv)
|
|||
// sendInfo["编辑时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|||
// case "id":
|
|||
// if idInt, ok := mv.(int64); ok {
|
|||
// sendInfo["Id"] = strconv.FormatInt(idInt, 10)
|
|||
// }
|
|||
// idInt, _ := publicmethod.StringToInt64(mv)
|
|||
// sendInfo["Id"] = idInt
|
|||
// default:
|
|||
// // sendInfo[mi] = l.BaseTableAttrField(mi, mv)
|
|||
// key, val := l.BaseTableAttrViewField(mi, mv)
|
|||
// if key != "" {
|
|||
// sendInfo[key] = val
|
|||
// }
|
|||
|
|||
// // sendInfo[mi] = publicmethod.TypeToInterface(mv)
|
|||
// }
|
|||
key, val := l.BaseTableAttrViewField(mi, mv) |
|||
if key != "" { |
|||
sendInfo[key] = val |
|||
} |
|||
} |
|||
// fmt.Printf("================================\n")
|
|||
sendList = append(sendList, sendInfo) |
|||
} |
|||
return sendList |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-04-02 11:42:20 |
|||
@ 功能: 根据字段显示格式处理数据(字段) |
|||
*/ |
|||
func (l *ListPageFields) BaseTableAttrViewField(key string, val interface{}) (string, interface{}) { |
|||
// fmt.Printf("根据字段显示格式处理数据(字段):%v==1==>%v\n", key, len(l.TableData.Columns))
|
|||
if len(l.TableData.Columns) < 0 { |
|||
return "", val |
|||
} |
|||
keyStr := "" |
|||
for _, v := range l.TableData.Columns { |
|||
// fmt.Printf("根据字段显示格式处理数据(字段):%v====>%v\n", key, v.Id)
|
|||
if v.Id == key { |
|||
// fmt.Printf("根据字段显示格式处理数据(字段):%v\n", v.Label)
|
|||
switch v.FieldClass { |
|||
case "checkbox": |
|||
if val != nil { |
|||
var checkboxStrAry []interface{} |
|||
var checkboxAry []string |
|||
if valStr, ok := val.(string); ok { |
|||
err := json.Unmarshal([]byte(valStr), &checkboxStrAry) |
|||
if err == nil { |
|||
for _, v := range checkboxStrAry { |
|||
checkboxAry = append(checkboxAry, publicmethod.TypeToInterface(v)) |
|||
} |
|||
} |
|||
} |
|||
|
|||
if len(checkboxAry) > 0 { |
|||
var jieGuo []string |
|||
for _, ov := range v.Options { |
|||
if publicmethod.IsInTrue[string](ov.Value, checkboxAry) { |
|||
jieGuo = append(jieGuo, ov.Label) |
|||
} |
|||
} |
|||
val = strings.Join(jieGuo, ",") |
|||
} |
|||
} |
|||
case "orgCentent": |
|||
var orgCont modelshr.AdministrativeOrganization |
|||
orgCont.GetCont(map[string]interface{}{"`id`": val}, "name") |
|||
return v.Label, orgCont.Name |
|||
case "baidumap": |
|||
var mapAry []string |
|||
if valStr, ok := val.(string); ok { |
|||
mapAry = strings.Split(valStr, "|*@*|") |
|||
} |
|||
if len(mapAry) > 0 { |
|||
return v.Label, mapAry[0] |
|||
} |
|||
default: |
|||
return v.Label, publicmethod.TypeToInterface(val) |
|||
} |
|||
} |
|||
} |
|||
return keyStr, val |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-16 14:02:42 |
|||
@ 功能: 根据日期获取数据 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) GainCalendarList(c *gin.Context) { |
|||
var requestData CalendarSearch |
|||
c.ShouldBindJSON(&requestData) |
|||
|
|||
if len(requestData.TimeAry) < 1 && len(requestData.TimeMonthAry) < 1 { |
|||
publicmethod.Result(1, requestData, c, "未知日期!无法获取字段!2") |
|||
return |
|||
} |
|||
if requestData.Search.FormId == "" { |
|||
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!") |
|||
return |
|||
} |
|||
if requestData.Search.Page == 0 { |
|||
requestData.Search.Page = 1 |
|||
} |
|||
if requestData.Search.PageSize == 0 { |
|||
requestData.Search.Page = 20 |
|||
} |
|||
|
|||
var listField []SearchButtonInfo |
|||
json.Unmarshal([]byte(requestData.Search.SearchData), &listField) |
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
|
|||
var formInfo modelAppPlatform.CustomerFormView |
|||
err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.Search.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`") |
|||
if err != nil { |
|||
publicmethod.Result(1, err, c, "未知表单!无法获取字段!") |
|||
return |
|||
} |
|||
var listFieldsMap ListPageFields |
|||
json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) |
|||
|
|||
if requestData.Types != 1 { |
|||
var listSynv CalendarList |
|||
for _, v := range requestData.TimeAry { |
|||
syncSeting.Add(1) |
|||
go listSynv.GetDayCont(v, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson) |
|||
} |
|||
syncSeting.Wait() |
|||
sendListArt := TimeHaveAry(requestData.TimeAry, listSynv.List) |
|||
if len(sendListArt) == 1 { |
|||
var onInfo TimeAryInfo |
|||
for _, v := range sendListArt { |
|||
onInfo = v |
|||
} |
|||
publicmethod.Result(0, onInfo, c) |
|||
return |
|||
} |
|||
publicmethod.Result(0, sendListArt, c) |
|||
} else { |
|||
var sendMonthList []interface{} |
|||
for _, v := range requestData.TimeMonthAry { |
|||
var listSynv CalendarList |
|||
for _, tv := range v { |
|||
syncSeting.Add(1) |
|||
go listSynv.GetDayCont(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson) |
|||
} |
|||
syncSeting.Wait() |
|||
// sendListArt := TimeHaveAry(v, listSynv.List)
|
|||
// fmt.Printf("每段结构---->%v\n=================================\n", sendListArt)
|
|||
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) |
|||
} |
|||
|
|||
publicmethod.Result(0, sendMonthList, c) |
|||
} |
|||
|
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-17 08:55:56 |
|||
@ 功能: 结果与日期合并 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func TimeHaveAry(dateList []TimeAryInfo, listDate []map[string]interface{}) []TimeAryInfo { |
|||
for ti, tv := range dateList { |
|||
fmt.Printf("测试类型--->%v=============>%v\n", ti, tv) |
|||
for _, v := range listDate { |
|||
for mi, mv := range v { |
|||
if tv.Date == mi { |
|||
dateList[ti].List = mv |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return dateList |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-16 14:09:26 |
|||
@ 功能: 按天获取数据 |
|||
@ 参数 |
|||
|
|||
#day 日历单个日期参数 |
|||
#tableName 要操作得数据表 |
|||
#userCont 当前操作人 |
|||
#Search 搜索条件 |
|||
#listField 自定义表单查询条件 |
|||
#viewCondition 视图设定 |
|||
#listJson 字段处理 |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string) { |
|||
defer syncSeting.Done() |
|||
|
|||
tableName = fmt.Sprintf("`%v` as f", tableName) |
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId") |
|||
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key") |
|||
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key) |
|||
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) |
|||
gormDb = AnalysisSerachTermSqlIng(listField, gormDb) |
|||
|
|||
if class, isOk := viewCondition["date"]; isOk { |
|||
if class.Status { |
|||
startTime, endTime := publicmethod.OenDayStartOrEndTime(day.Date, 1) |
|||
if class.Form.StartTime != "" && class.Form.EndTime != "" { |
|||
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v OR f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime, class.Form.EndTime, startTime, endTime) |
|||
gormDb = gormDb.Where(whySql) |
|||
} else if class.Form.StartTime != "" && class.Form.EndTime == "" { |
|||
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime) |
|||
gormDb = gormDb.Where(whySql) |
|||
} else if class.Form.StartTime == "" && class.Form.EndTime != "" { |
|||
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.EndTime, startTime, endTime) |
|||
gormDb = gormDb.Where(whySql) |
|||
} |
|||
} |
|||
} |
|||
var formList []map[string]interface{} |
|||
err := gormDb.Order("`id` DESC").Find(&formList).Error |
|||
if listJson != "" { |
|||
var listFieldsMap ListPageFields |
|||
err = json.Unmarshal([]byte(listJson), &listFieldsMap) |
|||
if err == nil { |
|||
formList = listFieldsMap.DevelopSpecificationsSend(formList) |
|||
} |
|||
|
|||
} |
|||
if err == nil { |
|||
inDate := publicmethod.MapOut[string]() |
|||
inDate[day.Date] = formList |
|||
c.List = append(c.List, inDate) |
|||
// c.List = append(c.List, inDate)
|
|||
// c.List = make(map[string]interface{})
|
|||
// c.List[day.Date] = formList
|
|||
} |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-07-16 15:53:51 |
|||
@ 功能: 自定义表单查询条件 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func AnalysisSerachTermSqlIng(why []SearchButtonInfo, gormDb *gorm.DB) *gorm.DB { |
|||
if len(why) < 1 { |
|||
return gormDb |
|||
} |
|||
for _, v := range why { |
|||
if v.Values != nil && v.Values != "" { |
|||
switch v.Pattern { |
|||
case "int": |
|||
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values) |
|||
gormDb = gormDb.Where(likeSql) |
|||
case "bigint": |
|||
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values) |
|||
gormDb = gormDb.Where(likeSql) |
|||
default: |
|||
likeSql := fmt.Sprintf("f.%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'") |
|||
gormDb = gormDb.Where(likeSql) |
|||
} |
|||
} |
|||
} |
|||
return gormDb |
|||
} |
|||
@ -0,0 +1,813 @@ |
|||
package taskflow |
|||
|
|||
import ( |
|||
"appPlatform/api/version1/customerform" |
|||
"appPlatform/api/version1/taskplatform/taskmanagement" |
|||
"appPlatform/models/customerForm" |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"strconv" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-06 16:37:39 |
|||
@ 功能: 获取App任务(任务流版本) |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) GainAppTaskList(c *gin.Context) { |
|||
var requestData AppTaskSearch |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(100, requestData, c) |
|||
return |
|||
} |
|||
if requestData.Page == 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 10 |
|||
} |
|||
|
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
|
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Select("`id`").Where("appKey = ?", requestData.Id) |
|||
switch requestData.Class { |
|||
case 2: //待办事宜
|
|||
gormDb = gormDb.Where("`status` = 3 AND FIND_IN_SET(?,`next_executor`)", userCont.Key) |
|||
case 3: //已办事宜
|
|||
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?", userCont.Key, userCont.Key, userCont.Key) |
|||
case 4: //草稿箱
|
|||
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key) |
|||
case 5: //抄送我的
|
|||
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", userCont.Key) |
|||
default: //我的请求
|
|||
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key) |
|||
} |
|||
if requestData.Title != "" { |
|||
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") |
|||
} |
|||
if requestData.State != 0 { |
|||
gormDb = gormDb.Where("`status` = ?", requestData.State) |
|||
} |
|||
//获取总数
|
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
var idAry []int64 |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
err := gormDb.Order("`update_time` desc").Find(&idAry).Error |
|||
var userList []SendAppTaskFlowInfo |
|||
if err != nil || len(idAry) < 1 { |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) |
|||
return |
|||
} |
|||
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Where("`id` IN ?", idAry).Order("`start_time` desc").Find(&userList) |
|||
for i := 0; i < len(userList); i++ { |
|||
userList[i].FormVersionId = strconv.FormatInt(userList[i].VersionId, 10) |
|||
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10) |
|||
userList[i].FlowKeys = strconv.FormatInt(userList[i].FlowKey, 10) |
|||
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater) |
|||
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10) |
|||
if userList[i].NextExecutor != "" { |
|||
nextAry := strings.Split(userList[i].NextExecutor, ",") |
|||
for _, v := range nextAry { |
|||
userList[i].CurrentNodeUser = append(userList[i].CurrentNodeUser, GainSmaillUserInfo[string](v)) |
|||
} |
|||
} |
|||
userList[i].StartDate = publicmethod.UnixTimeToDay(userList[i].StartTime, 27) |
|||
if userList[i].NextStep != 0 { |
|||
nodeCont, idTrue := GainCurreNode(userList[i].FlowCont, userList[i].CurrentStep, userList[i].NextStep, userList[i].Status) |
|||
if idTrue { |
|||
userList[i].CurrentNodeName = nodeCont.NodeName |
|||
} |
|||
} |
|||
if userList[i].MastesForm == "" || userList[i].MastesFormJson == "" { |
|||
userList[i].MastesForm, userList[i].MastesFormJson = GainTaskFormData(userList[i].FlowKey) |
|||
} |
|||
if userList[i].Status == 3 && userList[i].NextStep != 0 { |
|||
if userList[i].CurrentStep == 1 { |
|||
userList[i].IsRetract = true |
|||
} |
|||
} |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-07 11:06:14 |
|||
@ 功能: 获取App任务(包含非流程表单) |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) GainAppAllTaskList(c *gin.Context) { |
|||
var requestData AppAllTaskSearch |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(100, requestData, c) |
|||
return |
|||
} |
|||
if requestData.Page == 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 10 |
|||
} |
|||
|
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Select("`id`").Where("appKey = ?", requestData.Id) |
|||
switch requestData.Class { |
|||
case 2: //草稿箱
|
|||
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key) |
|||
default: //我的请求
|
|||
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key) |
|||
} |
|||
if requestData.Title != "" { |
|||
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") |
|||
} |
|||
//获取总数
|
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
var idAry []int64 |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
err := gormDb.Order("`id` desc").Find(&idAry).Error |
|||
var userList []SendTaskInfo |
|||
if err != nil || len(idAry) < 1 { |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) |
|||
return |
|||
} |
|||
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Where("`id` IN ?", idAry).Order("`id` desc").Find(&userList) |
|||
for i := 0; i < len(userList); i++ { |
|||
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10) |
|||
userList[i].CreaterTimeStr = publicmethod.UnixTimeToDay(userList[i].CreaterTime, 27) |
|||
userList[i].RunFlowIdStr = strconv.FormatInt(userList[i].RunFlowId, 10) |
|||
userList[i].VersionIdStr = strconv.FormatInt(userList[i].VersionId, 10) |
|||
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10) |
|||
userList[i].FlowKeyStr = strconv.FormatInt(userList[i].FlowKey, 10) |
|||
userList[i].FlowRunSingStr = strconv.FormatInt(userList[i].FlowRunSing, 10) |
|||
userList[i].TableKeyStr = strconv.FormatInt(userList[i].TableKey, 10) |
|||
userList[i].AppKeyStr = strconv.FormatInt(userList[i].AppKey, 10) |
|||
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater) |
|||
if userList[i].Types == 1 && userList[i].Status == 3 && userList[i].RunFlowId != 0 { |
|||
var runFlowInfo customerForm.RunWorkflow |
|||
runFlowInfo.GetCont(map[string]interface{}{"`id`": userList[i].RunFlowId}, "`current_step`", "`next_step`", "`creater`") |
|||
if runFlowInfo.NextStep != 0 && runFlowInfo.CurrentStep == 1 { |
|||
if runFlowInfo.Creater == userCont.Key { |
|||
userList[i].IsRetract = true |
|||
} |
|||
} |
|||
} |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-07 13:27:30 |
|||
@ 功能: 启动流程 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) RunAppWorkFlow(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(100, err, c) |
|||
return |
|||
} |
|||
var taskInfo customerForm.TaskRecord |
|||
err = taskInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
creetTime := time.Now().Unix() //当前时间
|
|||
|
|||
//获取任务
|
|||
var runFlowInfo customerForm.RunWorkflow |
|||
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskInfo.MastersKey}) |
|||
if err != nil { //不存在,则新建工作流
|
|||
|
|||
//获取流程详情
|
|||
var flowVersionInfo modelAppPlatform.WorkFlowVersion |
|||
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`") |
|||
uuid := publicmethod.GetUUid(1) |
|||
runUuId := publicmethod.GetUUid(6) |
|||
//执行工作流内容
|
|||
var workFlowInfo customerForm.RunWorkflow |
|||
workFlowInfo.Id = uuid |
|||
workFlowInfo.FlowKey, _ = strconv.ParseInt(requestData.Id, 10, 64) //统一识别符(任务标识符)
|
|||
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
|
|||
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
|
|||
workFlowInfo.Creater = userCont.Key //流程发起人
|
|||
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
|
|||
workFlowInfo.StartTime = creetTime //开始时间
|
|||
workFlowInfo.UpdateTime = creetTime //更新时间
|
|||
workFlowInfo.RunKey = runUuId //当前执行识别符
|
|||
// startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
|
|||
//执行流程
|
|||
// var executeWorkflow RunWorkFlow
|
|||
// executeWorkflow.Step = 0 //执行第几部
|
|||
// executeWorkflow.FlowList = requestData.FlowList
|
|||
// executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
|
|||
// executeWorkflow.TotalSteps = len(requestData.FlowList) //流程总长度
|
|||
// executeWorkflow.Uuid = uuid //流程唯一识别符
|
|||
// executeWorkflow.RunUid = runUuId //执行Uid
|
|||
|
|||
} else { |
|||
//存在,则发起工作流
|
|||
} |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-07 16:05:33 |
|||
@ 功能: 编辑任务内容 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) EditTaskAppInfo(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(1, err, c, "未知表单参数!请核对1后重新提交!") |
|||
return |
|||
} |
|||
//Step1:判断任务是处在什么状态
|
|||
var taskInfo customerForm.TaskRecord |
|||
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`version_id`", "`mastesformjson`", "`status`", "`types`", `flow_key`, "`masters_key`") |
|||
if err != nil { |
|||
publicmethod.Result(1, err, c, "流程不存在!不可进行下一步") |
|||
return |
|||
} |
|||
if !publicmethod.IsInTrue[int](taskInfo.Status, []int{1, 2, 4}) { |
|||
publicmethod.Result(1, err, c, "流程既不是草稿,也未发表、归档!不可进行下一步") |
|||
return |
|||
} |
|||
//Step2:展开表单
|
|||
var formJsonCont customerform.CustomerFormMaster |
|||
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) |
|||
//Step3:获取流程使用得表单数据表
|
|||
var customerFormInfo modelAppPlatform.CustomerFormVersion |
|||
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`", "`table_structure`", "`dict`") |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var formUnitCont customerform.FormUnitInfo |
|||
formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) |
|||
masterUnitList := make(map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.MasterInfo { |
|||
|
|||
masterUnitList[v.Name] = v |
|||
} |
|||
mastKeyName, sunKeyName := formUnitCont.GainMasterAndSunFormUnitNameKey() |
|||
masterDataInfo := GainCurrendLogData(taskInfo.MastersKey, customerFormInfo, formUnitCont, masterUnitList) |
|||
|
|||
var logDataInfo FormDataLog |
|||
logDataInfo.FlowKey = taskInfo.MastersKey |
|||
logDataInfo.GainFlowFoemLog() |
|||
|
|||
fmt.Printf("主表的数据返回值--->%v\n--->%v\n", masterDataInfo, logDataInfo.NewData) |
|||
|
|||
if len(logDataInfo.NewData) > 0 { |
|||
logTime := logDataInfo.NewData["logTime"] |
|||
newDataInfo := publicmethod.MapOut[string]() |
|||
for i, v := range masterDataInfo { |
|||
fmt.Printf("logDataInfo.masterDataInfo---->%v:%v--------->%T\n", i, v, v) |
|||
for j, jv := range logDataInfo.NewData { |
|||
if i == j { |
|||
if i == "masters_key" { |
|||
if mastKey, ok := jv.(uint64); ok { |
|||
newDataInfo[i] = strconv.FormatUint(mastKey, 10) |
|||
} |
|||
} else if i == "creater" { |
|||
if createrKey, ok := jv.(int64); ok { |
|||
newDataInfo[i] = strconv.FormatInt(createrKey, 10) |
|||
} |
|||
} else { |
|||
newDataInfo[i] = jv |
|||
} |
|||
|
|||
} |
|||
if j == "explicate" { |
|||
newDataInfo["explicate"] = jv |
|||
} |
|||
} |
|||
} |
|||
logDataInfo.NewData = masterDataInfo |
|||
logDataInfo.NewData["logTime"] = logTime |
|||
masterDataInfo = newDataInfo |
|||
} else { |
|||
isWrite := true |
|||
for i, v := range masterDataInfo { |
|||
fmt.Printf("logDataInfo.masterDataInfo--1-->%v:%v--------->%T\n", i, v, v) |
|||
if i == "masters_key" { |
|||
if mastKey, ok := v.(uint64); ok { |
|||
masterDataInfo[i] = strconv.FormatUint(mastKey, 10) |
|||
} |
|||
} |
|||
if i == "creater" { |
|||
if createrKey, ok := v.(int64); ok { |
|||
masterDataInfo[i] = strconv.FormatInt(createrKey, 10) |
|||
} |
|||
} |
|||
if i == "explicate" { |
|||
isWrite = false |
|||
} |
|||
} |
|||
if isWrite { |
|||
masterDataInfo["explicate"] = "" |
|||
} |
|||
} |
|||
masterDataInfo["flowKey"] = strconv.FormatInt(taskInfo.FlowKey, 10) |
|||
sendData := publicmethod.MapOut[string]() |
|||
sendData["masterDataInfo"] = masterDataInfo |
|||
|
|||
publicmethod.Result(0, sendData, c) |
|||
return |
|||
|
|||
sendNewData := publicmethod.MapOut[string]() |
|||
sendSunNewData := publicmethod.MapOut[string]() |
|||
for i, v := range logDataInfo.NewData { |
|||
if val, isOk := v.([]map[string]interface{}); !isOk { |
|||
for mi, mv := range mastKeyName { |
|||
if mi == i { |
|||
sendNewData[mv] = v |
|||
} |
|||
} |
|||
} else { |
|||
// fmt.Printf("获取数据类型:---4-->%v----->%v\n", val, sunKeyName[i])
|
|||
var newSunData []map[string]interface{} |
|||
for _, sv := range val { |
|||
sunOld := publicmethod.MapOut[string]() |
|||
for smi, smv := range sv { |
|||
for sui, suv := range sunKeyName[i] { |
|||
if sui == smi { |
|||
sunOld[suv] = smv |
|||
} |
|||
if smi == "id" { |
|||
sunOld[suv] = smv |
|||
} |
|||
} |
|||
} |
|||
newSunData = append(newSunData, sunOld) |
|||
fmt.Printf("获取数据类型:---4-->%v----->%v\n", sv, newSunData) |
|||
} |
|||
sendSunNewData[i] = newSunData |
|||
} |
|||
|
|||
} |
|||
for i, v := range sendSunNewData { |
|||
sendNewData[i] = v |
|||
} |
|||
if len(sendNewData) > 0 { |
|||
sendNewData["logTime"] = logDataInfo.NewData["logTime"] |
|||
} |
|||
|
|||
fmt.Printf("获取数据类型:----->%v\n", sendNewData) |
|||
sendData["newData"] = sendNewData |
|||
sendData["oldData"] = EditLogCont(logDataInfo.OldData, mastKeyName, sunKeyName) |
|||
sendData["newDataLen"] = len(sendNewData) |
|||
sendData["logistrue"] = false |
|||
if len(sendNewData) > 0 || len(logDataInfo.OldData) > 0 { |
|||
sendData["logistrue"] = true |
|||
} |
|||
publicmethod.Result(0, sendData, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-10 11:27:13 |
|||
@ 功能: 再次保存草稿箱内容 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) SaveDraftAgain(c *gin.Context) { |
|||
data, err := c.GetRawData() //接收表单提交得数据
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
mapData := publicmethod.MapOut[string]() //初始化MAP
|
|||
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
taskId := "" |
|||
if taskIdVal, ok := mapData["masters_key"]; !ok { |
|||
publicmethod.Result(1, err, c, "非法表单!不能提交数据!") |
|||
return |
|||
} else { |
|||
if akValStr, ok := taskIdVal.(string); ok { |
|||
taskId = akValStr |
|||
} |
|||
} |
|||
|
|||
var formCont modelAppPlatform.CustomerFormView |
|||
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]}) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var sunFormName []string //子表名称集合
|
|||
if formCont.TableStructure != "" { //拆解获取子表名称
|
|||
var sunFormStruct map[string]string |
|||
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct) |
|||
if err == nil { |
|||
for _, v := range sunFormStruct { |
|||
if !publicmethod.IsInTrue[string](v, sunFormName) { |
|||
sunFormName = append(sunFormName, v) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
masterField := publicmethod.MapOut[string]() //主表数据
|
|||
sunFieldAry := publicmethod.MapOut[string]() //子表数据
|
|||
for k, v := range mapData { |
|||
if !publicmethod.IsInTrue[string](k, sunFormName) { |
|||
if !publicmethod.IsInTrue[string](k, []string{"formId"}) { |
|||
masterField[k] = v |
|||
} |
|||
} else { |
|||
sunFieldAry[k] = v |
|||
} |
|||
} |
|||
|
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
cureeTime := time.Now().Unix() |
|||
|
|||
var formJsonCont customerform.CustomerFormMaster |
|||
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串
|
|||
|
|||
var formUnitCont customerform.FormUnitInfo |
|||
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件
|
|||
|
|||
//主表组件
|
|||
masterUnitList := make(map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.MasterInfo { |
|||
masterUnitList[v.Name] = v |
|||
} |
|||
sendInfo := publicmethod.MapOut[string]() |
|||
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2) |
|||
if len(masrWriteMap) > 0 { |
|||
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap) |
|||
sendInfo["oldMasterData"] = oldMasterData |
|||
} |
|||
//判断是否有子表
|
|||
if len(sunFieldAry) > 0 { |
|||
//有子表
|
|||
sunTypeAry := make(map[string]map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.SunFormInfo { |
|||
sunTypeAry[v.TableName] = v.UbitInfo |
|||
} |
|||
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) |
|||
sendInfo["sunTableData"] = sunTableData |
|||
if len(sunTableData) > 0 { |
|||
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry) |
|||
sendInfo["sonList"] = sonList |
|||
} |
|||
} |
|||
|
|||
sendInfo["taskId"] = taskId |
|||
sendInfo["mapData"] = mapData |
|||
sendInfo["masterField"] = masterField |
|||
sendInfo["sunFieldAry"] = sunFieldAry |
|||
sendInfo["masterUnitList"] = masterUnitList |
|||
sendInfo["cureeTime"] = cureeTime |
|||
sendInfo["masrWriteMap"] = masrWriteMap |
|||
publicmethod.Result(0, sendInfo, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-13 11:20:04 |
|||
@ 功能: 重新提交(有流程就发动流程,无流程就正常发表) |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) AfreshAppSubmit(c *gin.Context) { |
|||
data, err := c.GetRawData() //接收表单提交得数据
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
mapData := publicmethod.MapOut[string]() //初始化MAP
|
|||
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
taskId := "" |
|||
if taskIdVal, ok := mapData["masters_key"]; !ok { |
|||
publicmethod.Result(1, err, c, "非法表单!不能提交数据!") |
|||
return |
|||
} else { |
|||
if akValStr, ok := taskIdVal.(string); ok { |
|||
taskId = akValStr |
|||
} |
|||
} |
|||
var flowListAry []RunFlow |
|||
if flowAry, ok := mapData["flowList"]; ok { |
|||
|
|||
if akFlowValStr, ok := flowAry.(string); ok { |
|||
json.Unmarshal([]byte(akFlowValStr), &flowListAry) |
|||
} |
|||
|
|||
} |
|||
var formCont modelAppPlatform.CustomerFormView |
|||
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]}) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var sunFormName []string //子表名称集合
|
|||
if formCont.TableStructure != "" { //拆解获取子表名称
|
|||
var sunFormStruct map[string]string |
|||
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct) |
|||
if err == nil { |
|||
for _, v := range sunFormStruct { |
|||
if !publicmethod.IsInTrue[string](v, sunFormName) { |
|||
sunFormName = append(sunFormName, v) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
masterField := publicmethod.MapOut[string]() //主表数据
|
|||
sunFieldAry := publicmethod.MapOut[string]() //子表数据
|
|||
for k, v := range mapData { |
|||
if !publicmethod.IsInTrue[string](k, sunFormName) { |
|||
if !publicmethod.IsInTrue[string](k, []string{"formId"}) { |
|||
masterField[k] = v |
|||
} |
|||
} else { |
|||
sunFieldAry[k] = v |
|||
} |
|||
} |
|||
|
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
cureeTime := time.Now().Unix() |
|||
|
|||
var formJsonCont customerform.CustomerFormMaster |
|||
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串
|
|||
|
|||
var formUnitCont customerform.FormUnitInfo |
|||
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件
|
|||
|
|||
//主表组件
|
|||
masterUnitList := make(map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.MasterInfo { |
|||
masterUnitList[v.Name] = v |
|||
} |
|||
sendInfo := publicmethod.MapOut[string]() |
|||
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2) |
|||
if len(masrWriteMap) > 0 { |
|||
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap) |
|||
sendInfo["oldMasterData"] = oldMasterData |
|||
} |
|||
//判断是否有子表
|
|||
if len(sunFieldAry) > 0 { |
|||
//有子表
|
|||
sunTypeAry := make(map[string]map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.SunFormInfo { |
|||
sunTypeAry[v.TableName] = v.UbitInfo |
|||
} |
|||
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) |
|||
sendInfo["sunTableData"] = sunTableData |
|||
if len(sunTableData) > 0 { |
|||
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry) |
|||
sendInfo["sonList"] = sonList |
|||
} |
|||
} |
|||
//开启流程的
|
|||
if formCont.FlowIsOpen == 1 { |
|||
var runFlowInfo customerForm.RunWorkflow |
|||
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskId}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`") |
|||
saveTask := publicmethod.MapOut[string]() //修改任务
|
|||
if err != nil { |
|||
uuid := publicmethod.GetUUid(1) |
|||
runUuId := publicmethod.GetUUid(6) |
|||
var taskInfo customerForm.TaskRecord |
|||
taskInfo.GetCont(map[string]interface{}{"`masters_key`": taskId}, "`flow_key`", "`flow_run_sing`") |
|||
//获取流程详情
|
|||
var flowVersionInfo modelAppPlatform.WorkFlowVersion |
|||
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`") |
|||
//执行工作流内容
|
|||
var workFlowInfo customerForm.RunWorkflow |
|||
workFlowInfo.Id = uuid |
|||
workFlowInfo.FlowKey = taskInfo.FlowKey //统一识别符(任务标识符)
|
|||
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
|
|||
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
|
|||
workFlowInfo.Creater = userCont.Key //流程发起人
|
|||
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
|
|||
workFlowInfo.StartTime = cureeTime //开始时间
|
|||
workFlowInfo.UpdateTime = cureeTime //更新时间
|
|||
workFlowInfo.RunKey = runUuId //当前执行识别符
|
|||
|
|||
startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
|
|||
//执行流程
|
|||
var executeWorkflow RunWorkFlow |
|||
executeWorkflow.Step = 0 //执行第几部
|
|||
executeWorkflow.FlowList = flowListAry |
|||
executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey) |
|||
executeWorkflow.TotalSteps = len(flowListAry) //流程总长度
|
|||
executeWorkflow.Uuid = uuid //流程唯一识别符
|
|||
executeWorkflow.RunUid = runUuId //执行Uid
|
|||
executeWorkflow.GainRunNode(startCreaterKey, 2, "发起审批") |
|||
flowJsonCont, _ := json.Marshal(executeWorkflow.FlowList) //将步进流转化成json流
|
|||
workFlowInfo.FlowCont = string(flowJsonCont) //流程执行体
|
|||
|
|||
workFlowInfo.CurrentStep = executeWorkflow.Step |
|||
workFlowInfo.NextStep = executeWorkflow.NextStep |
|||
//参与人去重
|
|||
var parUser []string |
|||
for _, v := range executeWorkflow.Participant { |
|||
if !publicmethod.IsInTrue[string](v, parUser) { |
|||
parUser = append(parUser, v) |
|||
} |
|||
} |
|||
workFlowInfo.Participants = strings.Join(parUser, ",") |
|||
nextRunUser := executeWorkflow.NextRunNodeUser(1) |
|||
workFlowInfo.NextExecutor = strings.Join(nextRunUser, ",") |
|||
if executeWorkflow.NextStep <= 0 { |
|||
workFlowInfo.Status = 4 |
|||
} |
|||
|
|||
err = workFlowInfo.WriteCont() //写入执行工作流
|
|||
if err != nil { |
|||
var taskInfo customerForm.TaskRecord |
|||
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 1}) |
|||
publicmethod.Result(10001, err, c, "流程写入失败!请重新发起") |
|||
return |
|||
} |
|||
if executeWorkflow.NextStep <= 0 { |
|||
var taskCont customerForm.TaskRecord |
|||
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 4}) |
|||
} else { |
|||
var taskCont customerForm.TaskRecord |
|||
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 3}) |
|||
} |
|||
// saveTask["`flow_key`"] = 2
|
|||
} else { |
|||
var flowList []taskmanagement.RunFlow |
|||
err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
|
|||
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
|
|||
runUuId := publicmethod.GetUUid(6) |
|||
//执行流程
|
|||
var runFlow taskmanagement.RunWorkFlow |
|||
runFlow.Step = 0 //执行第几部
|
|||
runFlow.FlowList = flowList |
|||
runFlow.Participant = append(runFlow.Participant, startUs) |
|||
runFlow.TotalSteps = len(flowList) //流程总长度
|
|||
runFlow.Uuid = runFlowInfo.Id |
|||
runFlow.RunUid = runUuId |
|||
runFlow.GainRunNode(startUs, 2, "重新发起流程") |
|||
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
|
|||
SaveFlowCont := publicmethod.MapOut[string]() |
|||
SaveFlowCont["`flow_cont`"] = string(flowJsonCont) |
|||
SaveFlowCont["`current_step`"] = runFlow.Step |
|||
SaveFlowCont["`next_step`"] = runFlow.NextStep |
|||
SaveFlowCont["`runKey`"] = runUuId |
|||
//参与人去重
|
|||
var parUser []string |
|||
for _, v := range runFlow.Participant { |
|||
if !publicmethod.IsInTrue[string](v, parUser) { |
|||
parUser = append(parUser, v) |
|||
} |
|||
} |
|||
SaveFlowCont["`participants`"] = strings.Join(parUser, ",") |
|||
nextRunUser := runFlow.NextRunNodeUser(1) |
|||
SaveFlowCont["`next_executor`"] = strings.Join(nextRunUser, ",") |
|||
SaveFlowCont["`status`"] = 3 |
|||
if runFlow.NextStep <= 0 { |
|||
SaveFlowCont["`status`"] = 4 |
|||
} |
|||
SaveFlowCont["`update_time`"] = time.Now().Unix() |
|||
err = runFlowInfo.EiteCont(map[string]interface{}{"`id`": runFlowInfo.Id}, SaveFlowCont) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} |
|||
saveTask["`status`"] = 3 |
|||
saveTask["`edit_time`"] = time.Now().Unix() |
|||
var taskInfo customerForm.TaskRecord |
|||
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask) |
|||
} else { //未开启流程的表单
|
|||
saveTask := publicmethod.MapOut[string]() //修改任务
|
|||
saveTask["`status`"] = 2 |
|||
|
|||
saveTask["`edit_time`"] = time.Now().Unix() |
|||
var taskInfo customerForm.TaskRecord |
|||
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask) |
|||
} |
|||
|
|||
// sendInfo["taskId"] = taskId
|
|||
// sendInfo["mapData"] = mapData
|
|||
// sendInfo["masterField"] = masterField
|
|||
// sendInfo["sunFieldAry"] = sunFieldAry
|
|||
// sendInfo["masterUnitList"] = masterUnitList
|
|||
// sendInfo["cureeTime"] = cureeTime
|
|||
// sendInfo["masrWriteMap"] = masrWriteMap
|
|||
publicmethod.Result(0, sendInfo, c) |
|||
} |
|||
@ -0,0 +1,164 @@ |
|||
package taskmanagement |
|||
|
|||
import ( |
|||
"appPlatform/api/version1/customerform" |
|||
"appPlatform/models/customerForm" |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-06 13:57:55 |
|||
@ 功能: 自定义App表单新增记录 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) CreateAppTask(c *gin.Context) { |
|||
data, err := c.GetRawData() //接收表单提交得数据
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
mapData := publicmethod.MapOut[string]() //初始化MAP
|
|||
err = json.Unmarshal(data, &mapData) //将接收的json字符串参数转换成Map
|
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if _, ok := mapData["versionId"]; !ok { |
|||
publicmethod.Result(1, err, c, "非法表单!不能提交数据!") |
|||
return |
|||
} |
|||
status := 1 |
|||
if _, ok := mapData["status"]; ok { |
|||
fmt.Printf("mapData[status]:%v------------->%T\n", mapData["status"], mapData["status"]) |
|||
if vFloat64, isOk := mapData["status"].(float64); isOk { |
|||
vStr := strconv.FormatFloat(vFloat64, 'f', -1, 64) |
|||
status, _ = strconv.Atoi(vStr) |
|||
} |
|||
} |
|||
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
|
|||
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]}) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var sunFormName []string //子表名称集合
|
|||
if formCont.TableStructure != "" { //拆解获取子表名称
|
|||
var sunFormStruct map[string]string |
|||
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct) |
|||
if err == nil { |
|||
for _, v := range sunFormStruct { |
|||
if !publicmethod.IsInTrue[string](v, sunFormName) { |
|||
sunFormName = append(sunFormName, v) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
masterField := publicmethod.MapOut[string]() //主表数据
|
|||
sunFieldAry := publicmethod.MapOut[string]() //子表数据
|
|||
for k, v := range mapData { |
|||
if !publicmethod.IsInTrue[string](k, sunFormName) { |
|||
if !publicmethod.IsInTrue[string](k, []string{"formId", "id"}) { |
|||
masterField[k] = v |
|||
} |
|||
} else { |
|||
sunFieldAry[k] = v |
|||
} |
|||
} |
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
uuid := publicmethod.GetUUid(1) //统一识别符
|
|||
cureeTime := time.Now().Unix() //写入时间
|
|||
|
|||
var formJsonCont customerform.CustomerFormMaster |
|||
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) |
|||
|
|||
var formUnitCont customerform.FormUnitInfo |
|||
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) |
|||
masterUnitList := make(map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.MasterInfo { |
|||
masterUnitList[v.Name] = v |
|||
} |
|||
|
|||
masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1) |
|||
masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen |
|||
//任务列表
|
|||
var taskCont customerForm.TaskRecord |
|||
taskCont.MastersKey = uuid |
|||
taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"`
|
|||
taskCont.AppKey = formCont.Groupid |
|||
taskCont.TableKey = formCont.SignCode |
|||
taskCont.Creater = userCont.Key //创建人"`
|
|||
taskCont.CreaterTime = cureeTime //创建时间"`
|
|||
taskCont.EditTime = cureeTime //编辑时间"`
|
|||
taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"`
|
|||
taskCont.VersionId = formCont.Id //来源于哪个表单"`
|
|||
taskCont.Status = status |
|||
if formCont.FlowIsOpen == 1 { |
|||
taskCont.Status = status |
|||
taskCont.FlowKey = formCont.Flowkey |
|||
var flowInfo modelAppPlatform.FlowVersion |
|||
flowInfo.GetCont(map[string]interface{}{"`key`": formCont.Flowkey, "`state`": 1}, "`id`") |
|||
taskCont.FlowRunSing = flowInfo.Id |
|||
} |
|||
//判断是否
|
|||
if len(sunFieldAry) > 0 { |
|||
//有子表
|
|||
sunTypeAry := make(map[string]map[string]customerform.MasterStruct) |
|||
for _, v := range formUnitCont.SunFormInfo { |
|||
sunTypeAry[v.TableName] = v.UbitInfo |
|||
} |
|||
|
|||
err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) |
|||
|
|||
} else { |
|||
// //无子表
|
|||
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masrWriteMap).Error |
|||
publicmethod.WriteLog("write", "写入自定义表单", formCont.TableKey, err) |
|||
} |
|||
if err != nil { |
|||
publicmethod.Result(104, err, c) |
|||
return |
|||
} |
|||
taskCont.MastesForm = formCont.MastesForm |
|||
taskCont.MastesFormJson = formCont.MastesFormJson |
|||
err = overall.CONSTANT_DB_CustomerForm.Create(&taskCont).Error |
|||
// for k, v := range masrWriteMap {
|
|||
// fmt.Printf("%v----> %T\n", k, v)
|
|||
// }
|
|||
publicmethod.WriteLog("write", "写入任务", err, taskCont) |
|||
|
|||
sendData := publicmethod.MapOut[string]() |
|||
sendData["uuid"] = strconv.FormatInt(uuid, 10) |
|||
sendData["cureeTime"] = cureeTime |
|||
sendData["formUnitCont"] = formUnitCont |
|||
sendData["masterField"] = masterField |
|||
sendData["sunFieldAry"] = sunFieldAry |
|||
sendData["sunFieldAry_len"] = len(sunFieldAry) |
|||
sendData["masrWriteMap"] = masrWriteMap |
|||
sendData["sunFormName"] = sunFormName |
|||
sendData["mapData"] = mapData |
|||
|
|||
publicmethod.Result(0, sendData, c) |
|||
} |
|||
@ -0,0 +1,286 @@ |
|||
package taskmanagement |
|||
|
|||
import ( |
|||
"appPlatform/models/customerForm" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"strconv" |
|||
"strings" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-18 09:11:38 |
|||
@ 功能: 执行工作流 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) RunTaskFlow(c *gin.Context) { |
|||
var requestData SubmitAppResults |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.AgreeOrRefuse == 0 { |
|||
requestData.AgreeOrRefuse = 2 |
|||
} |
|||
where := publicmethod.MapOut[string]() |
|||
where["`id`"] = requestData.Id |
|||
var flowInfo customerForm.RunWorkflow |
|||
err = flowInfo.GetCont(where) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
if flowInfo.NextStep == 0 || flowInfo.Status != 3 { |
|||
publicmethod.Result(1, err, c, "此流程再不可审批状态!您的提交无效") |
|||
return |
|||
} |
|||
if len(requestData.FlowList) < 1 { |
|||
if flowInfo.FlowCont != "" { |
|||
err = json.Unmarshal([]byte(flowInfo.FlowCont), &requestData.FlowList) |
|||
if err != nil { |
|||
publicmethod.Result(1, err, c, "流程异常!您的提交无效") |
|||
return |
|||
} |
|||
} else { |
|||
publicmethod.Result(1, err, c, "流程异常!您的提交无效") |
|||
return |
|||
} |
|||
} |
|||
context, _ := c.Get(overall.MyContJwt) |
|||
var userCont modelshr.ManCont |
|||
userCont.GetLoginCont(context) //当前操作人
|
|||
//执行流程
|
|||
var runFlow RunWorkFlow |
|||
runFlow.Step = flowInfo.NextStep |
|||
runFlow.TotalSteps = len(requestData.FlowList) //流程总长度
|
|||
runFlow.Uuid = flowInfo.FlowKey |
|||
runFlow.RunUid = flowInfo.RunKey |
|||
runFlow.Participant = strings.Split(flowInfo.Participants, ",") |
|||
runFlow.FlowList = requestData.FlowList |
|||
runFlow.RunNodeHandle(userCont.Key, requestData.AgreeOrRefuse, requestData.Suggest) |
|||
if runFlow.IsRun { |
|||
publicmethod.Result(1, err, c, runFlow.Msg) |
|||
return |
|||
} |
|||
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
|
|||
saveFlowInfo := publicmethod.MapOut[string]() |
|||
saveTaskInfo := publicmethod.MapOut[string]() |
|||
saveFlowInfo["`flow_cont`"] = flowJsonCont |
|||
saveFlowInfo["`current_step`"] = runFlow.Step |
|||
saveFlowInfo["`next_step`"] = runFlow.NextStep |
|||
if flowInfo.Participants != "" { |
|||
oldUser := strings.Split(flowInfo.Participants, ",") |
|||
runFlow.Participant = append(runFlow.Participant, oldUser...) |
|||
} |
|||
//参与人去重
|
|||
var parUser []string |
|||
for _, v := range runFlow.Participant { |
|||
if !publicmethod.IsInTrue[string](v, parUser) { |
|||
parUser = append(parUser, v) |
|||
} |
|||
} |
|||
saveFlowInfo["`participants`"] = strings.Join(parUser, ",") |
|||
|
|||
var tsakInfos customerForm.TaskRecord |
|||
tsakInfos.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`participant`") |
|||
if len(parUser) > 0 { |
|||
oldTaskUser := strings.Split(tsakInfos.Participant, ",") |
|||
for _, v := range parUser { |
|||
if !publicmethod.IsInTrue[string](v, oldTaskUser) { |
|||
oldTaskUser = append(oldTaskUser, v) |
|||
} |
|||
} |
|||
saveTaskInfo["`participant`"] = strings.Join(parUser, ",") |
|||
} |
|||
//抄送人
|
|||
if flowInfo.MakeCopy != "" { |
|||
oldCopyUser := strings.Split(flowInfo.MakeCopy, ",") |
|||
runFlow.MakeCopy = append(runFlow.MakeCopy, oldCopyUser...) |
|||
} |
|||
|
|||
var copyMan []string |
|||
for _, v := range runFlow.MakeCopy { |
|||
if !publicmethod.IsInTrue[string](v, copyMan) { |
|||
copyMan = append(copyMan, v) |
|||
} |
|||
} |
|||
saveFlowInfo["`makeCopy`"] = strings.Join(copyMan, ",") |
|||
//下一步执行人
|
|||
nextRunUser := runFlow.NextRunNodeUser(requestData.AgreeOrRefuse) |
|||
saveFlowInfo["`next_executor`"] = strings.Join(nextRunUser, ",") |
|||
saveFlowInfo["`update_time`"] = time.Now().Unix() |
|||
if requestData.AgreeOrRefuse == 1 { |
|||
if runFlow.NextStep != 0 { |
|||
saveFlowInfo["`status`"] = 3 |
|||
saveTaskInfo["`status`"] = 3 |
|||
} else { |
|||
saveFlowInfo["`status`"] = 4 |
|||
saveTaskInfo["`status`"] = 4 |
|||
JudgeEditFlow(flowInfo.FlowKey) |
|||
} |
|||
} else { |
|||
saveFlowInfo["`runKey`"] = publicmethod.GetUUid(6) |
|||
if runFlow.Step != 1 { |
|||
saveFlowInfo["`status`"] = 3 |
|||
} else { |
|||
saveFlowInfo["`status`"] = 2 |
|||
saveTaskInfo["`status`"] = 1 |
|||
} |
|||
} |
|||
saveTaskInfo["`edit_time`"] = time.Now().Unix() |
|||
gordb := overall.CONSTANT_DB_CustomerForm.Begin() |
|||
flowErr := gordb.Model(&customerForm.RunWorkflow{}).Where(where).Updates(saveFlowInfo).Error |
|||
taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`runFlowId` = ?", requestData.Id).Updates(saveTaskInfo).Error |
|||
if flowErr != nil || taskErr != nil { |
|||
gordb.Rollback() |
|||
publicmethod.Result(100, err, c, "数据提交失败!请重新提交!") |
|||
return |
|||
} |
|||
gordb.Commit() |
|||
publicmethod.Result(0, err, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-18 09:18:27 |
|||
@ 功能: 执行节点处理 |
|||
@ 参数 |
|||
|
|||
#userKey 当前处理人 |
|||
#AgreeToRefuse 1:同意,2:驳回 |
|||
#Suggest 审批意见 |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (r *RunWorkFlow) RunNodeHandle(userKey int64, AgreeToRefuse int, Suggest string) { |
|||
//判断流程是否存在
|
|||
if len(r.FlowList) < 1 { |
|||
return |
|||
} |
|||
userKeyStr := strconv.FormatInt(userKey, 10) //当前操作人识别符转字符类型
|
|||
fmt.Printf("执行节点处理--->%v------>%v\n", r.Step, r.NextStep) |
|||
//遍历流程判断当前要执行的步骤
|
|||
for i := 0; i < r.TotalSteps; i++ { |
|||
if r.FlowList[i].Step == r.Step { //获取当前操作节点
|
|||
//Step1:判断当前节点是不是抄送节点
|
|||
if r.FlowList[i].Types == 2 { |
|||
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) |
|||
for _, op := range r.FlowList[i].Operator { |
|||
r.MakeCopy = append(r.MakeCopy, op.Id) |
|||
userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) |
|||
title := fmt.Sprintf("向%v发送抄送数据", op.Name) |
|||
FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") |
|||
// fmt.Printf("抄送人---->%v---->%v\n", userkIntId, title)
|
|||
} |
|||
r.Step = currentStep |
|||
r.NextStep = nextStep |
|||
if nextStep > 0 { |
|||
if JudgeRunNode(nextStep, r.FlowList) { |
|||
r.Step = nextStep |
|||
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) |
|||
} |
|||
} |
|||
} else { |
|||
r.IsRun, r.Msg = JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator) //判断操作人是有操作权限或是否已经操作过
|
|||
if r.IsRun { |
|||
return |
|||
} else { |
|||
if AgreeToRefuse != 1 { //驳回操作
|
|||
r.FlowList[i].Status = 3 |
|||
operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 3, r.FlowList[i].Operator, Suggest) |
|||
r.FlowList[i].Operator = operatorAry |
|||
r.Participant = append(r.Participant, nodeUser...) |
|||
r.RejectNode(r.FlowList[i].GoBackNode) |
|||
return |
|||
} else { |
|||
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) |
|||
fmt.Printf("同意操作---->%v---->%v---->%v\n", currentStep, nextStep, r.FlowList[i].Types) |
|||
r.FlowList[i].Status = 2 |
|||
operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 2, r.FlowList[i].Operator, Suggest) |
|||
r.FlowList[i].Operator = operatorAry |
|||
r.Participant = append(r.Participant, nodeUser...) |
|||
switch r.FlowList[i].Types { |
|||
case 0: |
|||
r.Step = currentStep |
|||
r.NextStep = nextStep |
|||
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, "发起流程", "") |
|||
if JudgeRunNode(nextStep, r.FlowList) { |
|||
r.Step = nextStep |
|||
r.FlowStepRun(userKey, AgreeToRefuse, Suggest) |
|||
} |
|||
return |
|||
case 1: |
|||
r.Step = currentStep |
|||
r.NextStep = nextStep |
|||
// fmt.Printf("判断是否继续执行---->%v\n", JudgeRunNode(nextStep, r.FlowList))
|
|||
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") |
|||
if JudgeRunNode(nextStep, r.FlowList) { |
|||
r.Step = nextStep |
|||
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) |
|||
} |
|||
case 2: |
|||
if currentStep+1 < r.TotalSteps { |
|||
r.Step = currentStep + 1 |
|||
if nextStep+1 <= r.TotalSteps { |
|||
r.NextStep = nextStep + 1 |
|||
} else { |
|||
r.NextStep = 0 |
|||
} |
|||
} else { |
|||
r.Step = r.TotalSteps |
|||
r.NextStep = 0 |
|||
} |
|||
for _, op := range r.FlowList[i].Operator { |
|||
r.MakeCopy = append(r.MakeCopy, op.Id) |
|||
userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) |
|||
title := fmt.Sprintf("向%v发送抄送数据", op.Name) |
|||
FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") |
|||
} |
|||
case 3: |
|||
r.Step = currentStep |
|||
r.NextStep = nextStep |
|||
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") |
|||
if JudgeRunNode(nextStep, r.FlowList) { |
|||
r.Step = nextStep |
|||
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) |
|||
} |
|||
default: |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
package customerForm |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 工作流执行主体
|
|||
// 字典类型
|
|||
type RunFlowTask struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
FlowKey int64 `json:"flowKey" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` |
|||
Version string `json:"version" gorm:"column:version;type:varchar(255);default:'';comment:使用得版本"` |
|||
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` |
|||
FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:流程执行体"` |
|||
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"` |
|||
CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(4) unsigned;default:1;not null;comment:当前节点"` |
|||
NextStep int `json:"nextStep" gorm:"column:next_step;type:int(4) unsigned;default:0;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"` |
|||
NextExecutor string `json:"nextExecutor" gorm:"column:next_executor;type:mediumtext;default:'';comment:下一步执行人"` |
|||
Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:参与人"` |
|||
StartTime int64 `json:"startTime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"` |
|||
RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"` |
|||
Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` |
|||
TaskCreate int64 `json:"taskCreate" gorm:"column:taskCreate;type:bigint(20) unsigned;default:0;not null;comment:创建人"` |
|||
CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"` |
|||
VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"` |
|||
// MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"`
|
|||
TaskFlowKey int64 `json:"taskFlowKey" gorm:"column:taskFlowKey;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` |
|||
FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` |
|||
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` |
|||
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` |
|||
Visibility int `json:"visibility" gorm:"column:visibility;type:int(1) unsigned;default:1;not null;comment:1、所有人;2、自定义"` |
|||
AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;comment:授权角色"` |
|||
AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;comment:授权人员"` |
|||
AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;comment:授权行政组织"` |
|||
AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;comment:授权职务"` |
|||
Participant string `json:"participant" gorm:"column:participant;type:longtext;default:'';comment:表单结构json"` |
|||
TableKey int64 `json:"tableKey" gorm:"column:tableKey;type:bigint(20) unsigned;default:0;not null;comment:归属自定义表"` |
|||
AppKey int64 `json:"appKey" gorm:"column:appKey;type:bigint(20) unsigned;default:0;not null;comment:归属App(0:非app表单)"` |
|||
MakeCopy string `json:"makeCopy" gorm:"column:makeCopy;type:mediumtext;comment:抄送人"` |
|||
MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表识别符"` |
|||
} |
|||
|
|||
func (RunFlowTask *RunFlowTask) TableName() string { |
|||
return "runFlowTask" |
|||
} |
|||
|
|||
// 写入内容
|
|||
func (cont *RunFlowTask) WriteCont() (err error) { |
|||
err = overall.CONSTANT_DB_CustomerForm.Create(&cont).Error |
|||
return |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *RunFlowTask) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *RunFlowTask) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
// 根据条件获取总数
|
|||
func (cont *RunFlowTask) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *RunFlowTask) ContMap(whereMap interface{}, field ...string) (countAry []RunFlowTask, err error) { |
|||
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *RunFlowTask) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
package modelAppPlatform |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-04-23 11:25:43 |
|||
@ 功能: 自定义应用菜单表 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
type Appmenus struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` |
|||
Label string `json:"label" gorm:"column:label;type:varchar(255) unsigned;default:'';not null;comment:节点名称"` |
|||
Types int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:节点类型 1:目录;2:菜单"` |
|||
Svg string `json:"svg" gorm:"column:svg;type:varchar(255) DEFAULT '' comment:图标"` |
|||
PcIsShow int `json:"pcIsShow" gorm:"column:pcIsShow;type:int(1) unsigned DEFAULT '1' comment:pc端显示与隐藏(1:显示;非1:隐藏)"` |
|||
WapIsShow int `json:"wapIsShow" gorm:"column:wapIsShow;type:int(1) unsigned DEFAULT '1' comment:移动端显示与隐藏(1:显示;非1:隐藏)"` |
|||
Parent int64 `json:"parent" gorm:"column:parent;type:bigint(20) unsigned;default:0;not null;comment:上级"` |
|||
Appkey int64 `json:"appkey" gorm:"column:appkey;type:bigint(20) unsigned;default:0;not null;comment:归属哪个应用"` |
|||
CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
EditTime int64 `json:"edit_time" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` |
|||
IsLock int `json:"isLock" gorm:"column:isLock;type:int(1) unsigned NOT NULL DEFAULT '2' comment:是否为固定菜单(1:是;2:否)"` |
|||
Sort int64 `json:"sort" gorm:"column:sort;type:int(5) unsigned NOT NULL DEFAULT '50' comment:排序"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned NOT NULL DEFAULT '1' comment:状态(1:启用;2:禁用;3:删除)"` |
|||
IsMain int `json:"isMain" gorm:"column:isMain;type:int(1) unsigned NOT NULL DEFAULT '2' comment:1:入口;2:不是入口"` |
|||
} |
|||
|
|||
func (Appmenus *Appmenus) TableName() string { |
|||
return "appmenus" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *Appmenus) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *Appmenus) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
// 根据条件获取总数
|
|||
func (cont *Appmenus) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *Appmenus) ContMap(whereMap interface{}, field ...string) (countAry []Appmenus, err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *Appmenus) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue