应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

73 lines
3.6 KiB

package modelskpi
import (
"appPlatform/overall"
"strings"
)
// 指标细则
type DetailedTarget struct {
Id int64 `json:"id" gorm:"primaryKey;column:dt_id;type:bigint(20) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:dt_title;type:text;comment:指标细则"`
Content string `json:"content" gorm:"column:dt_content;type:text;comment:指标说明"`
ParentId int64 `json:"parentid" gorm:"column:dt_parentid;type:bigint(20) unsigned;default:0;not null;comment:归属指标栏目"`
ParentIdSun int64 `json:"parentidsun" gorm:"column:dt_parentid_sun;type:bigint(20) unsigned;default:0;not null;comment:归属指标子栏目"`
State int `json:"state" gorm:"column:dt_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
AddTime int64 `json:"addtime" gorm:"column:dt_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"`
MinScore int64 `json:"minscore" gorm:"column:dt_min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"`
MaxScore int64 `json:"maxscore" gorm:"column:dt_max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"`
Company string `json:"company" gorm:"column:dt_company;type:varchar(20) unsigned;default:0;not null;comment:单位"`
AddReduce int `json:"addreduce" gorm:"column:dt_add_reduce;type:int(1) unsigned;default:1;not null;comment:1:减少;2:增加;3:无属性,现场确认加或减"`
CensorType string `json:"censortype" gorm:"column:dt_censor_type;type:text;comment:检查方式"`
CensorCont string `json:"censorcont" gorm:"column:dt_censor_cont;type:longtext;comment:检查依据"`
CensorRate int `json:"censorrate" gorm:"column:dt_censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"`
Cycles int `json:"cycle" gorm:"column:dt_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"`
CycleAttres int `json:"cycleattr" gorm:"column:dt_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"`
Paretment string `json:"paretment" gorm:"column:dt_paretment;type:longtext;comment:接受考核的部门"`
Reportary string `json:"reportary" gorm:"column:reportary;type:longtext;comment:提报人"`
}
func (DetailedTarget *DetailedTarget) TableName() string {
return "detailed_target"
}
// 编辑内容
func (cont *DetailedTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(&saveData).Error
return
}
// 获取内容
func (cont *DetailedTarget) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.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 *DetailedTarget) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *DetailedTarget) ContMap(whereMap interface{}, field ...string) (countAry []DetailedTarget, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error
return
}
// 删除内容
func (cont *DetailedTarget) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}