31 changed files with 4603 additions and 24 deletions
@ -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 |
|||
} |
|||
@ -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) |
|||
} |
|||
File diff suppressed because it is too large
@ -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: |
|||
{} |
|||
} |
|||
@ -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) |
|||
} |
|||
@ -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) |
|||
} |
|||
@ -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"` |
|||
} |
|||
@ -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) //入口
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
package taskrouter |
|||
|
|||
//公共路由
|
|||
type ApiRouter struct{} |
|||
@ -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 |
|||
} |
|||
@ -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 |
|||
} |
|||
@ -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 |
|||
} |
|||
@ -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 |
|||
} |
|||
Loading…
Reference in new issue