Browse Source

编写自定义列表功能

li_v1
超级管理员 2 years ago
parent
commit
c9b841d34a
  1. 37
      api/shiyan/maptostruct/shiyan.go
  2. 466
      api/version1/customerform/codeFormGroup.go
  3. 87
      api/version1/customerform/form.go
  4. 791
      api/version1/customerform/formTable.go
  5. 50
      api/version1/customerform/listField.go
  6. 132
      api/version1/customerform/type.go
  7. 48
      api/version1/publicapi/api.go
  8. 7
      api/version1/publicapi/type.go
  9. 51
      api/version1/taskplatform/taskflow/types.go
  10. 592
      api/version1/taskplatform/taskflow/workflow.go
  11. 4
      api/version1/taskplatform/taskmanagement/appform.go
  12. 149
      api/version1/taskplatform/taskmanagement/formcontrol.go
  13. 4
      api/version1/taskplatform/taskmanagement/types.go
  14. 2
      apirouter/apishiyan/maptostruct.go
  15. 21
      apirouter/v1/customerformrouter/router.go
  16. 7
      apirouter/v1/taskrouter/taskrouter.go
  17. 68
      models/customerForm/taskrecord.go
  18. 76
      models/customerForm/taskrunrecord.go
  19. 8
      models/modelAppPlatform/customer_form.go
  20. 68
      models/modelAppPlatform/customer_form_group.go
  21. 1
      models/modelAppPlatform/customer_form_version.go
  22. 5
      models/modelAppPlatform/customer_form_view.go
  23. 1
      overall/publicmethod/errorCode.go
  24. 143
      overall/publicmethod/technique.go
  25. 6
      overall/publicmethod/type.go

37
api/shiyan/maptostruct/shiyan.go

@ -222,10 +222,13 @@ type canshuzhi interface{}
// 接收参数
func (A *ApiMethod) Canshu(c *gin.Context) {
// var zhi canshuzhi
zhi, _ := c.GetRawData()
// var db *gorm.DB
// err := db.QueryFields
// overall.CONSTANT_DB_AppPlatform.Take.Title
// // var zhi canshuzhi
// zhi, _ := c.GetRawData()
fmt.Printf("%T------------->%v\n", zhi, string(zhi))
// fmt.Printf("%T------------->%v\n", zhi, string(zhi))
}
/*
@ -543,3 +546,31 @@ func (a *ApiMethod) CreateFlowChart(c *gin.Context) {
sendData["workFlowInfo"] = workFlowInfo
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-08 10:47:40
@ 功能: 获取行政组织所有子类
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GetAllOrgSun(c *gin.Context) {
var requestData publicmethod.CommonId[int64]
c.ShouldBindJSON(&requestData)
if requestData.Id == 0 {
requestData.Id = 309
}
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(requestData.Id)
publicmethod.Result(0, sunOrg.Id, c)
}

466
api/version1/customerform/codeFormGroup.go

@ -0,0 +1,466 @@
package customerform
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-03-06 13:28:08
@ 功能: 自定义表单分组列表树
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CustomerFormGroupTree(c *gin.Context) {
var requestData FormGroupArg
c.ShouldBindJSON(&requestData)
// err := c.ShouldBindJSON(&requestData)
// if err != nil {
// publicmethod.Result(100, err, c)
// return
// }
// var groupList []*publicmethod.CustomerFormGroupTree
var groupList []modelAppPlatform.CustomerFormGroup
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormGroup{})
if requestData.Name != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Name+"%")
}
if requestData.State != 0 {
gormDb = gormDb.Where("`state` = ?", requestData.State)
} else {
gormDb = gormDb.Where("`state` IN ?", []int{1, 2})
}
if requestData.OrgId != "" && requestData.OrgId != "0" {
gormDb = gormDb.Where("`ordid` = ?", requestData.OrgId)
}
if requestData.Superior != "" && requestData.Superior != "0" {
var sunGroupId publicmethod.GetOrgAllParent
superiorId, _ := strconv.ParseInt(requestData.Superior, 10, 64)
sunGroupId.GetFormGroupSun(superiorId)
if len(sunGroupId.Id) < 1 {
gormDb = gormDb.Where("`superior` = ?", -1)
} else {
gormDb = gormDb.Where("`superior` IN ?", sunGroupId.Id)
}
}
err := gormDb.Order("`sort` DESC").Find(&groupList).Error
if err != nil {
publicmethod.Result(106, err, c)
return
}
groupTree := publicmethod.CustFormGroupTree(0, groupList)
publicmethod.Result(0, groupTree, c)
}
/**
@ 作者: 秦东
@ 时间: 2024-03-19 08:23:44
@ 功能: 自定义分组列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
// func (){}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-07 08:55:42
@ 功能: 自定义表单分组列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CustomerFormGroupList(c *gin.Context) {
var requestData FormGroupArgList
c.ShouldBindJSON(&requestData)
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 15
}
var groupList []SendFormGroupInfo
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormGroup{})
if requestData.Name != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Name+"%")
}
if requestData.State != 0 {
gormDb = gormDb.Where("`state` = ?", requestData.State)
} else {
gormDb = gormDb.Where("`state` IN ?", []int{1, 2})
}
if requestData.OrgId != "" && requestData.OrgId != "0" {
gormDb = gormDb.Where("`ordid` = ?", requestData.OrgId)
}
if requestData.Superior != "" && requestData.Superior != "0" {
var sunGroupId publicmethod.GetOrgAllParent
superiorId, _ := strconv.ParseInt(requestData.Superior, 10, 64)
sunGroupId.GetFormGroupSun(superiorId)
if len(sunGroupId.Id) < 1 {
gormDb = gormDb.Where("`superior` = ?", -1)
} else {
gormDb = gormDb.Where("`superior` IN ?", sunGroupId.Id)
}
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`sort` ASC").Order("`id` DESC").Find(&groupList).Error
if err != nil {
publicmethod.Result(106, err, c)
return
}
for i, v := range groupList {
groupList[i].IdStr = strconv.FormatInt(v.Id, 10)
}
// publicmethod.Result(0, groupList, c)
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(groupList)), groupList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-06 15:10:52
@ 功能:添加自定义表单分组
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AddCustomerFormGroup(c *gin.Context) {
var requestData AddFormGroup
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Title == "" {
publicmethod.Result(101, err, c)
return
}
if requestData.Sort == 0 {
requestData.Sort = 50
}
var groupInfo modelAppPlatform.CustomerFormGroup
err = groupInfo.GetCont(map[string]interface{}{"`title`": requestData.Title}, "`id`")
if err == nil || groupInfo.Id != 0 {
publicmethod.Result(103, err, c)
return
}
groupInfo.Id = onlyoenUUID(publicmethod.GetUUid(1))
groupInfo.Title = requestData.Title
groupInfo.Superior = 0
groupInfo.Sort = requestData.Sort
groupInfo.Ordid = 0
groupInfo.State = 1
groupInfo.Icon = requestData.Icon
groupInfo.Time = time.Now().Unix()
err = overall.CONSTANT_DB_AppPlatform.Create(&groupInfo).Error
if err != nil {
publicmethod.Result(100, err, c)
return
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-08 08:16:33
@ 功能: 确保添加时uuid唯一
*/
func onlyoenUUID(uuId int64) int64 {
var groupInfo modelAppPlatform.CustomerFormGroup
err := groupInfo.GetCont(map[string]interface{}{"`id`": uuId}, "`id`")
if err == nil {
uId := publicmethod.GetUUid(1)
return onlyoenUUID(uId)
}
return uuId
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-07 08:59:59
@ 功能: 改变自定义表单分组内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditCustomerFormGroup(c *gin.Context) {
var requestData EditFormGroup
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(102, err, c)
return
}
if requestData.Title == "" {
publicmethod.Result(101, err, c)
return
}
var groupInfo modelAppPlatform.CustomerFormGroup
err = groupInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
saveInfo := publicmethod.MapOut[string]()
if groupInfo.Title != requestData.Title {
var groupInfoJuadge modelAppPlatform.CustomerFormGroup
err = groupInfoJuadge.GetCont(map[string]interface{}{"`title`": requestData.Title}, "`id`")
if err == nil || groupInfoJuadge.Id != 0 {
publicmethod.Result(103, err, c)
return
}
saveInfo["`title`"] = requestData.Title
}
if requestData.Sort != 0 && requestData.Sort != groupInfo.Sort {
saveInfo["`sort`"] = requestData.Sort
}
if requestData.Icon != "" && requestData.Icon != groupInfo.Icon {
saveInfo["`icon`"] = requestData.Icon
}
if len(saveInfo) > 0 {
saveInfo["`time`"] = time.Now().Unix()
var groupEditInfo modelAppPlatform.CustomerFormGroup
err = groupEditInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveInfo)
if err != nil {
publicmethod.Result(106, err, c)
return
}
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-08 08:09:17
@ 功能: 改变自定义表单分组状态
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditFormGroupState(c *gin.Context) {
var requestData publicmethod.PublicStates
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(102, err, c)
return
}
if requestData.Status == 0 {
requestData.Status = 2
}
var groupInfo modelAppPlatform.CustomerFormGroup
err = groupInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`state`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
saveInfo := publicmethod.MapOut[string]()
if requestData.Status != groupInfo.State {
saveInfo["`state`"] = requestData.Status
saveInfo["`time`"] = time.Now().Unix()
var groupEditInfo modelAppPlatform.CustomerFormGroup
err = groupEditInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveInfo)
if err != nil {
publicmethod.Result(106, err, c)
return
}
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-08 08:21:14
@ 功能: 强制删除(慎重操作一旦执行不可恢复)
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) DelFormGroup(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 groupInfo modelAppPlatform.CustomerFormGroup
err = groupInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`state`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
var custFormIdAry []modelAppPlatform.CustomerForm
err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`groupid` = ?", requestData.Id).Find(&custFormIdAry).Error
var oldCustForm []modelAppPlatform.CustomerForm
var oldCustFormVersion []modelAppPlatform.CustomerFormVersion
var workForm []modelAppPlatform.WorkFlow
var workFormVersion []modelAppPlatform.WorkFlowVersion
var formId []int64
var formVersionKey []string
var flowKey []int64
if err == nil {
for _, v := range custFormIdAry {
if v.Id != 0 && !publicmethod.IsInTrue[int64](v.Id, formId) {
formId = append(formId, v.Id)
}
if v.TableNames != "" && !publicmethod.IsInTrue[string](v.TableNames, formVersionKey) {
formVersionKey = append(formVersionKey, v.TableNames)
}
if v.FlowKey != 0 && !publicmethod.IsInTrue[int64](v.FlowKey, flowKey) {
flowKey = append(flowKey, v.FlowKey)
}
if len(formId) > 0 {
overall.CONSTANT_DB_AppPlatform.Where("`id IN ?", formId).Find(&oldCustForm)
overall.CONSTANT_DB_AppPlatform.Where("`id IN ?", formId).Delete(&modelAppPlatform.CustomerForm{})
}
if len(formVersionKey) > 0 {
overall.CONSTANT_DB_AppPlatform.Where("`tablekey` IN ?", formVersionKey).Find(&oldCustFormVersion)
overall.CONSTANT_DB_AppPlatform.Where("`tablekey` IN ?", formVersionKey).Delete(&modelAppPlatform.CustomerFormVersion{})
}
if len(flowKey) > 0 {
overall.CONSTANT_DB_AppPlatform.Where("`id IN ?", flowKey).Find(&workForm)
overall.CONSTANT_DB_AppPlatform.Where("`key IN ?", flowKey).Find(&workFormVersion)
overall.CONSTANT_DB_AppPlatform.Where("`id IN ?", flowKey).Delete(&modelAppPlatform.WorkFlow{})
overall.CONSTANT_DB_AppPlatform.Where("`key IN ?", flowKey).Delete(&modelAppPlatform.WorkFlowVersion{})
}
}
}
var delGroupInfo modelAppPlatform.CustomerFormGroup
err = delGroupInfo.DelCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
if len(formId) > 0 {
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Save(&oldCustForm)
}
if len(formVersionKey) > 0 {
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormVersion{}).Save(&oldCustFormVersion)
}
if len(flowKey) > 0 {
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.WorkFlow{}).Save(&workForm)
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.WorkFlowVersion{}).Save(&workFormVersion)
}
publicmethod.Result(107, err, c)
return
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-09 10:12:00
@ 功能: 查看分组详情
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainFormGroupInfo(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 groupInfo SendFormGroupInfo
err = groupInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
groupInfo.IdStr = strconv.FormatInt(groupInfo.Id, 10)
publicmethod.Result(0, groupInfo, c)
}

