Browse Source

自定义表格用户端增加记录完成

v1
超级管理员 2 years ago
parent
commit
cfb0fa7ba6
  1. 165
      api/shiyan/maptostruct/shiyan.go
  2. 483
      api/version1/customerform/analysis_table.go
  3. 614
      api/version1/customerform/datatable.go
  4. 1165
      api/version1/customerform/form.go
  5. 228
      api/version1/customerform/type.go
  6. 4
      api/version1/entry.go
  7. 12
      api/version1/menus/menus.go
  8. 53
      api/version1/publicapi/api.go
  9. 7
      api/version1/publicapi/type.go
  10. 813
      api/version1/publicapi/组件结构.ts
  11. 36
      api/version1/taskplatform/taskflow/types.go
  12. 479
      api/version1/taskplatform/taskmanagement/appform.go
  13. 73
      api/version1/taskplatform/taskmanagement/types.go
  14. 9
      apirouter/apishiyan/maptostruct.go
  15. 2
      apirouter/entry.go
  16. 22
      apirouter/v1/customerformrouter/router.go
  17. 1
      apirouter/v1/public/router.go
  18. 31
      apirouter/v1/taskrouter/taskrouter.go
  19. 4
      apirouter/v1/taskrouter/type.go
  20. 1
      config/configDatabase/database.go
  21. 6
      initialization/databaseinit/mysql.go
  22. 3
      initialization/route/initRoute.go
  23. 70
      models/modelAppPlatform/customer_form.go
  24. 66
      models/modelAppPlatform/customer_form_version.go
  25. 71
      models/modelAppPlatform/customer_form_view.go
  26. 64
      models/modelAppPlatform/task.go
  27. 11
      models/modelshr/man_cont.go
  28. 1
      models/modelsschool/test_paper.go
  29. 2
      overall/appConfig.go
  30. 128
      overall/publicmethod/technique.go
  31. 3
      scheduledtask/time_task_cron.go

165
api/shiyan/maptostruct/shiyan.go

@ -1,6 +1,8 @@
package maptostruct package maptostruct
import ( import (
"appPlatform/api/version1/customerform"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelsschool" "appPlatform/models/modelsschool"
"appPlatform/overall" "appPlatform/overall"
"appPlatform/overall/publicmethod" "appPlatform/overall/publicmethod"
@ -12,6 +14,7 @@ import (
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/mozillazg/go-pinyin"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
@ -212,3 +215,165 @@ func TestPageTimeTask() {
// var countPages int64 // var countPages int64
// overall.CONSTANT_DB_Tidb.Model(&modelsschool.TestPaper{}).Select("tp_id").Count(&countPages) // overall.CONSTANT_DB_Tidb.Model(&modelsschool.TestPaper{}).Select("tp_id").Count(&countPages)
} }
type canshuzhi interface{}
// 接收参数
func (A *ApiMethod) Canshu(c *gin.Context) {
// var zhi canshuzhi
zhi, _ := c.GetRawData()
fmt.Printf("%T------------->%v\n", zhi, string(zhi))
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-05 08:38:58
@ 功能: 模拟创建表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CreateTable(c *gin.Context) {
var requestData publicmethod.CommonId[int64]
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
var customerFormCont modelAppPlatform.CustomerFormView
err = customerFormCont.GetCont(map[string]interface{}{"cfid": requestData.Id, "`status`": 1})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(customerFormCont.MastesFormJson), &formJsonCont)
mastSql, _ := formJsonCont.DisassembleForm()
var formVersionCont modelAppPlatform.CustomerFormVersion
formVersionCont.EiteCont(map[string]interface{}{"id": customerFormCont.Id}, map[string]interface{}{"table_structure": mastSql, "edit_time": time.Now().Unix()})
publicmethod.Result(0, mastSql, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-08 09:24:00
@ 功能: 改革自定义表单列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) QianyiVersion(c *gin.Context) {
var list []modelAppPlatform.CustomerForm
err := overall.CONSTANT_DB_AppPlatform.Find(&list).Error
if err != nil {
return
}
for _, v := range list {
var versionCont modelAppPlatform.CustomerFormVersion
versionCont.TableKey = v.TableNames //default:'';not null;comment:表单标识符"`
versionCont.Version = 1 //1;not null;comment:版本号"`
versionCont.Status = 1 //not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
// versionCont.MastesForm = v.MastesForm //';comment:表单结构"`
// versionCont.MastesFormJson = v.MastesFormJson //efault:'';comment:表单结构json"`
// versionCont.Creater = v.Creater //ult:0;not null;comment:创建人"`
versionCont.CreaterTime = v.CreaterTime //not null;comment:创建时间"`
versionCont.EditTime = v.EditTime //efault:0;not null;comment:编辑时间"`
// versionCont.TableStructure = v.TableStructure //;default:'';comment:字表结构"`
// versionCont.Dict = v.Dict //字表结构"`
overall.CONSTANT_DB_AppPlatform.Create(&versionCont)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 13:13:13
@ 功能: 查询表结构
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) LookTableStruct(c *gin.Context) {
var requestData publicmethod.CommonId[int64]
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == 0 {
publicmethod.Result(107, err, c)
return
}
var versionCont modelAppPlatform.CustomerFormVersion
err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
formStruct, err := customerform.ReadDatabaseForm(versionCont.TableKey)
publicmethod.Result(107, formStruct, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-26 11:34:53
@ 功能: 汉字转拼音
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) HanZiZhuanPinYin(c *gin.Context) {
var requestData publicmethod.PublicName
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Name == "" {
publicmethod.Result(107, err, c)
return
}
pyObject := pinyin.NewArgs()
// pyObject.Heteronym =true
pyObject.Style = pinyin.Tone3
pyObject.Separator = ""
str := pinyin.Slug(requestData.Name, pyObject)
publicmethod.Result(0, str, c)
}

483
api/version1/customerform/analysis_table.go

@ -0,0 +1,483 @@
package customerform
import (
"appPlatform/overall/publicmethod"
"fmt"
"strconv"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-09-26 15:34:07
@ 功能:
@ 参数
#分析表格
@ 返回值
#
@ 方法原型
#
*/
func AnalysisTable(subUnit MasterStruct) (fieldCont TableFormStruct) {
//TableFormStruct
fieldCont.TableName = subUnit.Name
switch subUnit.Type {
case "datePicker":
switch subUnit.Control.Type {
case "year", "month", "date", "datetime":
fieldCont.Types = "bigint"
fieldCont.ControlType = subUnit.Control.Type
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
case "week":
fieldCont.Types = "varchar"
fieldCont.ControlType = subUnit.Control.Type
fieldCont.DefaultValue = ""
fieldCont.ControlType = "string"
fieldCont.FieldLenght = 255
case "datetimerange", "daterange", "monthrange":
fieldCont.Types = "bigint"
fieldCont.ControlType = "array"
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
default:
fieldCont.Types = "mediumtext"
fieldCont.ControlType = subUnit.Control.Type
fieldCont.DefaultValue = ""
fieldCont.ControlType = "string"
}
case "input", "password":
if len(subUnit.CustomRules) > 0 {
zdType, signed := CustomRulesInput(subUnit.CustomRules)
fieldCont.Types = zdType
fieldCont.Signed = signed
switch zdType {
case "float":
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
fieldCont.ControlType = "float"
case "decimal":
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
fieldCont.ControlType = "decimal"
case "bigint":
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
fieldCont.ControlType = "bigint"
case "int":
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 6
fieldCont.ControlType = "int"
default:
fieldCont.DefaultValue = ""
fieldCont.FieldLenght = 255
fieldCont.ControlType = "string"
}
} else {
fieldCont.Types = "varchar"
fieldCont.DefaultValue = ""
fieldCont.FieldLenght = 255
fieldCont.ControlType = "string"
}
case "textarea", "cascader":
fieldCont.Types = "mediumtext"
fieldCont.DefaultValue = ""
fieldCont.ControlType = "string"
case "radio", "select":
var fieldVal string
if len(subUnit.Options) > 0 {
for _, ov := range subUnit.Options {
if len(fieldVal) < len(ov.Value) {
fieldVal = ov.Value
}
}
}
if subUnit.Config.TransformData == "number" {
size, fieldType := CalculateCharacterLength("int", fieldVal)
fieldCont.Types = fieldType
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = size
fieldCont.ControlType = fieldType
} else {
size, fieldType := CalculateCharacterLength("string", fieldVal)
fieldCont.Types = fieldType
fieldCont.DefaultValue = ""
fieldCont.FieldLenght = size
fieldCont.ControlType = "string"
}
case "checkbox":
fieldCont.Types = "mediumtext"
fieldCont.DefaultValue = ""
fieldCont.ControlType = "array"
case "colorPicker", "timePicker":
fieldCont.Types = "varchar"
fieldCont.DefaultValue = ""
fieldCont.FieldLenght = 50
fieldCont.ControlType = "string"
case "switch":
var fieldVal string
if len(subUnit.Control.ActiveValue) < len(subUnit.Control.InactiveValue) {
fieldVal = subUnit.Control.InactiveValue
} else {
fieldVal = subUnit.Control.ActiveValue
}
size, fieldType := CalculateCharacterLength("int", fieldVal)
fieldCont.Types = fieldType
fieldCont.ControlType = "booble"
fieldCont.DefaultValue, _ = strconv.Atoi(subUnit.Control.ActiveValue)
fieldCont.FieldLenght = size
case "inputNumber":
fieldCont.Types = "bigint"
fieldCont.DefaultValue = 0
fieldCont.FieldLenght = 20
fieldCont.ControlType = "bigint"
case "rate", "slider":
fieldVal := strconv.Itoa(subUnit.Control.Max)
size, fieldType := CalculateCharacterLength("int", fieldVal)
fieldCont.Types = fieldType
fieldCont.ControlType = fieldType
if scm, scmIsok := subUnit.Control.ModelValue.(int); scmIsok {
fieldCont.DefaultValue = scm
}
fieldCont.FieldLenght = size
case "treeSelect":
case "upload":
fieldCont.Types = "longtext"
fieldCont.DefaultValue = ""
fieldCont.ControlType = "array" //返回值为数组
case "tinymce", "expand-user":
fieldCont.Types = "longtext"
fieldCont.DefaultValue = ""
fieldCont.ControlType = "string"
case "grid", "tabs", "card", "div", "table", "flex", "divider":
default:
fieldCont.Types = "varchar"
fieldCont.DefaultValue = ""
fieldCont.FieldLenght = 255
fieldCont.ControlType = "string"
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-27 09:28:33
@ 功能: 文本框校验规则
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func CustomRulesInput(list []CustomRulesStruct) (types string, signed bool) {
if len(list) == 0 {
types = "varchar"
return
}
var typeAry []string
for _, v := range list {
if !publicmethod.IsInTrue[string](v.Type, typeAry) {
typeAry = append(typeAry, v.Type)
}
}
if len(typeAry) == 0 {
types = "varchar"
return
}
stringType := []string{"mobile", "tel", "phone", "email", "card", "cn", "numberLetter", "网址"}
moneyType := []string{"money"}
floatType := []string{"longitude", "latitude"}
zhengZs := []string{"int"}
numberType := []string{"number"}
for _, tv := range typeAry {
if publicmethod.IsInTrue[string](tv, floatType) {
types = "float"
return
}
if publicmethod.IsInTrue[string](tv, moneyType) {
types = "decimal"
return
}
if publicmethod.IsInTrue[string](tv, numberType) {
types = "bigint"
signed = true
return
}
if publicmethod.IsInTrue[string](tv, zhengZs) {
types = "int"
return
}
if publicmethod.IsInTrue[string](tv, stringType) {
types = "varchar"
return
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-26 16:28:16
@ 功能: 计算字符长度
@ 参数
#class 类型
#str
@ 返回值
#size 字段长度
#fieldType 字段类型
@ 方法原型
#func CalculateCharacterLength(class, str string) (size int, fieldType string)
*/
func CalculateCharacterLength(class, str string) (size int, fieldType string) {
size = len(str) + 1
switch class {
case "int":
if size <= 9 {
fieldType = "int"
} else {
fieldType = "bigint"
}
case "string":
if size <= 255 {
fieldType = "varchar"
} else {
fieldType = "mediumtext"
}
default:
fieldType = "varchar"
size = 255
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-27 08:52:56
@ 功能: 创建自定义表单数据表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (c *CustomerFormMaster) CreateFormDatabaseTable() (relevance string, err error) {
err = CreateForm(c.Form.Name, c.Form.FormName, true) //创建主表
if err != nil {
return
}
var masterSql []string //主数据库添加字段语句集合
var sunFormName []string //子表名称集合
sunFormNameAry := publicmethod.MapOut[string]() //子表对应关系
sunForm := publicmethod.MapOut[string]()
for _, v := range c.List {
switch v.Type {
case "grid", "tabs":
if len(v.Columns) > 0 {
for _, cv := range v.Columns {
// fmt.Printf("type:%v <===========>label:%v <===========> Name:%v<===========> ModelValue:%v\n", v.Type, cv.Attr.Span, cv.Type, v.Control.ModelValue)
sqlStr := VesselSubUnitConvertSql(c.Form.Name, cv.List)
if len(sqlStr) > 0 {
masterSql = append(masterSql, sqlStr...)
}
}
}
case "card", "div":
if len(v.List) > 0 {
sqlStr := VesselSubUnitConvertSql(c.Form.Name, v.List)
if len(sqlStr) > 0 {
masterSql = append(masterSql, sqlStr...)
}
}
case "table", "flex":
if len(v.List) > 0 {
if !publicmethod.IsInTrue[string](v.Name, sunFormName) {
sunFormName = append(sunFormName, v.Name)
sunFormNameAry[v.Name] = v.Name
sqlStr := VesselSubUnitConvertSql(v.Name, v.List)
sunForm[v.Name] = sqlStr
CreateForm(v.Name, fmt.Sprintf("%v(%v)子表", c.Form.FormName, c.Form.Name), false)
} else {
sunTableName := fmt.Sprintf("%v%v", v.Name, publicmethod.GetUUid(1))
sunFormName = append(sunFormName, sunTableName)
sunFormNameAry[v.Name] = sunTableName
sqlStr := VesselSubUnitConvertSql(sunTableName, v.List)
sunForm[sunTableName] = sqlStr
CreateForm(sunTableName, fmt.Sprintf("%v(%v)子表", c.Form.FormName, c.Form.Name), false)
}
}
default:
sqlMasterStr := SubUnitConvertSql(c.Form.Name, v)
if sqlMasterStr != "not" {
masterSql = append(masterSql, sqlMasterStr)
}
// masterSql = append(masterSql, SubUnitConvertSql(c.Form.Name, v))
// fielfInfoClass := AnalysisTable(v)
// unsigned := ""
// if !fielfInfoClass.Signed {
// unsigned = "unsigned"
// }
// switch fielfInfoClass.Types {
// case "int", "bigint":
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, v.Item.Label))
// case "booble":
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(1) %v NOT NULL DEFAULT %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, unsigned, fielfInfoClass.DefaultValue, v.Item.Label))
// case "float":
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,%v) %v NOT NULL DEFAULT %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, v.Item.Label))
// case "decimal":
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,2) %v NOT NULL DEFAULT %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, v.Item.Label))
// case "mediumtext", "longtext":
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, v.Item.Label))
// default:
// masterSql = append(masterSql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) COLLATE utf8mb4_general_ci NOT NULL DEFAULT %v COMMENT '%v'", c.Form.Name, v.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, fielfInfoClass.DefaultValue, v.Item.Label))
// }
}
}
// if len(masterSql) > 0 {
// CreateFormFiled(c.Form.Name, c.Form.FormName, true, masterSql) //添加主表字段
// }
// if len(sunForm) > 0 { //子表操作
// relevanceByte, _ := json.Marshal(sunFormNameAry)
// relevance = string(relevanceByte)
// for i, v := range sunForm {
// // fmt.Printf("表单结构----拆解----》%v========>%v\n", i, v)
// CreateFormFiled(i, fmt.Sprintf("%v(%v)子表", c.Form.FormName, c.Form.Name), false, v)
// }
// }
fmt.Printf("主表数据:%v\n", masterSql)
fmt.Printf("子表表数据:%v\n", sunForm)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-27 11:04:39
@ 功能: 容器组件生成数据库字段语句
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func VesselSubUnitConvertSql(tableName string, list []MasterStruct) (mastSql []string) {
if len(list) > 0 {
for _, v := range list {
sqlStr := SubUnitConvertSql(tableName, v)
if sqlStr != "not" {
mastSql = append(mastSql, sqlStr)
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-27 10:30:25
@ 功能: 单一组件转换Sql语句
@ 参数
#tablename 表单名称
#subUnit 第一组件结构体
@ 返回值
#sql 数据库字段添加语句
@ 方法原型
#func SubUnitConvertSql(tablename string, subUnit MasterStruct) (sql string)
*/
func SubUnitConvertSql(tablename string, subUnit MasterStruct) (sql string) {
if tablename == "" {
sql = "not"
return
}
fielfInfoClass := AnalysisTable(subUnit)
unsigned := ""
if !fielfInfoClass.Signed {
unsigned = "unsigned"
}
switch fielfInfoClass.Types {
case "int", "bigint":
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, subUnit.Item.Label)
case "booble":
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(1) %v NOT NULL DEFAULT %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, unsigned, fielfInfoClass.DefaultValue, subUnit.Item.Label)
case "float":
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,%v) %v NOT NULL DEFAULT %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, subUnit.Item.Label)
case "decimal":
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,2) %v NOT NULL DEFAULT %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, unsigned, fielfInfoClass.DefaultValue, subUnit.Item.Label)
case "mediumtext", "longtext":
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, subUnit.Item.Label)
default:
if fielfInfoClass.Types != "" {
sql = fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) COLLATE utf8mb4_general_ci NOT NULL DEFAULT %v COMMENT '%v'", tablename, subUnit.Name, fielfInfoClass.Types, fielfInfoClass.FieldLenght, fielfInfoClass.DefaultValue, subUnit.Item.Label)
}
}
return
}

