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.
131 lines
3.6 KiB
131 lines
3.6 KiB
package Jyt2012Service
|
|
|
|
import (
|
|
"dsDataex/GenXorm/models"
|
|
"dsDataex/MyModel/JYT2012/Jyt2012DAO"
|
|
"dsDataex/MyModel/MySwagger"
|
|
"dsDataex/Utils/CacheUtil"
|
|
"dsDataex/Utils/CommonUtil"
|
|
"html"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func GetJyt2012Results (swag MySwagger.Jyt2012Swag) (bool, string, int32, []map[string]interface{}, error) {
|
|
var condition string
|
|
var conditions []string
|
|
var page int
|
|
var query MySwagger.Jyt2012Query
|
|
|
|
if swag.DicName != "" {
|
|
conditions = append(conditions, "dic_name=" + "'" + html.EscapeString(swag.DicName) + "'")
|
|
}
|
|
if swag.DicType != 0 {
|
|
conditions = append(conditions, "dic_type=" + "'" + strconv.Itoa(swag.DicType) + "'")
|
|
}
|
|
if swag.DicInfo != "" {
|
|
conditions = append(conditions, "dic_info=" + "'" + html.EscapeString(swag.DicInfo) + "'")
|
|
}
|
|
if swag.RootFlag != 0 {
|
|
conditions = append(conditions, "root_flag=" + "'" + strconv.Itoa(swag.RootFlag) + "'")
|
|
}
|
|
if swag.JytFlag != 0 {
|
|
conditions = append(conditions, "jyt_flag=" + "'" + strconv.Itoa(swag.JytFlag) + "'")
|
|
}
|
|
if swag.ParentId != "" {
|
|
conditions = append(conditions, "parent_id=" + "'" + html.EscapeString(swag.ParentId) + "'")
|
|
}
|
|
if swag.DeleteFlag != 0 {
|
|
conditions = append(conditions, "delete_flag=" + "'" + strconv.Itoa(swag.DeleteFlag) + "'")
|
|
}
|
|
if swag.EnableFlag != 0 {
|
|
conditions = append(conditions, "enable_flag=" + "'" + strconv.Itoa(swag.EnableFlag) + "'")
|
|
}
|
|
if swag.Page != 0 {
|
|
page = swag.Page
|
|
query.Page = (page -1) * 100
|
|
} else {
|
|
query.Page = 0
|
|
}
|
|
|
|
if len(conditions) > 0 {
|
|
condition = " AND " + strings.Join(conditions, " AND ")
|
|
} else {
|
|
condition = ""
|
|
}
|
|
query.Conditions = condition
|
|
|
|
|
|
result, message, count, data, failResult := Jyt2012DAO.GetJyt2012Results(query)
|
|
|
|
return result, message, count, data, failResult
|
|
}
|
|
|
|
|
|
func CreateJyt2012 (model models.TDataexJyt2012) (bool, string, error) {
|
|
business := new(models.TDataexJyt2012)
|
|
business.Id = CommonUtil.GetUUID()
|
|
business.DicName = html.EscapeString(model.DicName)
|
|
business.DicType = model.DicType
|
|
business.DicInfo = html.EscapeString(model.DicInfo)
|
|
business.RootFlag = model.RootFlag
|
|
business.JytFlag = model.JytFlag
|
|
business.ParentId = html.EscapeString(model.ParentId)
|
|
business.CreateTime = time.Now()
|
|
business.DeleteFlag = -1
|
|
business.EnableFlag = 1
|
|
|
|
result, message, error:= Jyt2012DAO.CreateJyt2012(business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
func UpdateJyt2012 (id string, model models.TDataexJyt2012) (bool, string, error) {
|
|
business := new(models.TDataexJyt2012)
|
|
|
|
//清除Redis缓存
|
|
var ids = []string{id}
|
|
var selector = CacheUtil.GetBean("t_dataex_jyt2012")
|
|
CacheUtil.DeleteCacheByIds(ids, selector)
|
|
|
|
business.ChangeTime = time.Now()
|
|
business.DicName = html.EscapeString(model.DicName)
|
|
business.DicType = model.DicType
|
|
business.DicInfo = html.EscapeString(model.DicInfo)
|
|
business.RootFlag = model.RootFlag
|
|
business.JytFlag = model.JytFlag
|
|
business.ParentId = html.EscapeString(model.ParentId)
|
|
business.EnableFlag = model.EnableFlag
|
|
|
|
result, message, error:= Jyt2012DAO.UpdateJyt2012(id, business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
func RemoveJyt2012 (id string) (bool, string, error) {
|
|
business := new(models.TDataexJyt2012)
|
|
|
|
//清除Redis缓存
|
|
var ids = []string{id}
|
|
var selector = CacheUtil.GetBean("t_dataex_jyt2012")
|
|
CacheUtil.DeleteCacheByIds(ids, selector)
|
|
|
|
business.Id = html.EscapeString(id)
|
|
business.ChangeTime = time.Now()
|
|
business.DeleteTime = time.Now()
|
|
business.DeleteFlag = 1
|
|
business.EnableFlag = -1
|
|
|
|
result, message, error:= Jyt2012DAO.RemoveJyt2012(id, business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
func IsJyt2012ExistsById(id string) bool {
|
|
result := Jyt2012DAO.IsJyt2012ExistsById(id)
|
|
|
|
return result
|
|
}
|
|
|