87
api/version1/customerform/form.go

@ -34,22 +34,27 @@ import (
*/
func (a *ApiMethod) CustomerFormList(c *gin.Context) {
var requestData SearchForm
ersr := c.ShouldBindJSON(&requestData)
// ersr := c.ShouldBindJSON(&requestData)
c.ShouldBindJSON(&requestData)
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 15
}
fmt.Printf("requestData---->%v---->%v\n", requestData, ersr)
var formList []modelAppPlatform.CustomerForm
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Select("`id`,`name`,`tablename`,`classify`,`permit`,`states`,`creater_time`,`flowkey`").Where("`states` BETWEEN ? AND ?", 1, 2)
// fmt.Printf("requestData---->%v---->%v\n", requestData, ersr)
// var formList []modelAppPlatform.CustomerForm
var formList []SendCustomerForm
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`states` BETWEEN ? AND ?", 1, 2)
if requestData.KeyWords != "" {
gormDb = gormDb.Where("`name` LIKE ? OR `tablename` LIKE ?", "%"+requestData.KeyWords+"%", "%"+requestData.KeyWords+"%")
}
if requestData.Classify != 0 {
gormDb = gormDb.Where("`classify` = ?", requestData.Classify)
}
if requestData.GroupId != "" {
gormDb = gormDb.Where("`groupid` = ?", requestData.GroupId)
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
@ -61,24 +66,26 @@ func (a *ApiMethod) CustomerFormList(c *gin.Context) {
publicmethod.Result(0, err, c)
return
}
var sendList []SendCustomerForm
for _, v := range formList {
var sendCont SendCustomerForm
sendCont.Id = strconv.FormatInt(v.Id, 10)
sendCont.Name = v.Name
sendCont.TableNames = v.TableNames
sendCont.States = v.States
sendCont.Classify = v.Classify
// var sendList []SendCustomerForm
for i, v := range formList {
// var sendCont SendCustomerForm
// sendCont.IdStr = strconv.FormatInt(v.Id, 10)
userCont := HaveCustomerFormCreaterUs(v.TableNames)
sendCont.CreaterName = userCont.Name
sendCont.CreaterTime = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
// sendCont.CreaterName = userCont.Name
// sendCont.CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
if v.FlowKey != 0 {
sendCont.FlowKey = strconv.FormatInt(v.FlowKey, 10)
// sendCont.FlowKeyStr = strconv.FormatInt(v.FlowKey, 10)
formList[i].FlowKeyStr = strconv.FormatInt(v.FlowKey, 10)
}
sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
formList[i].IdStr = strconv.FormatInt(v.Id, 10)
formList[i].CreaterName = userCont.Name
formList[i].CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
var versionInfo modelAppPlatform.CustomerFormVersion
versionInfo.GetCont(map[string]interface{}{"`status`": 1, "`tablekey`": v.TableNames}, "`id`")
formList[i].VersionId = strconv.FormatInt(versionInfo.Id, 10)
// sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
}
/*
@ -211,6 +218,9 @@ func (a *ApiMethod) SaveCustomerForm(c *gin.Context) {
customerFormCont.EditTime = cureeTime //编辑时间"`
// customerFormCont.TableStructure = "" //字表结构"`
// customerFormCont.Dict = requestData.Dict
customerFormCont.Icon = formJsonCont.Config.ImageUrl
groupId, _ := strconv.ParseInt(formJsonCont.Config.GroupKey, 10, 64)
customerFormCont.Groupid = groupId
var formVersion modelAppPlatform.CustomerFormVersion
formVersion.TableKey = formJsonCont.Form.Name //default:'';not null;comment:表单标识符"`
@ -236,7 +246,7 @@ func (a *ApiMethod) SaveCustomerForm(c *gin.Context) {
createDb := overall.CONSTANT_DB_AppPlatform.Begin()
errMain := createDb.Create(&customerFormCont).Error
errVer := createDb.Create(&formVersion).Error
sendErr := publicmethod.MapOut[string]()
if errMain != nil || errVer != nil {
createDb.Rollback()
sendErr := publicmethod.MapOut[string]()
@ -246,13 +256,15 @@ func (a *ApiMethod) SaveCustomerForm(c *gin.Context) {
return
}
err = createDb.Commit().Error
sendErr["err"] = err
sendErr["customerFormCont"] = customerFormCont
sendErr["formVersion"] = formVersion
// err = createDb.Create(&customerFormCont).Error
// if err != nil {
// publicmethod.Result(104, customerFormCont, c)
// return
// }
publicmethod.Result(0, err, c)
publicmethod.Result(0, sendErr, c)
}
/*
@ -340,7 +352,9 @@ func (a *ApiMethod) LookCustomerForm(c *gin.Context) {
sendCont.TableStructure = formVersion.TableStructure //字表结构"`
sendCont.Dict = formVersion.Dict //字表结构"`
sendCont.Status = formVersion.Status //显示状态(1:启用;2:禁用,3:删除)"`
sendCont.GroupKey = strconv.FormatInt(customerFormCont.Groupid, 10)
sendCont.Icon = customerFormCont.Icon
sendCont.FlowIsOpen = customerFormCont.FlowIsOpen
json.Unmarshal([]byte(customerFormCont.Permit), &sendCont.PermitList)
publicmethod.Result(0, sendCont, c)
}
@ -644,7 +658,7 @@ func CreateFormFiled(formName, formNotes string, isMasters bool, sqlList interfa
// 协程执行mysql语句
func CoroutineExecuteSql(k int, sql string) {
fmt.Printf("%v---------->%v\n", k, sql)
// fmt.Printf("%v---------->%v\n", k, sql)
defer syncSeting.Done()
overall.CONSTANT_DB_CustomerForm.Exec(sql)
// overall.CONSTANT_DB_CustomerForm.Raw(sql)
@ -679,12 +693,12 @@ func CreateForm(formName, notes, engine string, isMasters bool) (err error) {
if !isTrue { //当数据表不存在时进行创建
if isMasters {
//创建主表
sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`flow_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程识别标识',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,UNIQUE KEY `masters_key` (`masters_key`) USING HASH) ENGINE=%v DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, engine, notes)
sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`flow_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程识别标识',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',`flowIsOpen` int(1) unsigned NOT NULL DEFAULT '2' COMMENT '是否开启工作流',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,UNIQUE KEY `masters_key` (`masters_key`) USING HASH) ENGINE=%v DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, engine, notes)
err = overall.CONSTANT_DB_CustomerForm.Exec(sqlCreateTable).Error
} else {
//创建子表
sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,KEY `masters_key` (`masters_key`) USING HASH) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, notes)
sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,KEY `masters_key` (`masters_key`) USING HASH) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, notes)
err = overall.CONSTANT_DB_CustomerForm.Exec(sqlCreateTable).Error
}
}
@ -942,6 +956,11 @@ func (a *ApiMethod) EditCustomerFormInfo(c *gin.Context) {
mainData["`name`"] = formJsonCont.Form.FormName
mainData["`classify`"] = requestData.Classify
mainData["`edit_time`"] = cureeTime
if formJsonCont.Config.ImageUrl != "" {
mainData["`icon`"] = formJsonCont.Config.ImageUrl
}
groupId, _ := strconv.ParseInt(formJsonCont.Config.GroupKey, 10, 64)
mainData["`groupid`"] = groupId
customerFormCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, mainData)
versionData := publicmethod.MapOut[string]()
versionData["`mastesform`"] = requestData.Data
@ -1013,6 +1032,20 @@ func (a *ApiMethod) SaveAsNewVersion(c *gin.Context) {
publicmethod.Result(107, err, c)
return
}
mainData := publicmethod.MapOut[string]()
if formJsonCont.Config.ImageUrl != "" {
mainData["`icon`"] = formJsonCont.Config.ImageUrl
}
if formJsonCont.Config.GroupKey != "" {
groupId, _ := strconv.ParseInt(formJsonCont.Config.GroupKey, 10, 64)
mainData["`groupid`"] = groupId
}
if len(mainData) > 0 {
mainData["`edit_time`"] = cureeTime
customerFormCont.EiteCont(map[string]interface{}{"`id`": customerFormCont.Id}, mainData)
}
var formVersion modelAppPlatform.CustomerFormVersion
formVersion.TableKey = customerFormCont.TableNames //default:'';not null;comment:表单标识符"`
varsionNum := HageFormVersionNum(customerFormCont.TableNames)
@ -1037,7 +1070,7 @@ func (a *ApiMethod) SaveAsNewVersion(c *gin.Context) {
publicmethod.Result(104, customerFormCont, c)
return
}
publicmethod.Result(0, err, c)
publicmethod.Result(0, formVersion, c)
}
/*

791
api/version1/customerform/formTable.go

@ -1,11 +1,19 @@
package customerform
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
/*
@ -560,3 +568,786 @@ func (f *FormUnitInfo) GainMasterAndSunFormUnitNameKey() (mastNameKey map[string
// fmt.Printf("自定义表单结果值!tableName:%v---->%T\n", sunTypeAry, sunTypeAry)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-26 13:46:27
@ 功能: 获取数据库表字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainTableField(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, "未知表单!无法获取字段!")
return
}
var customerFormMaster modelAppPlatform.CustomerFormView
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
masterTable, err := GainFormTableField(customerFormMaster.TableKey)
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
sendTableList := publicmethod.MapOut[string]()
sendTableList["masterTable"] = masterTable
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
var sunTable map[string]interface{}
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
if err == nil {
sunTableMap := publicmethod.MapOut[string]()
for _, v := range sunTable { //遍历子表单名称
if vStr, ok := v.(string); ok {
sunTableMap[vStr], err = GainFormTableField(vStr)
}
}
sendTableList["sunTable"] = sunTableMap
}
}
publicmethod.Result(0, sendTableList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-20 15:09:59
@ 功能: 获取表格字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainFormTableField(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, "未知表单!无法获取字段!")
return
}
var customerFormMaster modelAppPlatform.CustomerFormView
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
masterTable, err := GainFormTableField(customerFormMaster.TableKey)
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
var unitCont map[string]interface{}
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &unitCont)
var formFieldAry FormJsonFieldInfo
if list, ok := unitCont["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
formFieldAry.AnalyzingFormJson("", listAry)
}
}
sendTableList := publicmethod.MapOut[string]()
if len(formFieldAry.MasterInfo) > 0 {
sendTableList["masterTable"] = TableFieldCompare(masterTable, formFieldAry.MasterInfo)
} else {
sendTableList["masterTable"] = masterTable
}
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
var sunTable map[string]interface{}
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
if err == nil {
sunTableMap := publicmethod.MapOut[string]()
for _, v := range sunTable { //遍历子表单名称
if vStr, ok := v.(string); ok {
sunField := GainSunFormTableField(vStr, formFieldAry.SunFormInfo)
if len(sunField) > 0 {
sunTableForm, formErr := GainFormTableField(vStr)
if formErr == nil {
sunTableMap[vStr] = TableFieldCompare(sunTableForm, sunField)
} else {
sunTableMap[vStr], _ = GainFormTableField(vStr) //获取表单字段
}
} else {
sunTableMap[vStr], _ = GainFormTableField(vStr) //获取表单字段
}
}
}
sendTableList["sunTable"] = sunTableMap
}
}
publicmethod.Result(0, sendTableList, c)
}
// 获取子表表单数据
func GainSunFormTableField(tableName string, SunFormInfo []SunFormFieldInfoList) (fieldList []FormFieldInfo) {
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-25 09:01:12
@ 功能: 表单数据对照
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func TableFieldCompare(tableFieldList []Result, jsonFieldList []FormFieldInfo) (fieldList []FormFieldInfo) {
if len(tableFieldList) > 0 {
if len(jsonFieldList) > 0 {
var writeTableField []string
for _, tv := range tableFieldList {
for _, jv := range jsonFieldList {
if tv.Field == jv.Id {
if !publicmethod.IsInTrue[string](tv.Field, writeTableField) {
writeTableField = append(writeTableField, tv.Field)
}
var fieldInfo FormFieldInfo
fieldInfo.Id = jv.Id
if tv.Comment == "" {
fieldInfo.Label = jv.Label
} else {
fieldInfo.Label = tv.Comment
}
fieldInfo.Field = tv.Field //field"`
attFiled := strings.Split(tv.Type, " ")
fmt.Printf("attFiled---->%v=========>%v\n", tv.Type, attFiled)
if len(attFiled) > 0 {
fieldInfo.Types = attFiled[0]
}
if len(attFiled) >= 2 {
fieldInfo.Attribute = attFiled[1]
}
patternInfo := strings.Split(tv.Type, "(")
if len(patternInfo) >= 1 {
fieldInfo.Pattern = patternInfo[0]
}
fieldInfo.FieldClass = jv.FieldClass //fieldClass"`
fieldInfo.ActiveValue = jv.ActiveValue //activeValue"`
fieldInfo.InactiveValue = jv.InactiveValue //inactiveValue"`
fieldInfo.Options = jv.Options //options"`
fieldList = append(fieldList, fieldInfo)
}
}
}
if len(writeTableField) > 0 {
for _, tv := range tableFieldList {
if !publicmethod.IsInTrue[string](tv.Field, writeTableField) {
var fieldInfo FormFieldInfo
fieldInfo.Id = tv.Field
if tv.Comment == "" {
fieldInfo.Label = tv.Field
} else {
fieldInfo.Label = tv.Comment
}
fieldInfo.Field = tv.Field //field"`
attFiled := strings.Split(tv.Type, " ")
if len(attFiled) > 0 {
fieldInfo.Types = attFiled[0]
}
if len(attFiled) >= 2 {
fieldInfo.Attribute = attFiled[1]
}
patternInfo := strings.Split(tv.Type, "(")
if len(patternInfo) >= 1 {
fieldInfo.Pattern = patternInfo[0]
}
fieldInfo.FieldClass = tv.Field //fieldClass"`
// fieldInfo.ActiveValue = v. //activeValue"`
// fieldInfo.InactiveValue = v. //inactiveValue"`
// fieldInfo.Options = v. //options"`
fieldList = append(fieldList, fieldInfo)
}
}
for _, jv := range jsonFieldList {
if !publicmethod.IsInTrue[string](jv.Id, writeTableField) {
fieldList = append(fieldList, jv)
}
}
}
} else {
for _, v := range tableFieldList {
var fieldInfo FormFieldInfo
fieldInfo.Id = v.Field
fieldInfo.Label = v.Comment
fieldInfo.Field = v.Field //field"`
attFiled := strings.Split(v.Type, " ")
if len(attFiled) >= 2 {
fieldInfo.Attribute = attFiled[1]
fieldInfo.Types = attFiled[0]
}
patternInfo := strings.Split(v.Type, "(")
if len(patternInfo) >= 1 {
fieldInfo.Pattern = patternInfo[0]
}
// fieldInfo.FieldClass = v. //fieldClass"`
// fieldInfo.ActiveValue = v. //activeValue"`
// fieldInfo.InactiveValue = v. //inactiveValue"`
// fieldInfo.Options = v. //options"`
fieldList = append(fieldList, fieldInfo)
}
}
} else {
fieldList = jsonFieldList
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-22 09:00:27
@ 功能: 获取表单字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func GainFormTableField(formTableName string) (fieldList []Result, err error) {
gormDb := overall.CONSTANT_DB_CustomerForm
sqlStr := fmt.Sprintf("SHOW FULL COLUMNS FROM `%v`", formTableName)
err = gormDb.Raw(sqlStr).Scan(&fieldList).Error
if err != nil {
return
}
for i, v := range fieldList {
attFiled := strings.Split(v.Type, " ")
if len(attFiled) >= 2 {
fieldList[i].Attribute = attFiled[1]
fieldList[i].Type = attFiled[0]
}
patternInfo := strings.Split(v.Type, "(")
if len(patternInfo) >= 1 {
fieldList[i].Pattern = patternInfo[0]
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-23 15:15:17
@ 功能: 解析表单字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []interface{}) {
if len(unitList) > 0 {
var fieldInfo []FormFieldInfo
for _, listVal := range unitList {
if listInfo, ok := listVal.(map[string]interface{}); ok {
if unitType, ok := listInfo["type"]; ok {
var unitInfo FormFieldInfo
if unitName, ok := listInfo["name"]; ok {
if unitNameStr, ok := unitName.(string); ok {
unitInfo.Id = unitNameStr
}
}
if itemVal, ok := listInfo["item"]; ok {
if itemInfo, ok := itemVal.(map[string]interface{}); ok {
if itemName, ok := itemInfo["label"]; ok {
if itemNameStr, ok := itemName.(string); ok {
unitInfo.Label = itemNameStr
}
}
}
}
switch unitType {
case "flex", "table":
if list, ok := listInfo["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
f.AnalyzingFormJson(unitInfo.Id, listAry)
}
}
case "grid", "tabs":
if list, ok := listInfo["columns"]; ok {
if listAry, ok := list.([]interface{}); ok {
for _, colVal := range listAry {
if colList, ok := colVal.(map[string]interface{}); ok {
if listMap, ok := colList["list"]; ok {
if colListAry, ok := listMap.([]interface{}); ok {
f.AnalyzingFormJson(unitInfo.Id, colListAry)
}
}
}
}
}
}
case "card", "div":
case "title", "txt", "button":
default:
if unitTypeStr, ok := unitType.(string); ok {
unitInfo.FieldClass = unitTypeStr
}
// fmt.Printf("unitList---->%T====>%v\n", listInfo["control"], listInfo["control"])
if controlVal, ok := listInfo["control"]; ok {
if controlMap, ok := controlVal.(map[string]interface{}); ok {
if activeVal, ok := controlMap["activeValue"]; ok {
if activeValStr, ok := activeVal.(string); ok {
unitInfo.ActiveValue = activeValStr
}
}
if InactiveVal, ok := controlMap["inactiveValue"]; ok {
if InactiveValStr, ok := InactiveVal.(string); ok {
unitInfo.InactiveValue = InactiveValStr
}
}
}
}
if optionsVal, ok := listInfo["options"]; ok {
if optionsMap, ok := optionsVal.([]interface{}); ok {
for _, optv := range optionsMap {
if optvMap, ok := optv.(map[string]interface{}); ok {
var optInfo OptionsInfo
fmt.Printf("optvMap---->%T====>%v\n", optvMap["label"], optvMap["label"])
if labelVal, ok := optvMap["label"]; ok {
if labelValStr, ok := labelVal.(string); ok {
optInfo.Label = labelValStr
}
}
if valueVal, ok := optvMap["value"]; ok {
if valueValStr, ok := valueVal.(string); ok {
optInfo.Value = valueValStr
}
}
unitInfo.Options = append(unitInfo.Options, optInfo)
}
}
}
}
fieldInfo = append(fieldInfo, unitInfo)
}
}
}
}
if len(fieldInfo) > 0 {
if tableName != "" {
if len(f.SunFormInfo) > 0 {
isNewData := true
for i, v := range f.SunFormInfo {
if v.TableName == tableName {
f.SunFormInfo[i].UbitInfo = append(f.SunFormInfo[i].UbitInfo, fieldInfo...)
isNewData = false
}
}
if isNewData {
var sunFormInfo SunFormFieldInfoList
sunFormInfo.TableName = tableName
sunFormInfo.UbitInfo = fieldInfo
f.SunFormInfo = append(f.SunFormInfo, sunFormInfo)
}
} else {
var sunFormInfo SunFormFieldInfoList
sunFormInfo.TableName = tableName
sunFormInfo.UbitInfo = fieldInfo
f.SunFormInfo = append(f.SunFormInfo, sunFormInfo)
}
} else {
f.MasterInfo = append(f.MasterInfo, fieldInfo...)
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-29 16:43:17
@ 功能: 编辑自定义表单列表数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditCustomerFormList(c *gin.Context) {
var requestData EditCustFormList
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2")
return
}
if requestData.Data == "" {
publicmethod.Result(1, err, c, "未知列表数据!无法获取字段!1")
return
}
var customerFormInfo modelAppPlatform.CustomerForm
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`listjson`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!3")
return
}
editInfo := publicmethod.MapOut[string]()
editInfo["listjson"] = requestData.Data
editInfo["edit_time"] = time.Now().Unix()
err = customerFormInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, editInfo)
if err != nil {
publicmethod.Result(1, err, c, "编辑失败!请重新提交!")
return
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-01 08:34:08
@ 功能: 获取表单列表数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainFormListCont(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, "未知表单!无法获取字段!2")
return
}
var customerFormInfo modelAppPlatform.CustomerForm
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!3")
return
}
publicmethod.Result(0, customerFormInfo, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-01 16:03:50
@ 功能:获取表单列表翻页数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
var requestData FormPageListAttr
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.FormId == "" {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2")
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.Page = 20
}
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
}
// why, err := AnalysisSerachTerm(requestData.SearchData)
// fmt.Printf("why---->%v\n", why)
var formList []map[string]interface{}
gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey)
// gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey).Where("`states` BETWEEN ? AND ?", 1, 2)
// if err == nil {
// gormDb = gormDb.Where(why)
// }
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)
err = gormDb.Order("`id` DESC").Find(&formList).Error
if err != nil && len(formList) < 1 {
publicmethod.Result(0, err, c)
return
}
// for i, _ := range formList {
// // formList[i]["flowIsOpen"] = formInfo.FlowIsOpen
// formList[i]["flowkey"] = strconv.FormatInt(formInfo.Flowkey, 10)
// }
if formInfo.ListJson != "" {
var listFieldsMap ListPageFields
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap)
if err == nil {
// fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap)
formList = listFieldsMap.DevelopSpecificationsSend(formList)
// formList = DevelopSpecificationsSend(formList, listFieldsMap)
}
}
// publicmethod.Result(100, formList, c)
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 08:14:10
@ 功能: 按照制定列表字段输出
*/
func (l *ListPageFields) DevelopSpecificationsSend(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[mi] = myInfo.Name
case "creater_time":
timeInt, _ := publicmethod.StringToInt64(mv)
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
case "edit_time":
timeInt, _ := publicmethod.StringToInt64(mv)
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
default:
sendInfo[mi] = l.BaseTableAttrField(mi, mv)
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
}
}
fmt.Printf("================================\n")
sendList = append(sendList, sendInfo)
}
return sendList
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 11:42:20
@ 功能: 根据字段显示格式处理数据
*/
func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interface{} {
if len(l.TableData.Columns) < 0 {
return val
}
for _, v := range l.TableData.Columns {
if v.Id == key {
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 orgCont.Name
case "baidumap":
var mapAry []string
if valStr, ok := val.(string); ok {
mapAry = strings.Split(valStr, "|*@*|")
}
if len(mapAry) > 0 {
return mapAry[0]
}
default:
return publicmethod.TypeToInterface(val)
}
}
}
return publicmethod.TypeToInterface(val)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-01 16:16:28
@ 功能: 拆析查询条件
*/
func AnalysisSerachTerm(why string) (whereMap map[string]interface{}, err error) {
err = nil
if why == "" {
return
}
var listField []SearchButtonInfo
err = json.Unmarshal([]byte(why), &listField)
if err != nil {
return
}
whyMap := publicmethod.MapOut[string]()
for _, v := range listField {
// fmt.Printf("%v: %v\n", v.Field, v.Values)
if v.Values != nil && v.Values != "" {
whyMap[v.Field] = v.Values
}
}
if len(whyMap) < 1 {
err = errors.New("没有要查询的内容!")
return
}
whereMap = whyMap
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 13:26:45
@ 功能: 查询条件
*/
func AnalysisSerachTermSql(why string, gormDb *gorm.DB) *gorm.DB {
if why == "" {
return gormDb
}
var listField []SearchButtonInfo
err := json.Unmarshal([]byte(why), &listField)
if err != nil {
return gormDb
}
for _, v := range listField {
if v.Values != nil && v.Values != "" && v.Values != "" {
switch v.Pattern {
case "int":
likeSql := fmt.Sprintf("`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
case "bigint":
likeSql := fmt.Sprintf("`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
default:
likeSql := fmt.Sprintf("%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'")
gormDb = gormDb.Where(likeSql)
}
}
}
return gormDb
}

50
api/version1/customerform/listField.go

@ -0,0 +1,50 @@
package customerform
type ListPageFields struct {
TableData TableDataInfo `json:"tableData"`
SearchData []SearchButtonInfo `json:"searchData"`
Loading bool `json:"loading"`
AttrObj interface{} `json:"attrObj"`
Config ConfigInfo `json:"config"`
TagList interface{} `json:"tagList"`
FormId interface{} `json:"formId"`
FormList []interface{} `json:"formList"`
Name string `json:"name"`
TreeData interface{} `json:"treeData"`
PreviewVisible bool `json:"previewVisible"`
TabsName string `json:"tabsName"`
FormFieldList []interface{} `json:"formFieldList"`
FormApi FormApiInfor `json:"formApi"`
Dict interface{} `json:"dict"`
RefreshTable bool `json:"refreshTable"`
}
type FormApiInfor struct {
Type string `json:"type"`
AddApiUrl string `json:"addApiUrl"`
EditApiUrl string `json:"editApiUrl"`
DelApiUrl string `json:"delApiUrl"`
LookApiUrl string `json:"lookApiUrl"`
}
type ConfigInfo struct {
SearchIsShow bool `json:"searchIsShow"`
SearchFormIsShow bool `json:"searchFormIsShow"`
OpenPageMode string `json:"openPageMode"`
PageSize int `json:"pageSize"`
}
type TableDataInfo struct {
Columns []SearchButtonInfo `json:"columns"`
Config interface{} `json:"config"`
ControlBtn []controlBtnInfo `json:"controlBtn"`
OperateBtn []controlBtnInfo `json:"operateBtn"`
}
type controlBtnInfo struct {
Label string `json:"label"`
Key string `json:"key"`
Type string `json:"type"`
Size string `json:"size"`
Icon string `json:"icon"`
}

132
api/version1/customerform/type.go

@ -41,6 +41,7 @@ type CustomerFormMaster struct {
List []MasterStruct `json:"list"` //组件列表
Form FormStruct `json:"form"` //表单配置
Config ConfigStruct `json:"config"`
Icon string `json:"icon"` //图片
}
// 组件主体
@ -168,7 +169,9 @@ type FormStruct struct {
// 属性配置
type ConfigStruct struct {
AddLoad bool `json:"addLoad"`
AddLoad bool `json:"addLoad"`
ImageUrl string `json:"imageUrl"`
GroupKey string `json:"groupKey"`
}
// 搜索自定义表单
@ -176,18 +179,21 @@ type SearchForm struct {
publicmethod.PagesTurn
KeyWords string `json:"keywords"`
Classify int `json:"classify"`
GroupId string `json:"groupId"`
}
// 输出表单列表
type SendCustomerForm struct {
Id string `json:"id"`
Name string `json:"name"`
TableNames string `json:"tablename"`
States int `json:"states"`
Classify int `json:"classify"`
CreaterName string `json:"creatername"`
CreaterTime string `json:"creatertime"`
FlowKey string `json:"flowkey"`
modelAppPlatform.CustomerForm
IdStr string `json:"idStr" gorm:"-"`
// Name string `json:"name"`
// TableNames string `json:"tablename"`
// States int `json:"states"`
// Classify int `json:"classify"`
CreaterName string `json:"creatername" gorm:"-"`
CreaterTimeStr string `json:"creatertimeStr" gorm:"-"`
FlowKeyStr string `json:"flowkeyStr" gorm:"-"`
VersionId string `json:"versionId" gorm:"-"`
}
// 输出自定义表格基础信息
@ -218,6 +224,7 @@ type EditCustomerFormStatus struct {
type LookCustomerFormInfo struct {
modelAppPlatform.CustomerFormView
States int `json:"states"`
GroupKey string `json:"groupKey"`
PermitList [][]int64 `json:"permit_list"`
}
@ -242,12 +249,14 @@ type Result struct {
Type string `json:"type"`
Attribute string `json:"attribute"`
Collation string `json:"collation"`
Null string `json:"null"`
Null string `json:"nullVal"`
Key string `json:"key"`
Default string `json:"default"`
Default string `json:"defaultVal"`
Extra string `json:"extra"`
Privileges string `json:"privileges"`
Comment string `json:"comment"`
Pattern string `json:"pattern"`
Classify string `json:"classify"`
}
// 自定义表单数据结构版本及表单输出
@ -338,3 +347,104 @@ type SunFormInfoList struct {
TableName string //表名称
UbitInfo map[string]MasterStruct //相关组件
}
// 表单分组列表参数
type FormGroupArg struct {
publicmethod.PublicName
OrgId string `json:"orgid"`
Superior string `json:"superior"`
State int `json:"state"`
}
type FormGroupArgList struct {
publicmethod.PagesTurn
publicmethod.PublicName
OrgId string `json:"orgid"`
Superior string `json:"superior"`
State int `json:"state"`
}
// 自定义表单分组树
type CustomerFormGroupTree struct {
modelAppPlatform.CustomerFormGroup
Child []modelAppPlatform.CustomerFormGroup `json:"child"`
}
// 添加自定义表单分组
type AddFormGroup struct {
Title string `json:"title"` //分组名称
Sort int `json:"sort"` //排序
Icon string `json:"icon"` //图片
}
// 编辑自定义表单分组内容
type EditFormGroup struct {
publicmethod.PublicId
AddFormGroup
}
// 输出表单分组列表
type SendFormGroupInfo struct {
modelAppPlatform.CustomerFormGroup
IdStr string `json:"idStr" gorm:"-"`
VersionId string `json:"versionId" gorm:"-"`
}
// 自定义表单字段(解析对照用)
type FormFieldInfo struct {
publicmethod.PublicId
Label string `json:"label"`
Field string `json:"field"`
Types string `json:"type"`
Attribute string `json:"attribute"`
Pattern string `json:"pattern"`
FieldClass string `json:"fieldClass"`
ActiveValue string `json:"activeValue"`
InactiveValue string `json:"inactiveValue"`
Options []OptionsInfo `json:"options"`
}
type OptionsInfo struct {
Label string `json:"label"`
Value string `json:"value"`
}
// 分析表单Json字段
type FormJsonFieldInfo struct {
MasterInfo []FormFieldInfo //主表组件列表
SunFormInfo []SunFormFieldInfoList //子表
}
type SunFormFieldInfoList struct {
TableName string //表名称
UbitInfo []FormFieldInfo //相关组件
}
// 编辑自定义表单数据列表参数
type EditCustFormList struct {
publicmethod.PublicId
Data string `json:"data"`
}
// 自定义表单列表数据查询
type FormPageListAttr struct {
FormId string `json:"formId"`
publicmethod.PagesTurn
SearchData string `json:"searchData"`
}
// 查询按钮类型
type SearchButtonInfo struct {
Id string `json:"id"`
Name string `json:"name"`
Field string `json:"field"`
Types string `json:"type"`
Attribute string `json:"attribute"`
Pattern string `json:"pattern"`
FieldClass string `json:"fieldClass"`
ActiveValue string `json:"activeValue"`
InactiveValue string `json:"inactiveValue"`
Options []OptionsInfo `json:"options"`
Config string `json:"config"`
Label string `json:"label"`
IsSearch bool `json:"isSearch"`
Values interface{} `json:"value"`
}

48
api/version1/publicapi/api.go

@ -1,6 +1,7 @@
package publicapi
import (
"appPlatform/api/version1/taskplatform/taskflow"
"appPlatform/middleware/grocerystore"
"appPlatform/models/modelshr"
"appPlatform/models/modelsschool"
@ -204,9 +205,56 @@ func (a *ApiMethod) ChineseToPinyin(c *gin.Context) {
}
pyObject.Separator = requestData.Connector
str := pinyin.Slug(requestData.Title, pyObject)
if requestData.FormJson != "" {
var formCont map[string]interface{}
json.Unmarshal([]byte(requestData.FormJson), &formCont)
// taskflow.RecursionFormUnit
var formUnit taskflow.RecursionFormUnit
if list, ok := formCont["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
formUnit.AllUnitNodes("", listAry)
}
}
if len(formUnit.UnitAllKey) > 0 {
var oneName OnleyOneName
oneName.NameAry = formUnit.UnitAllKey
oneName.OneName(str)
str = oneName.Name
}
}
publicmethod.Result(0, str, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-13 13:59:47
@ 功能: 生成唯一名字识别符
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (o *OnleyOneName) OneName(name string) {
if publicmethod.IsInTrue[string](name, o.NameAry) {
newName := fmt.Sprintf("%v%v", name, publicmethod.GetRandNumber(5))
o.OneName(newName)
} else {
o.Name = name
o.NameAry = append(o.NameAry, name)
}
}
/*
*
@ 作者: 秦东

7
api/version1/publicapi/type.go

@ -26,6 +26,7 @@ type HanziToPinyin struct {
Title string `json:"title"` //中文语句
Types int `json:"types"` //转换风格 0:普通风格,不带声调(默认风格)。如: zhong guo;1:声调风格1,拼音声调在韵母第一个字母上。如: zhōng guó;2:声调风格2,即拼音声调在各个韵母之后,用数字 [1-4] 进行表示。如: zho1ng guo2;3:声母风格,只返回各个拼音的声母部分。如: zh g 。注意:不是所有的拼音都有声母;4:首字母风格,只返回拼音的首字母部分。如: z g;5: 韵母风格,只返回各个拼音的韵母部分,不带声调。如: ong uo;6:韵母风格1,带声调,声调在韵母第一个字母上。如: ōng uó;7:韵母风格2,带声调,声调在各个韵母之后,用数字 [1-4] 进行表示。如: o1ng uo2;8:声调风格3,即拼音声调在各个拼音之后,用数字 [1-4] 进行表示。如: zhong1 guo2;9:韵母风格3,带声调,声调在各个拼音之后,用数字 [1-4] 进行表示。如: ong1 uo2;
Connector string `json:"connector"` // Join 所用的分隔符
FormJson string `json:"formJson"` //当前表单内容
}
// 访问地址
@ -87,3 +88,9 @@ type SilentLoginInfo struct {
Time string `json:"time"`
Openid string `json:"openid"`
}
// 判断名称识别符不重复
type OnleyOneName struct {
publicmethod.PublicName
NameAry []string
}

51
api/version1/taskplatform/taskflow/types.go

@ -267,3 +267,54 @@ type FormDataLog struct {
NewData map[string]interface{}
OldData []map[string]interface{}
}
// 解析审批节点组件权限
type AnalysisNodesUnitPower struct {
NodeKey string `json:"nodeKey"`
NodeJson string `json:"nodeJson"`
UnitState []NodesUnitNameStatue `json:"unitState"`
}
// 类型断言解析组件
type TypesAnalysisNodesUnit struct {
UnitList map[string]interface{}
MasterUnitList []NodesUnitNameStatue `json:"masterUnitList"`
SunUnitList []SunNodesUnitNameStatue
}
type NodesUnitNameStatue struct {
publicmethod.PublicId
publicmethod.PublicName
publicmethod.PublicStatus
IsLook bool `json:"isLook"`
IsEdit bool `json:"isEdit"`
}
// 递归循环表单组件
type RecursionFormUnit struct {
MasterUnitList []NodesUnitNameStatue `json:"masterUnitList"`
SunUnitList []SunNodesUnitNameStatue `json:"sunUnitList"`
UnitAllKey []string `json:"unitAllKey"`
UnitAllState []NodesUnitNameStatue `json:"-"`
CurrentNodeName string `json:"-"`
NodePower []NodePowerInfo `json:"-"`
}
type SunNodesUnitNameStatue struct {
publicmethod.PublicName
UnitList []NodesUnitNameStatue `json:"masterUnitList"`
}
// 节点权限结构体
type NodePowerInfo struct {
NodeKey string `json:"nodeKey"`
PowerAry []NodesUnitNameStatue `json:"powerAry"`
}
// 编辑表单字段权限
type FlowFormPowerInfo struct {
FormKey string `json:"formKey"`
FormVersion string `json:"formVersion"`
FormData string `json:"formData"`
FormPower string `json:"formPower"`
}

592
api/version1/taskplatform/taskflow/workflow.go

@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
@ -245,3 +246,594 @@ func (f *CustomerFormUnit) GetFormUnit(tablename string, subUnitAry []customerfo
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-12 16:23:11
@ 功能: 判断是否已经存在工作流以及是否开启
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) JudgeFormFlowIsOpen(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil || requestData.Id == "" {
publicmethod.Result(100, err, c)
return
}
sendData := publicmethod.MapOut[string]()
var customerFormCont modelAppPlatform.CustomerForm
err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`flowkey`", "`flowIsOpen`")
if err != nil {
sendData["isOpen"] = 2
sendData["flowKey"] = customerFormCont.FlowKey
publicmethod.Result(106, sendData, c)
return
}
sendData["flowKey"] = customerFormCont.FlowKey
sendData["isOpen"] = customerFormCont.FlowIsOpen
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-12 16:27:46
@ 功能: 开启或关闭表单流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) OpenFormFlow(c *gin.Context) {
var requestData publicmethod.PublicStates
err := c.ShouldBindJSON(&requestData)
if err != nil || requestData.Id == "" {
publicmethod.Result(100, err, c)
return
}
if requestData.Status == 0 {
requestData.Status = 2
}
editData := publicmethod.MapOut[string]()
editData["flowIsOpen"] = requestData.Status
editData["edit_time"] = time.Now().Unix()
var customerFormCont modelAppPlatform.CustomerForm
err = customerFormCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, editData)
if err != nil {
publicmethod.Result(106, err, c)
return
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-13 09:28:40
@ 功能: 解析自定义表单组件
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AnalysisForm(c *gin.Context) {
var requestData AnalysisNodesUnitPower
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.NodeKey == "" {
requestData.NodeKey = "begin"
}
// var unitAry map[string]interface{}
// json.Unmarshal([]byte(requestData.NodeJson), &unitAry)
// if list, ok := unitAry["list"]; ok {
// fmt.Printf("list:%T--->%v\n", list, list)
// if listAry, ok := list.([]interface{}); ok {
// for i, v := range listAry {
// fmt.Printf("%v:%T\n", i, v)
// }
// }
// }
var unitCont TypesAnalysisNodesUnit
json.Unmarshal([]byte(requestData.NodeJson), &unitCont.UnitList)
// unitCont.AnalysisNodesUnit()
// var unitState []NodesUnitNameStatue
// json.Unmarshal([]byte(requestData.NodeJson), &unitState)
// var purview []map[string]interface{}
var recUnitAry RecursionFormUnit
recUnitAry.CurrentNodeName = requestData.NodeKey
// var nodePower []NodePowerInfo
if purviewList, ok := unitCont.UnitList["purview"]; ok {
if purviewAry, ok := purviewList.([]interface{}); ok {
// nodePower = SplitNodeUnitPurview(purviewAry)
recUnitAry.NodePower = SplitNodeUnitPurview(purviewAry)
}
}
// fmt.Printf("nodePower:%v\n", nodePower)
if list, ok := unitCont.UnitList["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
recUnitAry.AllUnitNodesAll("", listAry)
}
}
if len(recUnitAry.UnitAllState) > 0 {
recUnitAry.UnitAllState = QuChongUnit(recUnitAry.UnitAllState)
}
sendData := publicmethod.MapOut[string]()
sendData["nodeKey"] = requestData.NodeKey
sendData["recUnitAry"] = recUnitAry
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-14 08:38:32
@ 功能: 拆分节点已有得权限
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func SplitNodeUnitPurview(purviewAry []interface{}) (nodeUnitPowerAry []NodePowerInfo) {
jsonCont, jsonErr := json.Marshal(purviewAry)
// fmt.Printf("purviewList:%T--->%v--->%v\n", jsonCont, jsonErr, string(jsonCont))
if jsonErr == nil {
json.Unmarshal(jsonCont, &nodeUnitPowerAry)
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-13 15:40:43
@ 功能: 数组去重
*/
func QuChongUnit(unitList []NodesUnitNameStatue) []NodesUnitNameStatue {
var newAry []NodesUnitNameStatue
var unitKey []string
for _, v := range unitList {
if !publicmethod.IsInTrue[string](v.Id, unitKey) {
unitKey = append(unitKey, v.Id)
newAry = append(newAry, v)
}
}
return newAry
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-13 10:40:19
@ 功能: 自定义组件类型断言分解
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (t *TypesAnalysisNodesUnit) AnalysisNodesUnit() {
if list, ok := t.UnitList["list"]; ok {
// fmt.Printf("list:%T--->%v\n", list, list)
if listAry, ok := list.([]interface{}); ok {
if len(listAry) > 0 {
for _, listVal := range listAry {
if listInfo, ok := listVal.(map[string]interface{}); ok {
if unitType, ok := listInfo["type"]; ok {
var unitInfo NodesUnitNameStatue
if unitName, ok := listInfo["name"]; ok {
// fmt.Printf("unitName:%T--->%v\n", unitName, unitName)
if unitNameStr, ok := unitName.(string); ok {
unitInfo.Name = unitNameStr
}
}
switch unitType {
case "flex", "table":
fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
case "grid", "tabs":
fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
case "card", "div":
case "title", "txt", "button":
default:
unitInfo.Status = 4
t.MasterUnitList = append(t.MasterUnitList, unitInfo)
}
}
}
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-13 11:30:30
@ 功能: 递归解析所有组件
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (r *RecursionFormUnit) AllUnitNodes(tableName string, unitList []interface{}) {
if len(unitList) > 0 {
var unitIncoList []NodesUnitNameStatue
for _, listVal := range unitList {
if listInfo, ok := listVal.(map[string]interface{}); ok {
if unitType, ok := listInfo["type"]; ok {
var unitInfo NodesUnitNameStatue
if unitName, ok := listInfo["name"]; ok {
if unitNameStr, ok := unitName.(string); ok {
unitInfo.Id = unitNameStr
if !publicmethod.IsInTrue[string](unitNameStr, r.UnitAllKey) {
r.UnitAllKey = append(r.UnitAllKey, unitNameStr)
}
}
}
if itemVal, ok := listInfo["item"]; ok {
if itemInfo, ok := itemVal.(map[string]interface{}); ok {
if itemName, ok := itemInfo["label"]; ok {
if itemNameStr, ok := itemName.(string); ok {
unitInfo.Name = itemNameStr
}
}
}
fmt.Printf("list:%T--->%v\n", itemVal, itemVal)
}
// fmt.Printf("list:%T--->%v\n", unitName, unitName)
switch unitType {
case "flex", "table":
if list, ok := listInfo["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
r.AllUnitNodes(unitInfo.Id, listAry)
}
}
// fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
case "grid", "tabs":
if list, ok := listInfo["columns"]; ok {
if listAry, ok := list.([]interface{}); ok {
for _, colVal := range listAry {
if colList, ok := colVal.(map[string]interface{}); ok {
if listMap, ok := colList["list"]; ok {
// fmt.Printf("list:%T--->%v\n", listMap, listMap)
if colListAry, ok := listMap.([]interface{}); ok {
r.AllUnitNodes(unitInfo.Id, colListAry)
}
}
}
}
//
// r.AllUnitNodes(unitInfo.Name, listAry)
}
}
// fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
case "card", "div":
if list, ok := listInfo["list"]; ok {
fmt.Printf("list:%T--->%v\n", list, list)
}
// if len(listInfo["list"]) > 0 {
// // f.TableSubUnitAnalysis(tablename, v.List, isMaster)
// }
case "title", "txt", "button":
default:
unitInfo.Status = 4
// t.MasterUnitList = append(t.MasterUnitList, unitInfo)
unitIncoList = append(unitIncoList, unitInfo)
}
}
}
}
if len(unitIncoList) > 0 {
r.UnitAllState = append(r.UnitAllState, unitIncoList...)
if tableName != "" {
if len(r.SunUnitList) > 0 {
isTrue := true
for si, sv := range r.SunUnitList {
if sv.Name == tableName {
r.SunUnitList[si].UnitList = append(r.SunUnitList[si].UnitList, unitIncoList...)
isTrue = false
}
}
if isTrue {
var sunUnitInfo SunNodesUnitNameStatue
sunUnitInfo.Name = tableName
sunUnitInfo.UnitList = unitIncoList
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
}
} else {
var sunUnitInfo SunNodesUnitNameStatue
sunUnitInfo.Name = tableName
sunUnitInfo.UnitList = unitIncoList
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
}
} else {
r.MasterUnitList = append(r.MasterUnitList, unitIncoList...)
}
}
}
}
// func (r *RecursionFormUnit) AllUnitNodesAll(tableName string, unitList []interface{}, UnitState []NodesUnitNameStatue) {
func (r *RecursionFormUnit) AllUnitNodesAll(tableName string, unitList []interface{}) {
if len(unitList) > 0 {
var unitIncoList []NodesUnitNameStatue
for _, listVal := range unitList {
if listInfo, ok := listVal.(map[string]interface{}); ok {
if unitType, ok := listInfo["type"]; ok {
var unitInfo NodesUnitNameStatue
if unitName, ok := listInfo["name"]; ok {
if unitNameStr, ok := unitName.(string); ok {
unitInfo.Id = unitNameStr
if !publicmethod.IsInTrue[string](unitNameStr, r.UnitAllKey) {
r.UnitAllKey = append(r.UnitAllKey, unitNameStr)
}
if len(r.NodePower) > 0 {
// fmt.Printf("判断权限-1->: %v\n", unitNameStr)
//func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool)
unitInfo.IsLook, unitInfo.IsEdit = r.CalculateNodePower(unitNameStr)
// for _, uvs := range UnitState {
// if uvs.Id == unitNameStr {
// unitInfo.IsLook = uvs.IsLook
// unitInfo.IsEdit = uvs.IsEdit
// }
// }
} else {
// fmt.Printf("判断权限-3->: %v\n", unitNameStr)
unitInfo.IsLook = true
unitInfo.IsEdit = true
}
}
}
if itemVal, ok := listInfo["item"]; ok {
if itemInfo, ok := itemVal.(map[string]interface{}); ok {
if itemName, ok := itemInfo["label"]; ok {
if itemNameStr, ok := itemName.(string); ok {
unitInfo.Name = itemNameStr
}
}
}
// fmt.Printf("list:%T--->%v\n", itemVal, itemVal)
}
// fmt.Printf("list:%T--->%v\n", unitName, unitName)
switch unitType {
case "flex", "table":
if list, ok := listInfo["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
r.AllUnitNodesAll(unitInfo.Id, listAry)
}
}
// fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
case "grid", "tabs":
if list, ok := listInfo["columns"]; ok {
if listAry, ok := list.([]interface{}); ok {
for _, colVal := range listAry {
if colList, ok := colVal.(map[string]interface{}); ok {
if listMap, ok := colList["list"]; ok {
// fmt.Printf("list:%T--->%v\n", listMap, listMap)
if colListAry, ok := listMap.([]interface{}); ok {
r.AllUnitNodesAll(unitInfo.Id, colListAry)
}
}
}
}
//
// r.AllUnitNodes(unitInfo.Name, listAry)
}
}
// fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
case "card", "div":
if list, ok := listInfo["list"]; ok {
fmt.Printf("list:%T--->%v\n", list, list)
}
// if len(listInfo["list"]) > 0 {
// // f.TableSubUnitAnalysis(tablename, v.List, isMaster)
// }
case "title", "txt", "button":
default:
unitInfo.Status = 4
// t.MasterUnitList = append(t.MasterUnitList, unitInfo)
unitIncoList = append(unitIncoList, unitInfo)
}
}
}
}
if len(unitIncoList) > 0 {
r.UnitAllState = append(r.UnitAllState, unitIncoList...)
if tableName != "" {
if len(r.SunUnitList) > 0 {
isTrue := true
for si, sv := range r.SunUnitList {
if sv.Name == tableName {
r.SunUnitList[si].UnitList = append(r.SunUnitList[si].UnitList, unitIncoList...)
isTrue = false
}
}
if isTrue {
var sunUnitInfo SunNodesUnitNameStatue
sunUnitInfo.Name = tableName
sunUnitInfo.UnitList = unitIncoList
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
}
} else {
var sunUnitInfo SunNodesUnitNameStatue
sunUnitInfo.Name = tableName
sunUnitInfo.UnitList = unitIncoList
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
}
} else {
r.MasterUnitList = append(r.MasterUnitList, unitIncoList...)
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-14 09:20:29
@ 功能: 计算字段权限
@ 参数
#key 字段识别符
@ 返回值
#isLook 可见
#isErit 可编辑
@ 方法原型
#func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool)
*/
func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool) {
isLook = true
isErit = true
for _, v := range r.NodePower {
if v.NodeKey == r.CurrentNodeName {
for _, kv := range v.PowerAry {
if kv.Id == key {
isLook = kv.IsLook
isErit = kv.IsEdit
}
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-14 11:25:31
@ 功能: 设置工作流表单字段权限
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SetFlowFormKeyPower(c *gin.Context) {
var requestData FlowFormPowerInfo
c.ShouldBindJSON(&requestData)
if requestData.FormKey == "" && requestData.FormVersion == "" {
publicmethod.Result(106, requestData, c)
return
}
if requestData.FormData == "" && requestData.FormPower == "" {
publicmethod.Result(106, requestData, c)
return
}
var customerFormInfo modelAppPlatform.CustomerForm
err := customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.FormKey}, "`tablename`")
if err != nil {
publicmethod.Result(106, err, c)
return
}
if requestData.FormVersion == "" {
var formVersionInfo modelAppPlatform.CustomerFormVersion
formVersionInfo.GetCont(map[string]interface{}{"`tablekey`": customerFormInfo.TableNames, "`status`": 1}, "`id`")
requestData.FormVersion = strconv.FormatInt(formVersionInfo.Id, 10)
}
var formVersion modelAppPlatform.CustomerFormVersion
err = formVersion.GetCont(map[string]interface{}{"`id`": requestData.FormVersion})
if err != nil {
publicmethod.Result(106, err, c)
return
}
saveData := publicmethod.MapOut[string]()
if requestData.FormData != "" {
saveData["`mastesformjson`"] = requestData.FormData
}
if requestData.FormPower != "" {
saveData["`powerstr`"] = requestData.FormPower
} else {
var nodePower map[string]interface{}
err = json.Unmarshal([]byte(requestData.FormData), &nodePower)
if err != nil {
publicmethod.Result(106, err, c)
return
}
if powerInf, ok := nodePower["purview"]; ok {
fmt.Printf("nodePower:%T------>%v\n", powerInf, powerInf)
powerJson, err := json.Marshal(powerInf)
if err == nil {
saveData["`powerstr`"] = string(powerJson)
}
}
}
if len(saveData) > 0 {
saveData["`edit_time`"] = time.Now().Unix()
formVersion.EiteCont(map[string]interface{}{"`id`": requestData.FormVersion}, saveData)
}
publicmethod.Result(0, requestData, c)
}

4
api/version1/taskplatform/taskmanagement/appform.go

@ -233,6 +233,10 @@ func (a *ApiMethod) GianTaskVersionCont(c *gin.Context) {
sendInfo.Flowkey = versionCont.Flowkey //关联工作流"`
sendInfo.UserPermit = versionCont.UserPermit //可见人员"`
sendInfo.PostPermit = versionCont.PostPermit //可见角色"`
sendInfo.PowerStr = versionCont.PowerStr //权限结构"`
sendInfo.Groupid = versionCont.Groupid //分组Id"`
sendInfo.Icon = versionCont.Icon //图标"`
sendInfo.FlowIsOpen = versionCont.FlowIsOpen //是否开启工作流(1:启用;2:禁用)"`
sendInfo.FlowkeyStr = strconv.FormatInt(versionCont.Flowkey, 10)
sendInfo.CreaterStr = strconv.FormatInt(versionCont.Creater, 10)
publicmethod.Result(0, sendInfo, c)

149
api/version1/taskplatform/taskmanagement/formcontrol.go

@ -2,6 +2,7 @@ package taskmanagement
import (
"appPlatform/api/version1/customerform"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
@ -203,17 +204,21 @@ func WriteSunDatabase(uuid, creater, createrTime int64, masterTableName string,
}
if masterErr == nil && sunCreateIsOk {
err = gormDb.Commit().Error
publicmethod.WriteLog("write", "写入自定义表单", err, masterDataCont, sunDataList)
} else {
gormDb.Rollback()
err = errors.New("表单数据提交失败!请重新提交")
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
}
}
} else {
//子表不存在时,写入主表数据
err = overall.CONSTANT_DB_CustomerForm.Table(masterTableName).Create(masterDataCont).Error
publicmethod.WriteLog("write", "写入自定义表单", masterTableName, err)
}
} else {
err = errors.New("表单数据提交失败!请重新提交")
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
}
return
}
@ -551,7 +556,7 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) {
}
masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1)
masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen
//任务列表
var taskCont modelAppPlatform.Task
taskCont.MastersKey = uuid
@ -758,3 +763,145 @@ func MakeFormMapData(uuid, userKey, cureeTime int64, fieldVal map[string]interfa
}
return keyAndVal
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-03 09:40:31
@ 功能:
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AddCustomerForm(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["formId"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
}
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
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.Creater = userCont.Key //创建人"`
taskCont.CreaterTime = cureeTime //创建时间"`
taskCont.EditTime = cureeTime //编辑时间"`
taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"`
taskCont.VersionId = formCont.Id //来源于哪个表单"`
taskCont.Status = 2
if formCont.FlowIsOpen == 2 {
taskCont.Status = 3
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)
}

4
api/version1/taskplatform/taskmanagement/types.go

@ -76,6 +76,6 @@ type GainCustomerFormLogInfo struct {
// 返回自定义表单数据
type CallBackFormStruct struct {
modelAppPlatform.CustomerFormView
FlowkeyStr string `json:"flowkeystr"`
CreaterStr string `json:"createrstr"`
FlowkeyStr string `json:"flowkeystr" gorm:"-"`
CreaterStr string `json:"createrstr" gorm:"-"`
}

2
apirouter/apishiyan/maptostruct.go

@ -36,6 +36,8 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("createFlowChart", methodBinding.CreateFlowChart) //实验流程图生成
apiRouter.POST("getAllOrgSun", methodBinding.GetAllOrgSun) //获取行政组织所有子类
}
}
func (a *ApiRouter) RouterGroupVerify(router *gin.RouterGroup) {

21
apirouter/v1/customerformrouter/router.go

@ -12,8 +12,17 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
var methodBinding = version1.AppApiEntry.CustomerFormApi
{
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.POST("customerFormGroupTree", methodBinding.CustomerFormGroupTree) //自定义表单分组列表树
apiRouter.POST("customerFormGroupList", methodBinding.CustomerFormGroupList) //自定义表单分组列表
apiRouter.POST("addCustomerFormGroup", methodBinding.AddCustomerFormGroup) //添加自定义表单分组
apiRouter.POST("editCustomerFormGroup", methodBinding.EditCustomerFormGroup) //改变自定义表单分组内容
apiRouter.POST("editFormGroupState", methodBinding.EditFormGroupState) //改变自定义表单分组状态
apiRouter.POST("delFormGroup", methodBinding.DelFormGroup) // 强制删除(慎重操作!一旦执行不可恢复!)
apiRouter.POST("gainFormGroupInfo", methodBinding.GainFormGroupInfo) // 查看分组详情
apiRouter.POST("customer_form_list", methodBinding.CustomerFormList) //自定义表单列表
apiRouter.POST("production_mark_form", methodBinding.ProductionMarkOfCustomerForm) //生成表单基本信息
apiRouter.POST("save_customer_form", methodBinding.SaveCustomerForm) //保存自定义表单
@ -32,5 +41,13 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("optimize_repair_form", methodBinding.OptimizeOrRepairFormTable) //优化/修复数据表
apiRouter.POST("form_field_handle", methodBinding.FormFieldHandle) //表单结构数据处理
apiRouter.POST("edit_form_field", methodBinding.EditFormField) //编辑数据库表字段信息
apiRouter.POST("gainFormTableField", methodBinding.GainFormTableField) //获取表格字段
apiRouter.POST("gainTableField", methodBinding.GainTableField) //获取数据库表字段
apiRouter.POST("editCustomerFormList", methodBinding.EditCustomerFormList) //编辑自定义表单列表数据
apiRouter.POST("gainFormListCont", methodBinding.GainFormListCont) //获取表单列表数据
apiRouter.POST("gainFormPageListCont", methodBinding.GainFormPageListCont) //获取表单列表翻页数据
}
}

7
apirouter/v1/taskrouter/taskrouter.go

@ -25,6 +25,7 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("add_form_data", taskManagementRouter.AddFormAddData) //用户端自定义表单新增记录
apiRouter.POST("add_form_newdata", taskManagementRouter.AddFormAddNewData) //用户端自定义表单新增记录(新版)
apiRouter.POST("add_customer_form", taskManagementRouter.AddCustomerForm) //用户端自定义表单新增记录(列表新版)
}
taskFlowApi := router.Group("task_flow")
@ -45,6 +46,12 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
taskFlowApi.POST("gainFlowPeople", taskFlowRouter.GainFlowPeople) //获取操作人、
taskFlowApi.POST("searchUserList", taskFlowRouter.SearchUserList) //自定义表单搜索人员
taskFlowApi.POST("judgeFormFlowIsOpen", taskFlowRouter.JudgeFormFlowIsOpen) //判断是否已经存在工作流以及是否开启
taskFlowApi.POST("openFormFlow", taskFlowRouter.OpenFormFlow) //开启或关闭表单流程
taskFlowApi.POST("analysisForm", taskFlowRouter.AnalysisForm) //解析自定义表单组件
taskFlowApi.POST("setFlowFormKeyPower", taskFlowRouter.SetFlowFormKeyPower) //设置工作流表单字段权限
taskFlowApi.POST("startRunFlow", taskFlowRouter.StartRunFlow) //发起工作流
taskFlowApi.POST("taskFlowList", taskFlowRouter.TaskFlowList) //流程任务
taskFlowApi.POST("gainRunTaskFlow", taskFlowRouter.GainRunTaskFlow) //获取正在执行得任务流程

68
models/customerForm/taskrecord.go

@ -0,0 +1,68 @@
package customerForm
import (
"appPlatform/overall"
"strings"
)
// 自定义表单任务表
type TaskRecord struct {
Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"`
Creater int64 `json:"creater" gorm:"column:creater;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:"editTime" gorm:"column:edit_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:来源于哪个表单"`
Status int `json:"status" gorm:"column:status;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:主表标识"`
FlowKey int64 `json:"flow_key" gorm:"column:flow_key;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"`
}
func (TaskRecord *TaskRecord) TableName() string {
return "taskrecord"
}
// 编辑内容
func (cont *TaskRecord) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *TaskRecord) 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 *TaskRecord) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *TaskRecord) ContMap(whereMap interface{}, field ...string) (countAry []TaskRecord, 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 *TaskRecord) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error
return
}

76
models/customerForm/taskrunrecord.go

@ -0,0 +1,76 @@
package customerForm
import (
"appPlatform/overall"
"strings"
)
// 工作流执行主体
// 字典类型
type TaskRunRecord 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:当前执行识别符"`
}
func (TaskRunRecord *TaskRunRecord) TableName() string {
return "taskrunrecord"
}
// 写入内容
func (cont *TaskRunRecord) WriteCont() (err error) {
err = overall.CONSTANT_DB_CustomerForm.Create(&cont).Error
return
}
// 编辑内容
func (cont *TaskRunRecord) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *TaskRunRecord) 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 *TaskRunRecord) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *TaskRunRecord) ContMap(whereMap interface{}, field ...string) (countAry []TaskRunRecord, 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 *TaskRunRecord) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error
return
}

8
models/modelAppPlatform/customer_form.go

@ -17,8 +17,12 @@ type CustomerForm struct {
CreaterTime int64 `json:"createrTime" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:授权范围"`
PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:授权范围"`
UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:授权范围可见人员"`
PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:授权范围可见角色"`
Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"`
FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"`
ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"`
}
func (CustomerForm *CustomerForm) TableName() string {

68
models/modelAppPlatform/customer_form_group.go

@ -0,0 +1,68 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-03-06 13:23:03
@ 功能: 自定义表单分组
*/
type CustomerFormGroup struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:分组名称"`
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:父级"`
Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"`
Ordid int64 `json:"ordid" gorm:"column:ordid;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:删除)"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"`
}
func (CustomerFormGroup *CustomerFormGroup) TableName() string {
return "customer_form_group"
}
// 编辑内容
func (cont *CustomerFormGroup) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *CustomerFormGroup) 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 *CustomerFormGroup) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *CustomerFormGroup) ContMap(whereMap interface{}, field ...string) (countAry []CustomerFormGroup, 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 *CustomerFormGroup) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