614
api/version1/customerform/datatable.go

@ -0,0 +1,614 @@
package customerform
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 13:02:23
@ 功能: 数据库表结构
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) HaveDataBaseTableStruct(c *gin.Context) {
var requestData publicmethod.CommonId[string]
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(101, err, c)
return
}
//获取自定义表单设置主表信息
var customerFormCont modelAppPlatform.CustomerForm
err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`tablename`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
var versionInfo []modelAppPlatform.CustomerFormVersion
err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormVersion{}).Select("`id`,`tablekey`,`status`,`version`,`table_structure`").Where("`tablekey` = ? AND `status` BETWEEN ? AND ?", customerFormCont.TableNames, 1, 2).Order("status asc").Order("version asc").Order("id desc").Find(&versionInfo).Error
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sunFormStr string
var versionIdStr string
var sendCont CustomerFormDatabaseVesion
if len(versionInfo) > 0 {
for _, v := range versionInfo {
var versionCont PublicFormDatabaseVesion
versionCont.Id = requestData.Id
versionCont.VersionId = strconv.FormatInt(v.Id, 10)
versionCont.Name = fmt.Sprintf("V%v", v.Version)
if v.Status == 1 {
versionCont.IsMain = true
sunFormStr = v.TableStructure
versionIdStr = strconv.FormatInt(v.Id, 10)
//主表单数据
var masterFormTable PublicFormDatabaseVesion
masterFormTable.Id = requestData.Id
masterFormTable.VersionId = versionIdStr
masterFormTable.Name = v.TableKey
masterFormTable.IsMain = true
if num := HaveTableLog(v.TableKey); num > 0 {
masterFormTable.IsEdit = false
} else {
masterFormTable.IsEdit = true
}
sendCont.TableList = append(sendCont.TableList, masterFormTable)
} else {
versionCont.IsMain = false
}
sendCont.Version = append(sendCont.Version, versionCont)
}
}
if sunFormStr != "" {
sunSqlMap := make(map[string]string)
json.Unmarshal([]byte(sunFormStr), &sunSqlMap)
if len(sunSqlMap) > 0 {
for _, s := range sunSqlMap {
var sunFromTableCont PublicFormDatabaseVesion
sunFromTableCont.Id = requestData.Id
sunFromTableCont.VersionId = versionIdStr
sunFromTableCont.Name = s
sunFromTableCont.IsMain = false
if num := HaveTableLog(s); num > 0 {
sunFromTableCont.IsEdit = false
} else {
sunFromTableCont.IsEdit = true
}
sendCont.TableList = append(sendCont.TableList, sunFromTableCont)
}
}
}
publicmethod.Result(0, sendCont, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 14:34:04
@ 功能: 获取表格是否有记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func HaveTableLog(tableName string) (logCount int64) {
err := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("`id`").First(&logCount).Error
if err != nil {
logCount = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 13:03:11
@ 功能: 读取数据表结构
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func ReadDatabaseForm(tableName string, tableType ...string) (list []Result, err error) {
tableTypes := ""
if len(tableType) > 0 {
tableTypes = tableType[0]
}
gormDb := overall.CONSTANT_DB_CustomerForm
switch tableTypes {
default:
gormDb = overall.CONSTANT_DB_CustomerForm
}
// sqlStr := fmt.Sprintf("DESC %v", tableName)
sqlStr := fmt.Sprintf("SHOW FULL COLUMNS FROM `%v`", tableName)
err = gormDb.Raw(sqlStr).Scan(&list).Error
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 15:25:03
@ 功能: 获取表单结构{"table1693810889577":"table1693810889577","table1693811003658":"table1693811003658","table1693811044212":"table1693811044212"}
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) HaveFormTabelCont(c *gin.Context) {
var requestData HaveVersionForm
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(101, err, c)
return
}
if requestData.Name == "" {
publicmethod.Result(101, err, c)
return
}
//获取自定义表单设置主表信息
var versionCont modelAppPlatform.CustomerFormVersion
err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`tablekey`", "`mastesformjson`", "`table_structure`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
var formJsonCont CustomerFormMaster
err = json.Unmarshal([]byte(versionCont.MastesFormJson), &formJsonCont)
masterForm, sunForm := AnalyseFormTableJson(formJsonCont)
formStruct, err := ReadDatabaseForm(requestData.Name)
if err != nil {
publicmethod.Result(107, err, c)
return
}
fmt.Printf("%s\n", masterForm)
sendMap := make(map[string]interface{})
// sendMap["masterForm"] = masterForm
// sendMap["sunForm"] = sunForm
// sendMap["formStruct"] = formStruct
// sendMap["err"] = err
// sendMap["formJsonCont"] = formJsonCont
var filedList []Result
if requestData.Name == versionCont.TableKey {
for _, v := range formStruct {
if publicmethod.IsInTrue[string](v.Field, masterForm) {
attFiled := strings.Split(v.Type, " ")
if len(attFiled) >= 2 {
v.Attribute = attFiled[1]
v.Type = attFiled[0]
}
// fmt.Printf("attFiled--->%v--->%v\n", attFiled, len(attFiled))
filedList = append(filedList, v)
}
// attFiled := strings.Split(v.Type, " ")
// if len(attFiled) >= 2 {
// v.Attribute = attFiled[1]
// v.Type = attFiled[0]
// }
// // fmt.Printf("attFiled--->%v--->%v\n", attFiled, len(attFiled))
// filedList = append(filedList, v)
}
} else {
if fieldAry, isOk := sunForm[requestData.Name]; isOk {
for _, v := range formStruct {
if publicmethod.IsInTrue[string](v.Field, fieldAry.([]string)) {
attFiled := strings.Split(v.Type, " ")
if len(attFiled) >= 2 {
v.Attribute = attFiled[1]
v.Type = attFiled[0]
}
filedList = append(filedList, v)
}
}
}
}
sendMap["filedlist"] = filedList
if num := HaveTableLog(requestData.Name); num > 0 {
sendMap["isedit"] = false
} else {
sendMap["isedit"] = true
}
publicmethod.Result(0, sendMap, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 15:38:42
@ 功能: 根据版本获取数据库表集合
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) HaveFormTableList(c *gin.Context) {
var requestData publicmethod.CommonId[string]
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(101, err, c)
return
}
//获取自定义表单设置主表信息
var versionCont modelAppPlatform.CustomerFormVersion
err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`tablekey`", "`status`", "`version`", "`table_structure`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
var customerFormCont modelAppPlatform.CustomerForm
err = customerFormCont.GetCont(map[string]interface{}{"`tablename`": versionCont.TableKey}, "`id`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
formId := strconv.FormatInt(customerFormCont.Id, 10)
var sendAry []PublicFormDatabaseVesion
var masterFormTable PublicFormDatabaseVesion
masterFormTable.Id = formId
masterFormTable.VersionId = requestData.Id
masterFormTable.Name = versionCont.TableKey
masterFormTable.IsMain = true
if num := HaveTableLog(versionCont.TableKey); num > 0 {
masterFormTable.IsEdit = false
} else {
masterFormTable.IsEdit = true
}
sendAry = append(sendAry, masterFormTable)
if versionCont.TableStructure != "" {
sunSqlMap := make(map[string]string)
json.Unmarshal([]byte(versionCont.TableStructure), &sunSqlMap)
if len(sunSqlMap) > 0 {
for _, s := range sunSqlMap {
var sunFromTableCont PublicFormDatabaseVesion
sunFromTableCont.Id = formId
sunFromTableCont.VersionId = requestData.Id
sunFromTableCont.Name = s
sunFromTableCont.IsMain = false
if num := HaveTableLog(s); num > 0 {
sunFromTableCont.IsEdit = false
} else {
sunFromTableCont.IsEdit = true
}
sendAry = append(sendAry, sunFromTableCont)
}
}
}
publicmethod.Result(0, sendAry, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-13 15:57:13
@ 功能: 拆析版本表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func AnalyseFormTableJson(formJsonCont CustomerFormMaster) (masterForm []string, sunForm map[string]interface{}) {
dataMap := make(map[string]interface{})
fieldType := []string{"input", "password", "colorPicker", "component", "datePicker", "checkbox", "cascader", "treeSelect", "textarea", "upload", "expand-user", "select", "radio", "inputSlot", "rate", "inputNumber", "slider", "switch", "tinymce"}
cardFieldType := []string{"card"}
customLayout := []string{"grid", "tabs"}
sunFieldType := []string{"table", "flex"}
for _, v := range formJsonCont.List {
if publicmethod.IsInTrue[string](v.Type, fieldType) {
masterForm = append(masterForm, v.Name)
}
//卡片数据
if publicmethod.IsInTrue[string](v.Type, cardFieldType) {
if len(v.List) > 0 {
sqlStr := ComponentMappingDataTableField(v.List)
masterForm = append(masterForm, sqlStr...)
}
}
//自定义布局
if publicmethod.IsInTrue[string](v.Type, customLayout) {
if len(v.Columns) > 0 {
for _, cv := range v.Columns {
sqlStr := ComponentMappingDataTableField(cv.List)
masterForm = append(masterForm, sqlStr...)
}
}
}
//子表
if publicmethod.IsInTrue[string](v.Type, sunFieldType) {
if len(v.List) > 0 {
sqlStr := ComponentMappingDataTableField(v.List)
dataMap[v.Name] = sqlStr
}
}
}
sunForm = dataMap
return
}
/**
@ 作者: 秦东
@ 时间: 2023-09-13 16:14:07
@ 功能: 组件印射字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func ComponentMappingDataTableField(list []MasterStruct) (mastSql []string) {
if len(list) > 0 {
for _, lv := range list {
fieldType := []string{"input", "password", "colorPicker", "component", "datePicker", "checkbox", "cascader", "treeSelect", "textarea", "upload", "expand-user", "select", "radio", "inputSlot", "rate", "inputNumber", "slider", "switch", "tinymce"}
if publicmethod.IsInTrue[string](lv.Type, fieldType) {
mastSql = append(mastSql, lv.Name)
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-14 09:01:40
@ 功能: 优化/修复数据表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) OptimizeOrRepairFormTable(c *gin.Context) {
var requestData OptimizeOrRepairTable
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Name == "" {
publicmethod.Result(101, err, c)
return
}
if requestData.OptimizeOrRepair == 1 { //优化表
sqlStr := fmt.Sprintf("OPTIMIZE TABLE %v", requestData.Name)
overall.CONSTANT_DB_CustomerForm.Exec(sqlStr)
} else { //修复表
sqlStr1 := fmt.Sprintf("CHECK TABLE %v", requestData.Name)
overall.CONSTANT_DB_CustomerForm.Exec(sqlStr1)
sqlStr2 := fmt.Sprintf("REPAIR TABLE %v", requestData.Name)
overall.CONSTANT_DB_CustomerForm.Exec(sqlStr2)
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-14 11:50:30
@ 功能: 表单结构数据处理
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) FormFieldHandle(c *gin.Context) {
var requestData Result
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
var sendForm SendFieldCont
sendForm.Field = requestData.Field
sendForm.Type = requestData.Type
sendForm.Attribute = requestData.Attribute
sendForm.Collation = requestData.Collation
sendForm.Null = requestData.Null
sendForm.Key = requestData.Key
sendForm.Default = requestData.Default
sendForm.Extra = requestData.Extra
sendForm.Privileges = requestData.Privileges
sendForm.Comment = requestData.Comment
if requestData.Type == "" {
sendForm.Type = "varchar"
} else {
attFiled := strings.Split(requestData.Type, "(")
sendForm.Type = attFiled[0]
if len(attFiled) > 1 {
fieldLenght := publicmethod.MatchBracket(requestData.Type, "(", ")")
switch sendForm.Type {
case "decimal", "float", "double":
maxAndMin := strings.Split(fieldLenght, ",")
switch len(maxAndMin) {
case 1:
sendForm.Integer = maxAndMin[0]
case 2:
sendForm.Integer = maxAndMin[0]
sendForm.Decimal = maxAndMin[1]
default:
}
default:
sendForm.Integer = fieldLenght
}
}
}
publicmethod.Result(0, sendForm, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-14 15:43:03
@ 功能: 编辑数据库表字段信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditFormField(c *gin.Context) {
var requestData EditDatabaseFormField
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.FormName == "" || requestData.Field == "" {
publicmethod.Result(101, err, c)
return
}
sqlStr := fmt.Sprintf("ALTER TABLE `%v` MODIFY COLUMN `%v` ", requestData.FormName, requestData.Field)
switch requestData.Type {
case "decimal", "float", "double":
var integerIntVal int64
if requestData.Integer == "" {
integerIntVal = 3
} else {
integerInt, err := strconv.ParseInt(requestData.Integer, 10, 64)
if err == nil {
integerIntVal = integerInt
}
}
decimalVal := integerIntVal - 1
if requestData.Decimal != "" {
decimalVales, err := strconv.ParseInt(requestData.Decimal, 10, 64)
if err == nil {
decimalVal = decimalVales
}
}
if decimalVal == 0 {
decimalVal = integerIntVal
}
sqlStr = fmt.Sprintf(" %v %v(%v,%v) ", sqlStr, requestData.Type, integerIntVal, decimalVal)
case "tinyint", "smallint", "mediumint", "int", "integer", "bigint":
var integerIntVal int64
if requestData.Integer == "" {
integerIntVal = 3
} else {
integerInt, err := strconv.ParseInt(requestData.Integer, 10, 64)
if err == nil {
integerIntVal = integerInt
}
}
sqlStr = fmt.Sprintf(" %v %v(%v) %v ", sqlStr, requestData.Type, integerIntVal, requestData.Attribute)
case "enum", "set", "text", "tinytext", "mediumtext", "longtext", "blob", "year", "date", "time", "datetime", "timestamp":
sqlStr = fmt.Sprintf(" %v %v ", sqlStr, requestData.Type)
default:
if requestData.Integer != "" {
sqlStr = fmt.Sprintf(" %v %v(%v) ", sqlStr, requestData.Type, requestData.Integer)
} else {
sqlStr = fmt.Sprintf(" %v %v ", sqlStr, requestData.Type)
}
}
if requestData.Null == "NO" {
sqlStr = fmt.Sprintf(" %v NOT NULL ", sqlStr)
}
if !publicmethod.IsInTrue[string](requestData.Type, []string{"enum", "set", "text", "tinytext", "mediumtext", "longtext", "blob", "year", "date", "time", "datetime", "timestamp"}) {
sqlStr = fmt.Sprintf(" %v DEFAULT '%v'", sqlStr, requestData.Default)
}
sqlStr = fmt.Sprintf(" %v COMMENT '%v'", sqlStr, requestData.Comment)
err = publicmethod.ExecSql("CustomerForm", sqlStr)
if err != nil {
publicmethod.Result(106, err, c)
return
}
publicmethod.Result(0, err, c)
}

1165
api/version1/customerform/form.go

File diff suppressed because it is too large

228
api/version1/customerform/type.go

@ -1,6 +1,7 @@
package customerform package customerform
import ( import (
"appPlatform/models/modelAppPlatform"
"appPlatform/overall/publicmethod" "appPlatform/overall/publicmethod"
"sync" "sync"
@ -44,12 +45,35 @@ type CustomerFormMaster struct {
// 组件主体 // 组件主体
type MasterStruct struct { type MasterStruct struct {
Type string `json:"type"` //组件类型 Type string `json:"type"` //组件类型
Control ControlStruct `json:"control"` Columns []columnsStruct `json:"columns"` //
Config UnitConfigStruct `json:"config"` Control ControlStruct `json:"control"`
Options []OptionsStruct `json:"options"` Config UnitConfigStruct `json:"config"` //组件配置
Name string `json:"name"` Options []OptionsStruct `json:"options"`
Item ItemStruct `json:"item"` Name string `json:"name"`
Item ItemStruct `json:"item"`
CustomRules []CustomRulesStruct `json:"customRules"` //校验规则
List []MasterStruct `json:"list"`
TableData interface{} `json:"tableData"`
}
// 校验规则
type CustomRulesStruct struct {
Type string `json:"type"`
Message string `json:"message"`
Trigger string `json:"trigger"`
}
// 标签
type columnsStruct struct {
Label string `json:"label"`
Attr AttrStruct `json:"attr"`
List []MasterStruct `json:"list"` //组件列表
Type string `json:"type"`
}
type AttrStruct struct {
Span int `json:"span"` //占行范围
} }
// 选择内容 // 选择内容
@ -59,37 +83,86 @@ type OptionsStruct struct {
} }
type ItemStruct struct { type ItemStruct struct {
Label string `json:"label"` Label string `json:"label"`
ShowLabel bool `json:"showLabel"`
Rules []rulesStruct `json:"rules"`
}
type rulesStruct struct {
Name bool `json:"name"`
Required bool `json:"required"`
Message string `json:"message"`
Trigger string `json:"trigger"`
} }
// 组件控制器 // 组件控制器
type ControlStruct struct { type ControlStruct struct {
Label string `json:"label"` Label string `json:"label"`
Type string `json:"type"` Type string `json:"type"`
Key string `json:"key"` Key string `json:"key"`
ModelValue []interface{} `json:"model"` ModelValue interface{} `json:"modelValue"`
Placeholder string `json:"placeholder"` //占位内容
Disabled bool `json:"disabled"` //是否禁用
Rows int `json:"rows"` //行数(多行文本使用)
Direction string `json:"direction"` //
ContentPosition string `json:"contentPosition"` //
BorderStyle string `json:"borderStyle"` //
Height string `json:"height"` //
Width string `json:"width"` //
ImgUrl string `json:"imgUrl"` //
BlobUrl string `json:"blobUrl"` //
ActiveValue string `json:"activeValue"` //
InactiveValue string `json:"inactiveValue"` //
Max int `json:"max"` //
ColorFormat string `json:"colorFormat"` //
FormAt string `json:"format"` //
Data []string `json:"data"` //
RenderAfterExpand bool `json:"renderAfterExpand"` //
Multiple bool `json:"multiple"` //
Action string `json:"action"` //
ListType string `json:"listType"` //
Name string `json:"name"` //
AppendToBody bool `json:"appendToBody"` //
Clearable bool `json:"clearable"` //
} }
// 组件配置 // 组件配置
type UnitConfigStruct struct { type UnitConfigStruct struct {
ClassName string `json:"className"` //自定义样式 ClassName string `json:"className"` //自定义样式
Help string `json:"help"` //帮助信息
Span int `json:"span"` //占行范围 Span int `json:"span"` //占行范围
Prepend string `json:"prepend"` //对齐方式
Append string `json:"append"` //对齐方式
TextAlign string `json:"textAlign"` //对齐方式 TextAlign string `json:"textAlign"` //对齐方式
EditDisabled bool `json:"editDisabled"` // 页隐藏
DisabledAdd bool `json:"disabledAdd"` //添加页隐藏 DisabledAdd bool `json:"disabledAdd"` //添加页隐藏
DisabledEdit bool `json:"disabledEdit"` //编辑页隐藏
DisabledDetail bool `json:"disabledDetail"` //编辑页隐藏 DisabledDetail bool `json:"disabledDetail"` //编辑页隐藏
LinkKey bool `json:"linkKey"` //开启联动条件 LinkKey bool `json:"linkKey"` //开启联动条件
LinkValue string `json:"linkValue"` //联动条件内容 LinkValue string `json:"linkValue"` //联动条件内容
LinkResult string `json:"linkResult"` //联动条件内容
OptionsType int `json:"optionsType"` //选择数据源 0:固定选项;1:数据源;3:1接口字典 OptionsType int `json:"optionsType"` //选择数据源 0:固定选项;1:数据源;3:1接口字典
OptionsFun string `json:"optionsFun"` OptionsFun string `json:"optionsFun"`
Help string `json:"help"` //帮助信息 TransformData string `json:"transformData"` //值转换类型
AddBtnText string `json:"addBtnText"` //添加一行按钮(自定义布局中使用)
DelBtnText string `json:"delBtnText"` //删除一行按钮(自定义布局中使用)
BtnText string `json:"btnText"` //按钮文字
Label string `json:"label"` //指定label属性值
Value string `json:"value"` //指定value属性值
Method string `json:"method"` //
AddAll string `json:"addAll"` //
BeforeRequest interface{} `json:"beforeRequest"`
AfterResponse interface{} `json:"afterResponse"`
} }
// 表单信息 // 表单信息
type FormStruct struct { type FormStruct struct {
Size string `json:"size"` Size string `json:"size"`
Name string `json:"name"` FormName string `json:"formName"` //表单名称
LabelWidth string `json:"labelWidth"` Name string `json:"name"` //表单标识
Class string `json:"class"` LabelWidth string `json:"labelWidth"` //表单宽度
Class string `json:"class"` //表单样式
ShowColon bool `json:"showColon"` ShowColon bool `json:"showColon"`
} }
@ -97,3 +170,128 @@ type FormStruct struct {
type ConfigStruct struct { type ConfigStruct struct {
AddLoad bool `json:"addLoad"` AddLoad bool `json:"addLoad"`
} }
// 搜索自定义表单
type SearchForm struct {
publicmethod.PagesTurn
KeyWords string `json:"keywords"`
Classify int `json:"classify"`
}
// 输出表单列表
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"`
}
// 输出自定义表格基础信息
type SendCustomerFormConfig struct {
FormName string `json:"formname"`
FormLogo string `json:"formlogo"`
}
// 提交自定义表单数据
type HaveCustomerFormConfig struct {
Types int `json:"type"`
Name string `json:"name"`
Source string `json:"source"` // 数据源允许在表单属性设置里修改的
Dict string `json:"dict"`
Data string `json:"data"`
JsonData string `json:"jsondata"`
Classify int `json:"classify"` //分类1:表单;2:流程表单"
}
// 改变自定义报道状态
type EditCustomerFormStatus struct {
Id []string `json:"id"`
Status int `json:"status"`
IsDelete bool `json:"is_delete"`
}
// 输出查看详情信息
type LookCustomerFormInfo struct {
modelAppPlatform.CustomerFormView
States int `json:"states"`
PermitList [][]int64 `json:"permit_list"`
}
// 接收自定义表单设置数据
type HaveCustomerFormInfo struct {
publicmethod.CommonId[int64]
publicmethod.PublicName
States int `json:"states"`
Permit string `json:"permit"`
}
// 编辑自定义表单内容
type EditCustomerFormCont struct {
publicmethod.CommonId[string]
Version string `json:"version"`
HaveCustomerFormConfig
}
// 数据库表结构
type Result struct {
Field string `json:"field"`
Type string `json:"type"`
Attribute string `json:"attribute"`
Collation string `json:"collation"`
Null string `json:"null"`
Key string `json:"key"`
Default string `json:"default"`
Extra string `json:"extra"`
Privileges string `json:"privileges"`
Comment string `json:"comment"`
}
// 自定义表单数据结构版本及表单输出
type CustomerFormDatabaseVesion struct {
Version []PublicFormDatabaseVesion `json:"version"`
TableList []PublicFormDatabaseVesion `json:"tablelist"`
}
// 通用自定义表单数据结构
type PublicFormDatabaseVesion struct {
HaveVersionForm
IsMain bool `json:"ismain"`
IsEdit bool `json:"isedit"`
VersionId string `json:"versionid"`
}
// 获取版本表单
type HaveVersionForm struct {
publicmethod.CommonId[string]
publicmethod.PublicName
}
type OptimizeOrRepairTable struct {
publicmethod.PublicName
OptimizeOrRepair int `json:"optimizerender"` //1:优化;2:修复
}
// 输出字段拆析
type SendFieldCont struct {
Result
Integer string `json:"integer"` //整数部门
Decimal string `json:"decimal"` //小数部分
}
// 编辑数据库表单字段
type EditDatabaseFormField struct {
FormName string `json:"formname"` //
SendFieldCont
}
// 分析表单结构
type TableFormStruct struct {
TableName string `json:"tablename"` //字段名称
Types string `json:"types"` //组件类型
FieldLenght int `json:"fieldlenght"` //字段长度
ControlType string `json:"controlType"` //
DefaultValue interface{} `json:"defaultValue"` //
Signed bool `json:"signed"` //
}

4
api/version1/entry.go

@ -7,6 +7,8 @@ import (
matrixapi "appPlatform/api/version1/matrixApi" matrixapi "appPlatform/api/version1/matrixApi"
"appPlatform/api/version1/menus" "appPlatform/api/version1/menus"
"appPlatform/api/version1/publicapi" "appPlatform/api/version1/publicapi"
"appPlatform/api/version1/taskplatform/taskflow"
"appPlatform/api/version1/taskplatform/taskmanagement"
"appPlatform/api/version1/user" "appPlatform/api/version1/user"
) )
@ -18,6 +20,8 @@ type ApiEntry struct {
MatrixApi matrixapi.ApiMethod //权限矩阵 MatrixApi matrixapi.ApiMethod //权限矩阵
PublicApi publicapi.ApiMethod //公共方法 PublicApi publicapi.ApiMethod //公共方法
CustomerFormApi customerform.ApiMethod //自定表单 CustomerFormApi customerform.ApiMethod //自定表单
TaskManagementApi taskmanagement.ApiMethod
TaskFlowApi taskflow.ApiMethod
} }
var AppApiEntry = new(ApiEntry) var AppApiEntry = new(ApiEntry)

12
api/version1/menus/menus.go

@ -160,11 +160,13 @@ func (a *ApiMethod) AddNewMenu(c *gin.Context) {
menuCont.Component = requestData.Component //组件路径(vue页面完整路径,省略.vue后缀)"` menuCont.Component = requestData.Component //组件路径(vue页面完整路径,省略.vue后缀)"`
} }
menuCont.Perm = publicmethod.GetUUid(3) //权限标识"` menuCont.Perm = publicmethod.GetUUid(3) //权限标识"`
menuCont.Visible = requestData.Visible //显示状态(1:显示;2:隐藏,3:删除)"` menuCont.Visible = requestData.Visible //显示状态(1:显示;2:隐藏,3:删除)"`
menuCont.Sort = requestData.Sort //排序(数字越小排名越靠前))"` menuCont.Sort = requestData.Sort //排序(数字越小排名越靠前))"`
menuCont.Icon = requestData.Icon //菜单图标"` menuCont.Icon = requestData.Icon //菜单图标"`
menuCont.Redirect = requestData.Redirect //跳转路径"` if types != 1 {
menuCont.Redirect = requestData.Redirect //跳转路径"`
}
menuCont.ParentId = requestData.ParentId //父菜单ID"` menuCont.ParentId = requestData.ParentId //父菜单ID"`
menuCont.Time = time.Now().Unix() //创建时间"` menuCont.Time = time.Now().Unix() //创建时间"`
menuCont.Outside = requestData.Outside //1:内部使用;2:外部使用;3:内外使用"` menuCont.Outside = requestData.Outside //1:内部使用;2:外部使用;3:内外使用"`

53
api/version1/publicapi/api.go

@ -10,6 +10,7 @@ import (
"unicode" "unicode"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/mozillazg/go-pinyin"
) )
/* /*
@ -147,3 +148,55 @@ func (a *ApiMethod) GenerateSignCode(c *gin.Context) {
sendCode["code"] = signCode sendCode["code"] = signCode
publicmethod.Result(0, sendCode, c) publicmethod.Result(0, sendCode, c)
} }
/*
*
@ 作者: 秦东
@ 时间: 2023-09-26 11:51:43
@ 功能: 中文转拼音
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) ChineseToPinyin(c *gin.Context) {
var requestData HanziToPinyin
c.ShouldBindJSON(&requestData)
if requestData.Title == "" {
publicmethod.Result(1, requestData, c, "未知中文语句!")
return
}
pyObject := pinyin.NewArgs()
switch requestData.Types {
case 1:
pyObject.Style = pinyin.Tone
case 2:
pyObject.Style = pinyin.Tone2
case 3:
pyObject.Style = pinyin.Initials
case 4:
pyObject.Style = pinyin.FirstLetter
case 5:
pyObject.Style = pinyin.Finals
case 6:
pyObject.Style = pinyin.FinalsTone
case 7:
pyObject.Style = pinyin.FinalsTone2
case 8:
pyObject.Style = pinyin.Tone3
case 9:
pyObject.Style = pinyin.FinalsTone3
default:
pyObject.Style = pinyin.Normal
}
pyObject.Separator = requestData.Connector
str := pinyin.Slug(requestData.Title, pyObject)
publicmethod.Result(0, str, c)
}

7
api/version1/publicapi/type.go

@ -20,3 +20,10 @@ type SendUUID struct {
UuId int64 `json:"uuid"` UuId int64 `json:"uuid"`
UuIdString string `json:"uuidstring"` UuIdString string `json:"uuidstring"`
} }
// 汉字转拼音
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 所用的分隔符
}

813
api/version1/publicapi/组件结构.ts

@ -0,0 +1,813 @@
opt = {
list: [
{
type: "datePicker",
control:
{
modelValue: "",
type: "year",
format: "YYYY"
},
config:
{},
name: "nian2",
item:
{
label: "年"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "month"
},
config:
{},
name: "yue4",
item:
{
label: "月"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "date"
},
config:
{},
name: "ri4qi1",
item:
{
label: "日期"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "datetime"
},
config:
{},
name: "shi2jian1",
item:
{
label: "时间"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "week"
},
config:
{},
name: "zhou1",
item:
{
label: "周"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "datetimerange"
},
config:
{},
name: "shi2jian1zhou1qi1",
item:
{
label: "时间周期"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "daterange"
},
config:
{},
name: "ri4qi1zhou1qi1",
item:
{
label: "日期周期"
}
},
{
type: "datePicker",
control:
{
modelValue: "",
type: "monthrange"
},
config:
{},
name: "yue4zhou1qi1",
item:
{
label: "月周期"
}
},
{
type: "input",
control:
{
modelValue: ""
},
config:
{},
name: "wen2ben317478324",
item:
{
label: "文本"
}
},
{
type: "password",
control:
{
modelValue: ""
},
config:
{
prepend: "1",
append: "2"
},
name: "mi4ma3",
item:
{
label: "密码"
}
},
{
type: "textarea",
control:
{
modelValue: ""
},
config:
{},
name: "textarea1695711791732",
item:
{
label: "多行文本"
}
},
{
type: "radio",
control:
{
modelValue: ""
},
options: [
{
label: "男",
value: "1"
},
{
label: "女",
value: "2"
}],
config:
{
optionsType: 0,
transformData: "number"
},
name: "dan1xuan3kuang1zu3gu4ding4xuan3xiang4",
item:
{
label: "单选框组(固定选项)"
}
},
{
type: "radio",
control:
{
modelValue: ""
},
options: [],
config:
{
optionsType: 1,
optionsFun: "http://www.api.com/api",
method: "post",
label: "name",
value: "id"
},
name: "dxansjymoren",
item:
{
label: "单选框组数据源(默认)"
}
},
{
type: "radio",
control:
{
modelValue: ""
},
options: [],
config:
{
optionsType: 2,
optionsFun: "kjh",
transformData: "string"
},
name: "radio1695711963706",
item:
{
label: "单选框组"
}
},
{
type: "checkbox",
control:
{
modelValue: []
},
options: [
{
label: "书",
value: "1"
},
{
label: "笔",
value: "2"
},
{
label: "墨",
value: "3"
}],
config:
{
optionsType: 0,
transformData: "number"
},
name: "checkbox1695712007255",
item:
{
label: "多选框组"
}
},
{
type: "select",
control:
{
modelValue: "",
appendToBody: true
},
options: [
{
label: "笔",
value: "1"
},
{
label: "墨",
value: "2"
},
{
label: "纸",
value: "3"
},
{
label: "砚",
value: "4"
}],
config:
{
optionsType: 0,
addAll: "全部",
transformData: "number"
},
name: "select1695712048045",
item:
{
label: "下拉选择框"
}
},
{
type: "timePicker",
control:
{
modelValue: "",
format: ""
},
config:
{},
name: "timePicker1695712127740",
item:
{
label: "时间选择器"
}
},
{
type: "colorPicker",
control:
{
modelValue: "",
colorFormat: "rgb"
},
config:
{},
name: "colorPicker1695712229351",
item:
{
label: "取色器"
}
},
{
type: "switch",
control:
{
modelValue: false,
activeValue: 1,
inactiveValue: 2
},
config:
{},
name: "switch1695712256687",
item:
{
label: "开关"
}
},
{
type: "inputNumber",
control:
{
modelValue: 0
},
config:
{},
name: "inputNumber1695712298560",
item:
{
label: "计数器"
}
},
{
type: "cascader",
control:
{
modelValue: []
},
options: [
{
value: "guide",
label: "Guide",
children: [
{
value: "disciplines",
label: "Disciplines",
children: [
{
value: "consistency",
label: "Consistency"
},
{
value: "feedback",
label: "Feedback"
},
{
value: "efficiency",
label: "Efficiency"
},
{
value: "controllability",
label: "Controllability"
}]
},
{
value: "navigation",
label: "Navigation",
children: [
{
value: "side nav",
label: "Side Navigation"
},
{
value: "top nav",
label: "Top Navigation"
}]
}]
},
{
value: "component",
label: "Component",
children: [
{
value: "basic",
label: "Basic",
children: [
{
value: "layout",
label: "Layout"
},
{
value: "color",
label: "Color"
},
{
value: "typography",
label: "Typography"
},
{
value: "icon",
label: "Icon"
},
{
value: "button",
label: "Button"
}]
},
{
value: "form",
label: "Form",
children: [
{
value: "radio",
label: "Radio"
},
{
value: "checkbox",
label: "Checkbox"
},
{
value: "input",
label: "Input"
},
{
value: "input-number",
label: "InputNumber"
},
{
value: "select",
label: "Select"
},
{
value: "cascader",
label: "Cascader"
},
{
value: "switch",
label: "Switch"
},
{
value: "slider",
label: "Slider"
},
{
value: "time-picker",
label: "TimePicker"
},
{
value: "date-picker",
label: "DatePicker"
},
{
value: "datetime-picker",
label: "DateTimePicker"
},
{
value: "upload",
label: "Upload"
},
{
value: "rate",
label: "Rate"
},
{
value: "form",
label: "Form"
}]
},
{
value: "data",
label: "Data",
children: [
{
value: "table",
label: "Table"
},
{
value: "tag",
label: "Tag"
},
{
value: "progress",
label: "Progress"
},
{
value: "tree",
label: "Tree"
},
{
value: "pagination",
label: "Pagination"
},
{
value: "badge",
label: "Badge"
}]
},
{
value: "notice",
label: "Notice",
children: [
{
value: "alert",
label: "Alert"
},
{
value: "loading",
label: "Loading"
},
{
value: "message",
label: "Message"
},
{
value: "message-box",
label: "MessageBox"
},
{
value: "notification",
label: "Notification"
}]
},
{
value: "navigation",
label: "Navigation",
children: [
{
value: "menu",
label: "Menu"
},
{
value: "tabs",
label: "Tabs"
},
{
value: "breadcrumb",
label: "Breadcrumb"
},
{
value: "dropdown",
label: "Dropdown"
},
{
value: "steps",
label: "Steps"
}]
},
{
value: "others",
label: "Others",
children: [
{
value: "dialog",
label: "Dialog"
},
{
value: "tooltip",
label: "Tooltip"
},
{
value: "popover",
label: "Popover"
},
{
value: "card",
label: "Card"
},
{
value: "carousel",
label: "Carousel"
},
{
value: "collapse",
label: "Collapse"
}]
}]
},
{
value: "resource",
label: "Resource",
children: [
{
value: "axure",
label: "Axure Components"
},
{
value: "sketch",
label: "Sketch Templates"
},
{
value: "docs",
label: "Design Documentation"
}]
}],
config:
{
optionsType: 0,
transformData: "number"
},
name: "cascader1695712324832",
item:
{
label: "级联选择器"
}
},
{
type: "rate",
control:
{
modelValue: 0,
max: 10
},
config:
{},
name: "rate1695712405129",
item:
{
label: "评分"
}
},
{
type: "slider",
control:
{
modelValue: 0,
min: 0,
max: 10,
step: 1
},
config:
{},
name: "slider1695712423938",
item:
{
label: "滑块"
}
},
{
type: "treeSelect",
control:
{
modelValue: "",
data: [
{
label: "Level one 1",
children: [
{
label: "Level two 1-1",
children: [
{
label: "Level three 1-1-1"
}]
}]
},
{
label: "Level one 2",
children: [
{
label: "Level two 2-1",
children: [
{
label: "Level three 2-1-1"
}]
},
{
label: "Level two 2-2",
children: [
{
label: "Level three 2-2-1"
}]
}]
},
{
label: "Level one 3",
children: [
{
label: "Level two 3-1",
children: [
{
label: "Level three 3-1-1"
}]
},
{
label: "Level two 3-2",
children: [
{
label: "Level three 3-2-1"
}]
}]
}],
renderAfterExpand: false
},
config:
{
optionsType: 0,
transformData: "number"
},
name: "treeSelect1695712442351",
item:
{
label: "树形控件"
}
},
{
type: "txt",
control:
{
modelValue: "文字描述"
},
config:
{}
},
{
type: "title",
control:
{
modelValue: "标题空间"
},
config:
{}
},
{
type: "upload",
control:
{
modelValue: "",
action: "/api/upordown"
},
config:
{},
name: "upload1695712574412",
item:
{
label: "图片/文件"
}
},
{
type: "tinymce",
control:
{
modelValue: ""
},
config:
{},
name: "tinymce1695712627245",
item:
{
label: "富文本"
}
},
{
type: "expand-user",
control:
{
modelValue: ""
},
config:
{},
name: "expand-user1695712647280",
item:
{
label: "选择用户"
}
},
{
type: "button",
control:
{
label: "按钮",
key: "submit"
},
config:
{
textAlign: "center"
}
}],
form:
{
size: "default",
name: "customer_form_167271084951867392",
formName: "所有空间验证"
},
config:
{}
}

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

@ -0,0 +1,36 @@
package taskflow
import (
"appPlatform/overall/publicmethod"
"sync"
"github.com/gin-gonic/gin"
)
// 协程设置
var syncSeting = sync.WaitGroup{}
type ApiMethod struct{}
/*
*
@ 作者: 秦东
@ 时间: 2023-05-25 10:20:11
@ 功能:自定义表单流程表单列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) Index(c *gin.Context) {
outputCont := publicmethod.MapOut[string]()
outputCont["index"] = "流程表单内容列表入口"
publicmethod.Result(0, outputCont, c)
}

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

@ -0,0 +1,479 @@
package taskmanagement
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"errors"
"fmt"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-09-21 15:19:03
@ 功能: 非流程表单提交数据记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AppFormDataLog(c *gin.Context) {
var requestData AppFormDataLogStruct
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.Page = 15
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context)
var list []modelAppPlatform.Task
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Task{}).Where("`status` BETWEEN ? AND ? AND `creater` = ?", 1, 4, userCont.Key)
if requestData.KeyWords != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.KeyWords+"%")
}
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(&list).Error
if err != nil && len(list) < 1 {
publicmethod.Result(0, err, c)
return
}
var sendList []SendAppFormDataLog
for _, v := range list {
var sendCont SendAppFormDataLog
sendCont.Id = v.Id //dex"`
sendCont.Title = v.Title //标题"`
sendCont.Creater = v.Creater //创建人"`
sendCont.CreaterTime = v.CreaterTime //创建时间"`
sendCont.EditTime = v.EditTime //编辑时间"`
sendCont.Types = v.Types //类型(1:普通表单;2:流程表单)"`
sendCont.VersionId = v.VersionId //来源于哪个表单"`
sendCont.Status = v.Status //
var myConst modelshr.PersonArchives
myConst.GetCont(map[string]interface{}{"`key`": v.Creater}, "`number`", "`name`")
sendCont.CreaterName = myConst.Name
sendCont.CreaterNumber = myConst.Number
sendCont.CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
sendCont.MastersKey = v.MastersKey
sendCont.MastersKeyStr = strconv.FormatInt(v.MastersKey, 10)
sendList = append(sendList, sendCont)
}
// publicmethod.Result(0, sendList, c)
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-22 11:04:56
@ 功能: 获取可执行得任务列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainTaskList(c *gin.Context) {
var requestData GainTaskListStruct
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.Page = 15
}
if requestData.Status == 0 {
requestData.Status = 1
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context)
var list []modelAppPlatform.CustomerFormView
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormView{}).Where("`status` = 1")
//获取当前登录人得行政组织关系
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSun(userCont.AdminOrg)
sunOrg.GetOrgParentAllId(userCont.AdminOrg)
sunOrg.Id = append(sunOrg.Id, userCont.AdminOrg)
if len(sunOrg.Id) > 0 {
gormDb = gormDb.Where("ISNULL(permitstr) OR permitstr = ''")
var sqlStr string
for i, v := range sunOrg.Id {
if i < len(sunOrg.Id)-1 {
sqlStr = fmt.Sprintf("%v FIND_IN_SET(%v,`permitstr`) OR ", sqlStr, v)
} else {
sqlStr = fmt.Sprintf("%v FIND_IN_SET(%v,`permitstr`) ", sqlStr, v)
}
// gormDb = gormDb.Or("FIND_IN_SET(?,`permitstr`)", v)
}
gormDb = gormDb.Or(sqlStr)
} else {
gormDb = gormDb.Where("ISNULL(permitstr) OR permitstr = ''", sunOrg.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("`time` DESC").Order("`id` DESC").Find(&list).Error
if err != nil && len(list) < 1 {
publicmethod.Result(0, err, c)
return
}
var sendList []SendTaskList
for _, v := range list {
var sendCont SendTaskList
sendCont.Id = strconv.FormatInt(v.Id, 10)
sendCont.Name = v.Name
var myInfo modelshr.PersonArchives
myInfo.GetCont(map[string]interface{}{"`key`": v.Creater}, "`number`", "`name`")
sendCont.CreaterName = myInfo.Name
sendCont.CreaterNumber = myInfo.Number
sendCont.CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 1)
sendList = append(sendList, sendCont)
}
// publicmethod.Result(0, sendList, c)
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-23 13:51:58
@ 功能: 根据版本获取表单内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GianTaskVersionCont(c *gin.Context) {
var requestData publicmethod.CommonId[string]
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(107, err, c)
return
}
var versionCont modelAppPlatform.CustomerFormView
err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
publicmethod.Result(0, versionCont, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-25 11:42:35
@ 功能: 自定义表单新增记录数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CustomerFormAddData(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
sendData := publicmethod.MapOut[string]()
if _, ok := mapData["formId"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
}
var formCont modelAppPlatform.CustomerFormView
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
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)
}
}
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context)
uuid := publicmethod.GetUUid(1)
cureeTime := time.Now().Unix()
masterFrom := publicmethod.MapOut[string]()
masterFrom["masters_key"] = uuid
masterFrom["creater"] = userCont.Key
masterFrom["creater_time"] = cureeTime
masterFrom["edit_time"] = cureeTime
sunFormList := publicmethod.MapOut[string]()
for k, v := range mapData {
// fmt.Printf("key: %v, value: %v\n", k, v)
if !publicmethod.IsInTrue[string](k, sunFormName) {
if !publicmethod.IsInTrue[string](k, []string{"formId", "id"}) {
masterFrom[k] = v
}
} else {
sunFormList[k] = v
}
}
var taskCont modelAppPlatform.Task
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 = 1 //类型(1:普通表单;2:流程表单)"`
taskCont.VersionId = formCont.Id //来源于哪个表单"`
taskCont.Status = 2 //状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"`
if len(sunFormList) > 0 {
WriteDatabase(uuid, userCont.Key, cureeTime, taskCont, formCont.TableKey, masterFrom, sunFormList)
} else {
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masterFrom).Error
overall.CONSTANT_DB_AppPlatform.Create(&taskCont)
}
sendData["err"] = err
sendData["data"] = data
sendData["mapData"] = mapData
sendData["formCont"] = formCont
sendData["masterFrom"] = masterFrom
sendData["sunFormList"] = sunFormList
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-25 14:33:51
@ 功能: 写入数据库
@ 参数
#uuid 唯一标识
#creater 创建人
#createrTime 创建时间
#taskCont 主记录表
#masterTableName 主表标识
#masterDataCont 主表数据
#sunDataList 字表数据列表
@ 返回值
#err 返回信息
@ 方法原型
#func WriteDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}) (err error)
*/
func WriteDatabase(uuid, creater, createrTime int64, taskCont modelAppPlatform.Task, masterTableName string, masterDataCont, sunDataList map[string]interface{}) (err error) {
if len(sunDataList) > 0 && len(masterDataCont) > 0 {
sunMasterMap := publicmethod.MapOut[string]()
for k, v := range sunDataList {
s, ok := v.([]interface{})
if !ok {
err = errors.New("表单数据错误!请验证后重新提交!")
return
} else {
if len(s) > 0 {
var sunCont []map[string]interface{}
for _, sv := range s {
if sdf, isOk := sv.(map[string]interface{}); isOk {
for sdk, sdv := range sdf {
if fieldVal, filedIsok := sdv.(bool); filedIsok {
if fieldVal {
sdf[sdk] = 1
} else {
sdf[sdk] = 2
}
}
}
sdf["masters_key"] = uuid
sdf["creater"] = creater
sdf["creater_time"] = createrTime
sdf["edit_time"] = createrTime
sunCont = append(sunCont, sdf)
}
}
sunMasterMap[k] = sunCont
}
}
}
if len(sunMasterMap) < 1 {
err = overall.CONSTANT_DB_CustomerForm.Table(masterTableName).Create(masterDataCont).Error
overall.CONSTANT_DB_AppPlatform.Create(&taskCont)
} else {
gormDb := overall.CONSTANT_DB_CustomerForm.Begin()
masterErr := gormDb.Table(masterTableName).Create(masterDataCont).Error
taskErr := overall.CONSTANT_DB_AppPlatform.Create(&taskCont).Error
sunCreateIsOk := true
for k, v := range sunMasterMap {
sunErr := gormDb.Table(k).Create(v).Error
if sunErr != nil {
sunCreateIsOk = false
break
}
// fmt.Printf("234----->%v----->%v\n", k, v)
}
if masterErr == nil && taskErr == nil && sunCreateIsOk {
err = gormDb.Commit().Error
} else {
gormDb.Rollback()
err = errors.New("表单数据提交失败!请重新提交")
}
}
} else {
err = errors.New("表单数据错误!请验证后重新提交!")
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-25 11:45:08
@ 功能: 自定义表单编辑记录数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CustomerFormEditData(c *gin.Context) {
requestData := publicmethod.MapOut[string]()
err := c.ShouldBindQuery(&requestData)
sendData := publicmethod.MapOut[string]()
sendData["err"] = err
sendData["requestData"] = sendData
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-25 11:45:08
@ 功能: 查看自定义表单记录数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) LookCustomerFormData(c *gin.Context) {
var requestData GainCustomerFormLogInfo
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!")
return
}
if requestData.MastersKey == "" {
publicmethod.Result(1, err, c, "未知表单参数!请核对2后重新提交!")
return
}
var customerFormCont modelAppPlatform.CustomerFormView
err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.MastersKey}, "`tablekey`", "`table_structure`", "`name`", "`classify`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
masterFormCont := publicmethod.MapOut[string]()
err = overall.CONSTANT_DB_CustomerForm.Table(customerFormCont.TableKey).Where("`masters_key` = ?", requestData.Id).Find(&masterFormCont).Error
if customerFormCont.TableStructure != "" {
sunFormTable := publicmethod.MapOut[string]()
err = json.Unmarshal([]byte(customerFormCont.TableStructure), &sunFormTable)
if err == nil {
for _, v := range sunFormTable {
var sunContList []map[string]interface{}
if tableName, isOk := v.(string); isOk {
overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`masters_key` = ?", requestData.Id).Find(&sunContList)
masterFormCont[tableName] = sunContList
}
}
}
}
sendData := publicmethod.MapOut[string]()
sendData["err"] = err
sendData["customerFormCont"] = customerFormCont
sendData["masterFormCont"] = masterFormCont
publicmethod.Result(0, masterFormCont, c)
}

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

@ -0,0 +1,73 @@
package taskmanagement
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/overall/publicmethod"
"sync"
"github.com/gin-gonic/gin"
)
// 协程设置
var syncSeting = sync.WaitGroup{}
type ApiMethod struct{}
/*
*
@ 作者: 秦东
@ 时间: 2023-05-25 10:20:11
@ 功能:自定义表单非流程表单列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) Index(c *gin.Context) {
outputCont := publicmethod.MapOut[string]()
outputCont["index"] = "非流程表单内容列表入口"
publicmethod.Result(0, outputCont, c)
}
// 非流程表单提交数据记录参数
type AppFormDataLogStruct struct {
publicmethod.PagesTurn
KeyWords string `json:"keywords"`
}
// 返回非流程表单记录数据
type SendAppFormDataLog struct {
modelAppPlatform.Task
CreaterName string `json:"createrName"`
CreaterNumber string `json:"createrNumber"`
CreaterTimeStr string `json:"createrTame"`
MastersKeyStr string `json:"mastersKeyStr"`
}
// 获取可执行得任务列表
type GainTaskListStruct struct {
publicmethod.PagesTurn
publicmethod.PublicStatus
}
// 输出可执行得任务列表内容
type SendTaskList struct {
publicmethod.CommonId[string]
publicmethod.PublicName
CreaterName string `json:"createrName"`
CreaterNumber string `json:"createrNumber"`
CreaterTimeStr string `json:"createrTame"`
}
// 获取表单详细内容
type GainCustomerFormLogInfo struct {
publicmethod.CommonId[string]
MastersKey string `json:"formId"`
}

9
apirouter/apishiyan/maptostruct.go

@ -18,5 +18,14 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("charparking", methodBinding.CharParking) //获取车场车位信息 apiRouter.POST("charparking", methodBinding.CharParking) //获取车场车位信息
apiRouter.POST("testpage", methodBinding.TestPage) //获取车场车位信息 apiRouter.POST("testpage", methodBinding.TestPage) //获取车场车位信息
apiRouter.POST("canshu", methodBinding.Canshu) //获取车场车位信息
apiRouter.POST("create_table", methodBinding.CreateTable) //模拟创建表单
apiRouter.POST("qianyi_version", methodBinding.QianyiVersion) //改革自定义表单列表
apiRouter.POST("LookTableStruct", methodBinding.LookTableStruct) //查询表结构
apiRouter.POST("hzzpy", methodBinding.HanZiZhuanPinYin) //汉字转拼音
} }
} }

2
apirouter/entry.go

@ -9,6 +9,7 @@ import (
matrixrouters "appPlatform/apirouter/v1/matrixRouters" matrixrouters "appPlatform/apirouter/v1/matrixRouters"
menusrouters "appPlatform/apirouter/v1/menusRouters" menusrouters "appPlatform/apirouter/v1/menusRouters"
"appPlatform/apirouter/v1/public" "appPlatform/apirouter/v1/public"
"appPlatform/apirouter/v1/taskrouter"
userrouters "appPlatform/apirouter/v1/userRouters" userrouters "appPlatform/apirouter/v1/userRouters"
) )
@ -23,6 +24,7 @@ type RouterGroup struct {
PublicRouters public.ApiRouter PublicRouters public.ApiRouter
SignCodeRouter authenticationroute.ApiRouter SignCodeRouter authenticationroute.ApiRouter
CustomerFormRouter customerformrouter.ApiRouter CustomerFormRouter customerformrouter.ApiRouter
TaskRouter taskrouter.ApiRouter
} }
var RouterGroupEntry = new(RouterGroup) var RouterGroupEntry = new(RouterGroup)

22
apirouter/v1/customerformrouter/router.go

@ -12,7 +12,25 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
var methodBinding = version1.AppApiEntry.CustomerFormApi var methodBinding = version1.AppApiEntry.CustomerFormApi
{ {
apiRouter.GET("", methodBinding.Index) //入口 apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口 apiRouter.POST("", methodBinding.Index) //入口
apiRouter.POST("customer_form_list", methodBinding.CustomerFormList) //自定义表单列表
apiRouter.POST("production_mark_form", methodBinding.ProductionMarkOfCustomerForm) //生成表单基本信息
apiRouter.POST("save_customer_form", methodBinding.SaveCustomerForm) //保存自定义表单
apiRouter.POST("look_customer_form", methodBinding.LookCustomerForm) //查看自定义表单
apiRouter.POST("edit_customer_form_status", methodBinding.EditCustomerFormStatus) //编辑自定义表单状态
apiRouter.POST("save_setup_cont", methodBinding.SaveSetupCont) //编辑自定义表单设置
apiRouter.POST("have_customer_form_version", methodBinding.HaveCustomerFormVersion) //获取版本列表
apiRouter.POST("edit_customer_form_info", methodBinding.EditCustomerFormInfo) //编辑自定义表单内容
apiRouter.POST("save_as_new_version", methodBinding.SaveAsNewVersion) //另存为新版
apiRouter.POST("enable_version", methodBinding.EnableVersion) //启用版本
apiRouter.POST("judge_submit_cancel", methodBinding.JudgeSubmitCancel) //检测是否存在提交和返回按钮
apiRouter.POST("have_database_table_struct", methodBinding.HaveDataBaseTableStruct) //数据库表结构(版本及数据表)
apiRouter.POST("have_form_tabelcont", methodBinding.HaveFormTabelCont) //获取表单结构
apiRouter.POST("have_form_tablelist", methodBinding.HaveFormTableList) //根据版本获取数据库表集合
apiRouter.POST("optimize_repair_form", methodBinding.OptimizeOrRepairFormTable) //优化/修复数据表
apiRouter.POST("form_field_handle", methodBinding.FormFieldHandle) //表单结构数据处理
apiRouter.POST("edit_form_field", methodBinding.EditFormField) //编辑数据库表字段信息
} }
} }

1
apirouter/v1/public/router.go

@ -17,5 +17,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("chinese_initial", methodBinding.ChineseInitial) //获取汉字首字母 apiRouter.POST("chinese_initial", methodBinding.ChineseInitial) //获取汉字首字母
apiRouter.POST("send_number", methodBinding.SendNumber) //输出编号 apiRouter.POST("send_number", methodBinding.SendNumber) //输出编号
apiRouter.POST("generate_sign_code", methodBinding.GenerateSignCode) //生成身份验证唯一识别符 apiRouter.POST("generate_sign_code", methodBinding.GenerateSignCode) //生成身份验证唯一识别符
apiRouter.POST("chinese_to_pinyin", methodBinding.ChineseToPinyin) //中文转拼音
} }
} }

31
apirouter/v1/taskrouter/taskrouter.go

@ -0,0 +1,31 @@
package taskrouter
import (
"appPlatform/api/version1"
"github.com/gin-gonic/gin"
)
// 工作台
func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter := router.Group("task_management")
var taskManagementRouter = version1.AppApiEntry.TaskManagementApi
{
apiRouter.GET("", taskManagementRouter.Index) //入口
apiRouter.POST("", taskManagementRouter.Index) //入口
apiRouter.POST("app_formdata_log", taskManagementRouter.AppFormDataLog) //非流程表单提交数据记录
apiRouter.POST("gain_task_list", taskManagementRouter.GainTaskList) //获取可执行得任务列表
apiRouter.POST("gain_task_versioncont", taskManagementRouter.GianTaskVersionCont) //根据版本获取表单内容
apiRouter.POST("customer_form_adddata", taskManagementRouter.CustomerFormAddData) //自定义表单新增记录数据
apiRouter.POST("customer_form_editdata", taskManagementRouter.CustomerFormEditData) //自定义表单编辑记录数据
apiRouter.POST("look_customer_formdata", taskManagementRouter.LookCustomerFormData) //查看自定义表单记录数据列表
}
taskFlowApi := router.Group("task_flow")
var taskFlowRouter = version1.AppApiEntry.TaskFlowApi
{
taskFlowApi.GET("", taskFlowRouter.Index) //入口
taskFlowApi.POST("", taskFlowRouter.Index) //入口
}
}

4
apirouter/v1/taskrouter/type.go

@ -0,0 +1,4 @@
package taskrouter
//公共路由
type ApiRouter struct{}

1
config/configDatabase/database.go

@ -30,6 +30,7 @@ type MysqlSetUp struct {
Storage MasterMysqlSetUp `mapstructure:"storage" json:"storage" yaml:"storage"` //仓储系统数据库 Storage MasterMysqlSetUp `mapstructure:"storage" json:"storage" yaml:"storage"` //仓储系统数据库
ServerMaster MasterMysqlSetUp `mapstructure:"servermaster" json:"servermaster" yaml:"servermaster"` //仓储系统数据库 ServerMaster MasterMysqlSetUp `mapstructure:"servermaster" json:"servermaster" yaml:"servermaster"` //仓储系统数据库
TidbrMaster MasterMysqlSetUp `mapstructure:"tidbrmaster" json:"tidbrmaster" yaml:"tidbrmaster"` //仓储系统数据库 TidbrMaster MasterMysqlSetUp `mapstructure:"tidbrmaster" json:"tidbrmaster" yaml:"tidbrmaster"` //仓储系统数据库
CustomerForm MasterMysqlSetUp `mapstructure:"customerFormDatabase" json:"customerFormDatabase" yaml:"customerFormDatabase"` //自定义表单数据库
} }
type MasterMysqlSetUp struct { type MasterMysqlSetUp struct {

6
initialization/databaseinit/mysql.go

@ -142,4 +142,10 @@ func LoadDatabase() {
} else { } else {
fmt.Printf("%v数据库开启成功!私有云服务器\n", sqlConfig.TidbrMaster.Name) fmt.Printf("%v数据库开启成功!私有云服务器\n", sqlConfig.TidbrMaster.Name)
} }
overall.CONSTANT_DB_CustomerForm = sqlConfig.CustomerForm.OpenSql()
if overall.CONSTANT_DB_Tidb == nil {
fmt.Printf("%v数据库开启失败!服务器\n", sqlConfig.CustomerForm.Name)
} else {
fmt.Printf("%v数据库开启成功!服务器\n", sqlConfig.CustomerForm.Name)
}
} }

3
initialization/route/initRoute.go

@ -64,6 +64,9 @@ func InitialRouter() *gin.Engine {
//自定义表单 //自定义表单
customerFormRouterApi := apirouter.RouterGroupEntry.CustomerFormRouter customerFormRouterApi := apirouter.RouterGroupEntry.CustomerFormRouter
customerFormRouterApi.RouterGroupPc(VerifyIdentity) customerFormRouterApi.RouterGroupPc(VerifyIdentity)
//工作台
taskRouterApi := apirouter.RouterGroupEntry.TaskRouter
taskRouterApi.RouterGroupPc(VerifyIdentity)
} }
//验证身份接口 无需鉴权Url(主要web端使用) //验证身份接口 无需鉴权Url(主要web端使用)
VerifyIdentityWeb := router.Group("") VerifyIdentityWeb := router.Group("")

70
models/modelAppPlatform/customer_form.go

@ -0,0 +1,70 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
// 字典类型
type CustomerForm struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"`
TableNames string `json:"tablename" gorm:"column:tablename;type:varchar(255) unsigned;default:'';not null;comment:创建表单名称"`
Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"`
Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"`
PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"`
States int `json:"states" gorm:"column:states;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
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:编辑时间"`
// MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
// MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
// Creater int64 `json:"creater" gorm:"column:creater;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:字表结构"`
}
func (CustomerForm *CustomerForm) TableName() string {
return "customer_form"
}
// 编辑内容
func (cont *CustomerForm) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *CustomerForm) 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 *CustomerForm) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *CustomerForm) ContMap(whereMap interface{}, field ...string) (countAry []CustomerForm, 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 *CustomerForm) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

66
models/modelAppPlatform/customer_form_version.go

@ -0,0 +1,66 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
// 自定义表单版本列表
type CustomerFormVersion struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"`
Version int64 `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime int64 `json:"time" gorm:"column: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:编辑时间"`
TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"`
Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"`
}
func (CustomerFormVersion *CustomerFormVersion) TableName() string {
return "customer_form_version"
}
// 编辑内容
func (cont *CustomerFormVersion) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *CustomerFormVersion) 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 *CustomerFormVersion) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *CustomerFormVersion) ContMap(whereMap interface{}, field ...string) (countAry []CustomerFormVersion, 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 *CustomerFormVersion) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

71
models/modelAppPlatform/customer_form_view.go

@ -0,0 +1,71 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
// 自定义表单版本列表
type CustomerFormView struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"`
Version int `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime int64 `json:"time" gorm:"column: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:编辑时间"`
TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"`
Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"`
CfId int64 `json:"cfid" gorm:"column:cfid;type:int(5) unsigned;not null;comment:Id"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"`
Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"`
Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"`
PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"`
}
func (CustomerFormView *CustomerFormView) TableName() string {
return "customer_form_view"
}
// 编辑内容
func (cont *CustomerFormView) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *CustomerFormView) 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 *CustomerFormView) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *CustomerFormView) ContMap(whereMap interface{}, field ...string) (countAry []CustomerFormView, 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 *CustomerFormView) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

64
models/modelAppPlatform/task.go

@ -0,0 +1,64 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
// 行政组织类型
type Task 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:主表标识"`
}
func (Task *Task) TableName() string {
return "task"
}
// 编辑内容
func (cont *Task) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *Task) 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 *Task) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *Task) ContMap(whereMap interface{}, field ...string) (countAry []Task, 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 *Task) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

11
models/modelshr/man_cont.go

@ -2,6 +2,7 @@ package modelshr
import ( import (
"appPlatform/overall" "appPlatform/overall"
"encoding/json"
"strings" "strings"
) )
@ -74,3 +75,13 @@ func (cont *ManCont) GetCont(whereMap interface{}, field ...string) (err error)
err = gormDb.First(&cont).Error err = gormDb.First(&cont).Error
return return
} }
// 获取当前登录信息
func (c *ManCont) GetLoginCont(context any) (err error) {
jsonCont, err := json.Marshal(context)
if err != nil {
return
}
err = json.Unmarshal(jsonCont, c)
return
}

1
models/modelsschool/test_paper.go

@ -11,6 +11,7 @@ type TestPaper struct {
UserKey int64 `json:"tp_u_key" gorm:"column:tp_u_key;type:bigint(20) unsigned;default:0;not null;comment:员工唯一识别符"` UserKey int64 `json:"tp_u_key" gorm:"column:tp_u_key;type:bigint(20) unsigned;default:0;not null;comment:员工唯一识别符"`
ExamKey int64 `json:"tp_exa_key" gorm:"column:tp_exa_key;type:bigint(20) unsigned;default:0;not null;comment:考试项目唯一识别符"` ExamKey int64 `json:"tp_exa_key" gorm:"column:tp_exa_key;type:bigint(20) unsigned;default:0;not null;comment:考试项目唯一识别符"`
RightKey string `json:"tp_right_key" gorm:"column:tp_right_key;type:mediumtext;default:'';comment:正确答案"` RightKey string `json:"tp_right_key" gorm:"column:tp_right_key;type:mediumtext;default:'';comment:正确答案"`
TpExaQue string `json:"tp_exa_que" gorm:"column:tp_exa_que;type:mediumtext;default:'';comment:试卷Json格式"`
UserReply string `json:"tp_reply" gorm:"column:tp_reply;type:mediumtext;default:'';comment:员工提交答案"` UserReply string `json:"tp_reply" gorm:"column:tp_reply;type:mediumtext;default:'';comment:员工提交答案"`
Fraction int `json:"tp_fraction" gorm:"column:tp_fraction;type:int(5);default:1;not null;comment:分数"` Fraction int `json:"tp_fraction" gorm:"column:tp_fraction;type:int(5);default:1;not null;comment:分数"`
SumFraction int `json:"tp_sum_fraction" gorm:"column:tp_sum_fraction;type:int(5);default:1;not null;comment:总分"` SumFraction int `json:"tp_sum_fraction" gorm:"column:tp_sum_fraction;type:int(5);default:1;not null;comment:总分"`

2
overall/appConfig.go

@ -42,6 +42,8 @@ var (
CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库
CONSTANT_DB_Storage *gorm.DB //仓储系统数据库 CONSTANT_DB_Storage *gorm.DB //仓储系统数据库
CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库
CONSTANT_DB_Server *gorm.DB //线上数据库 CONSTANT_DB_Server *gorm.DB //线上数据库
CONSTANT_DB_Tidb *gorm.DB //私有云数据库 CONSTANT_DB_Tidb *gorm.DB //私有云数据库
//Redis //Redis

128
overall/publicmethod/technique.go

@ -2245,3 +2245,131 @@ func MenuTypeToInt(class string) int {
} }
return 2 return 2
} }
/*
*
@ 作者: 秦东
@ 时间: 2023-09-14 13:33:12
@ 功能: 获取指定括号中的数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func MatchBracket(s, starBracket, endBracket string) string {
i := strings.Index(s, starBracket)
if i >= 0 {
// fmt.Printf("match-i-->%v\n", i)
j := strings.Index(s[i:], endBracket)
if j >= 0 {
// fmt.Printf("match-j-->%v-->%v\n", j, s[i+1:i+j])
return s[i+1 : i+j]
}
}
return ""
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-14 16:01:13
@ 功能: 通用执行SQL原生语句
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func ExecSql(database, sqlStr string) (err error) {
switch database {
case "Master":
err = overall.CONSTANT_DB_Master.Exec(sqlStr).Error
case "AppPlatform":
err = overall.CONSTANT_DB_AppPlatform.Exec(sqlStr).Error
case "Wechat":
err = overall.CONSTANT_DB_Wechat.Exec(sqlStr).Error
case "HR":
err = overall.CONSTANT_DB_HR.Exec(sqlStr).Error
case "FILE_BOOK":
err = overall.CONSTANT_DB_FILE_BOOK.Exec(sqlStr).Error
case "ERROR_SUBJECT":
err = overall.CONSTANT_DB_ERROR_SUBJECT.Exec(sqlStr).Error
case "MY_TEST":
err = overall.CONSTANT_DB_MY_TEST.Exec(sqlStr).Error
case "SCORING":
err = overall.CONSTANT_DB_SCORING.Exec(sqlStr).Error
case "QA":
err = overall.CONSTANT_DB_QA.Exec(sqlStr).Error
case "BILLBOARD":
err = overall.CONSTANT_DB_BILLBOARD.Exec(sqlStr).Error
case "HEALTH":
err = overall.CONSTANT_DB_HEALTH.Exec(sqlStr).Error
case "KPI":
err = overall.CONSTANT_DB_KPI.Exec(sqlStr).Error
case "WECHAT_LOG":
err = overall.CONSTANT_DB_WECHAT_LOG.Exec(sqlStr).Error
case "MANAGE_ARCHIVES":
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Exec(sqlStr).Error
case "System_Permission":
err = overall.CONSTANT_DB_System_Permission.Exec(sqlStr).Error
case "DB_Storage":
err = overall.CONSTANT_DB_Storage.Exec(sqlStr).Error
case "DB_Server":
err = overall.CONSTANT_DB_Server.Exec(sqlStr).Error
case "Tidb":
err = overall.CONSTANT_DB_Tidb.Exec(sqlStr).Error
case "CustomerForm":
err = overall.CONSTANT_DB_CustomerForm.Exec(sqlStr).Error
default:
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-09-22 11:28:12
@ 功能: 获取指定行政组织id所有子类
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (g *GetOrgAllParent) GetOrgSun(superior int64) {
var id []int64
if superior == 0 {
return
}
err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", 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)
}
}

3
scheduledtask/time_task_cron.go

@ -1,7 +1,6 @@
package scheduledtask package scheduledtask
import ( import (
"appPlatform/api/shiyan/maptostruct"
"fmt" "fmt"
"time" "time"
@ -35,7 +34,7 @@ func TimeTask() {
*/ */
c.AddFunc("0 0 2 * * *", func() { c.AddFunc("0 0 2 * * *", func() {
fmt.Printf("执行定时任务--同步试卷数据---->%v\n", time.Now().UTC()) fmt.Printf("执行定时任务--同步试卷数据---->%v\n", time.Now().UTC())
maptostruct.TestPageTimeTask() // maptostruct.TestPageTimeTask()
}) //每3秒执行一个任务 }) //每3秒执行一个任务
c.Start() //启动 c.Start() //启动
defer c.Stop() //设定全部执行后,最后关闭定时任务 defer c.Stop() //设定全部执行后,最后关闭定时任务

Loading…
Cancel
Save