package LinksystemService import ( "dsDataex/GenXorm/models" "dsDataex/MyModel/LinkSystem/LinksystemDAO" "dsDataex/MyModel/MySwagger" "dsDataex/Utils/CacheUtil" "dsDataex/Utils/CommonUtil" "html" "strconv" "strings" "time" ) func GetLinksystemResults (swag MySwagger.LinksystemSwag) (bool, string, int32, []map[string]interface{}, error) { var condition string var conditions []string var page int var query MySwagger.LinksystemQuery if swag.SystemName != "" { conditions = append(conditions, "system_name=" + "'" + html.EscapeString(swag.SystemName) + "'") } if swag.SystemCode != "" { conditions = append(conditions, "system_code=" + "'" + html.EscapeString(swag.SystemCode) + "'") } if swag.SystemType != 0 { conditions = append(conditions, "system_type=" + "'" + strconv.Itoa(swag.SystemType) + "'") } if swag.SystemKey != "" { conditions = append(conditions, "system_key=" + "'" + html.EscapeString(swag.SystemKey) + "'") } if swag.CollectFlag != 0 { conditions = append(conditions, "collect_flag=" + "'" + strconv.Itoa(swag.CollectFlag) + "'") } if swag.ProviderName != "" { conditions = append(conditions, "provider_name=" + "'" + html.EscapeString(swag.ProviderName) + "'") } 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 := LinksystemDAO.GetLinksystemResults(query) return result, message, count, data, failResult } func CreateLinksystem (model models.TDataexLinksystem) (bool, string, error) { if ! LinksystemDAO.IsSystemCodeUnique(model.SystemCode) { return false, "SystemCode已存在", nil } business := new(models.TDataexLinksystem) business.Id = CommonUtil.GetUUID() business.SystemName = html.EscapeString(model.SystemName) business.SystemCode = html.EscapeString(model.SystemCode) business.SystemType = model.SystemType business.SystemKey = CommonUtil.GetUUID() business.CollectFlag = model.CollectFlag business.ProviderName = html.EscapeString(model.ProviderName) business.CreateTime = time.Now() business.DeleteFlag = -1 business.EnableFlag = 1 result, message, error:= LinksystemDAO.CreateLinksystem(business) return result, message, error } func UpdateLinksystem (id string, model models.TDataexLinksystem) (bool, string, error) { business := new(models.TDataexLinksystem) //清除Redis缓存 var ids = []string{id} var selector = CacheUtil.GetBean("t_dataex_linksystem") CacheUtil.DeleteCacheByIds(ids, selector) business.ChangeTime = time.Now() business.SystemName = html.EscapeString(model.SystemName) business.SystemCode = html.EscapeString(model.SystemCode) business.SystemType = model.SystemType business.CollectFlag = model.CollectFlag business.ProviderName = html.EscapeString(model.ProviderName) business.EnableFlag = model.EnableFlag result, message, error:= LinksystemDAO.UpdateLinksystem(id, business) return result, message, error } func RemoveLinksystem (id string) (bool, string, error) { business := new(models.TDataexLinksystem) //清除Redis缓存 var ids = []string{id} var selector = CacheUtil.GetBean("t_dataex_linksystem") 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:= LinksystemDAO.RemoveLinksystem(id, business) return result, message, error } func IsLinksystemExistsById(id string) bool { result := LinksystemDAO.IsLinksystemExistsById(id) return result }