1
models/modelAppPlatform/customer_form_version.go

@ -18,6 +18,7 @@ type CustomerFormVersion struct {
EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"`
Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"`
PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"`
}
func (CustomerFormVersion *CustomerFormVersion) TableName() string {

5
models/modelAppPlatform/customer_form_view.go

@ -26,6 +26,11 @@ type CustomerFormView struct {
Flowkey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:可见人员"`
PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:可见角色"`
PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"`
Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"`
FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"`
ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"`
}
func (CustomerFormView *CustomerFormView) TableName() string {

1
overall/publicmethod/errorCode.go

@ -5,6 +5,7 @@ var ErrorCodeMsg = map[int]string{
1: "",
100: "提交的数据格式错误!",
101: "提交的数据不能为空!",
102: "关键参数不能为空!",
103: "该数据已经存在!请不要重复添加",
104: "数据写入失败!",
105: "数据查询失败!",

143
overall/publicmethod/technique.go

@ -509,13 +509,29 @@ func StringToInt(val interface{}) (int, error) {
字符转int64
*/
func StringToInt64(val interface{}) (int64, error) {
switch val.(type) {
switch valData := val.(type) {
case string:
return strconv.ParseInt(val.(string), 10, 64)
return strconv.ParseInt(valData, 10, 64)
case int:
return int64(val.(int)), nil
return int64(valData), nil
case int8:
return int64(valData), nil
case int16:
return int64(valData), nil
case int32:
return int64(valData), nil
case int64:
return val.(int64), nil
return valData, nil
case uint:
return int64(valData), nil
case uint8:
return int64(valData), nil
case uint16:
return int64(valData), nil
case uint32:
return int64(valData), nil
case uint64:
return int64(valData), nil
default:
return 0, nil
}
@ -1781,6 +1797,7 @@ func MergeStruct[T GenericityVariable](aryOen, aryTwo []T) (structAry []T) {
}
// 根据字符串组合时间
//补全时间
/*
#dateTime 日期
*/
@ -2464,6 +2481,40 @@ func (g *GetOrgAllParent) GetOrgSun(superior int64) {
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-06 14:16:09
@ 功能: 获取指定自定义表单分组所有子分组
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (g *GetOrgAllParent) GetFormGroupSun(superior int64) {
if superior == 0 {
return
}
var id []int64
err := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormGroup{}).Select("`id`").Where("`state` IN ? AND `superior` = ?", []int{1, 2}, superior).Find(&id).Error
if err != nil || len(id) < 1 {
return
}
for _, v := range id {
if !IsInTrue[int64](v, g.Id) {
g.Id = append(g.Id, v)
}
g.GetOrgSun(v)
}
}
// 类型转换
func TypeToClass(val interface{}, timeClass int) (str string) {
@ -2618,3 +2669,87 @@ func StatisticalDuplication[T GenericityVariable](ary []T) (mapAry map[T]int) {
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-03-06 14:42:33
@ 功能: 生成自定义表单分组树
*/
func CustFormGroupTree(pid int64, treeList []modelAppPlatform.CustomerFormGroup) []CustomerFormGroupTree {
var TreeNodes []CustomerFormGroupTree
if reflect.ValueOf(treeList).IsValid() {
for _, v := range treeList {
if v.Superior == pid {
// v.Child = append(v.Child, CustFormGroupTree(v.Superior, treeList)...)
// TreeNodes = append(TreeNodes, v)
var treeInfo CustomerFormGroupTree
treeInfo.Id = v.Id
treeInfo.Title = v.Title //分组名称"`
treeInfo.Superior = v.Superior //父级"`
treeInfo.Sort = v.Sort //排序"`
treeInfo.Ordid = v.Ordid //归属行政组织"`
treeInfo.State = v.State //显示状态(1:启用;2:禁用,3:删除)"`
treeInfo.Time = v.Time //创建时间"`
treeInfo.Child = append(treeInfo.Child, CustFormGroupTree(v.Superior, treeList)...)
TreeNodes = append(TreeNodes, treeInfo)
}
}
}
return TreeNodes
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 11:19:41
@ 功能: 泛型类型断言
*/
func TypeToInterface(val interface{}) string {
switch balData := val.(type) {
case int:
return strconv.Itoa(balData)
case int8:
return strconv.FormatInt(int64(balData), 10)
case int16:
return strconv.FormatInt(int64(balData), 10)
case int32:
return strconv.FormatInt(int64(balData), 10)
case int64:
return strconv.FormatInt(balData, 10)
case uint:
return strconv.FormatUint(uint64(balData), 10)
case uint8:
return strconv.FormatUint(uint64(balData), 10)
case uint16:
return strconv.FormatUint(uint64(balData), 10)
case uint32:
return strconv.FormatUint(uint64(balData), 10)
case uint64:
return strconv.FormatUint(balData, 10)
case float32:
return fmt.Sprintf("%v", float64(balData))
case float64:
return fmt.Sprintf("%v", float64(balData))
default:
if balDataStr, ok := balData.(string); ok {
if balDataStr != "" {
return balDataStr
} else {
return ""
}
} else {
return ""
}
}
if valDataStr, ok := val.(string); ok {
if valDataStr != "" {
return valDataStr
} else {
return ""
}
} else {
return ""
}
}

6
overall/publicmethod/type.go

@ -341,3 +341,9 @@ type BirthdayAge struct {
Birthday string
Age int
}
// 自定义表单分组树
type CustomerFormGroupTree struct {
modelAppPlatform.CustomerFormGroup
Child []CustomerFormGroupTree `json:"child"`
}

Loading…
Cancel
Save