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.
152 lines
4.7 KiB
152 lines
4.7 KiB
package OrgtreeService
|
|
|
|
import (
|
|
"dsSupport/MyModel/AccessSystem/AccessSystemDao"
|
|
//"dsSupport/MyModel/LinkSystem/LinksystemService"
|
|
"dsSupport/MyModel/MySwagger"
|
|
"dsSupport/MyModel/OrgTree/OrgtreeDAO"
|
|
"dsSupport/Utils/CacheUtil"
|
|
"dsSupport/Utils/CommonUtil"
|
|
"dsSupport/models"
|
|
"fmt"
|
|
"html"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func GetOrgtreeResults(swag MySwagger.OrgtreeSwag) (bool, string, int, []map[string]interface{}, error) {
|
|
var condition string
|
|
var conditions []string
|
|
var query MySwagger.OrgtreeQuery
|
|
|
|
if swag.OrgName != "" {
|
|
conditions = append(conditions, "org_name="+"'"+html.EscapeString(swag.OrgName)+"'")
|
|
}
|
|
if swag.OrgType != 0 {
|
|
conditions = append(conditions, "org_type="+"'"+strconv.Itoa(swag.OrgType)+"'")
|
|
}
|
|
if swag.ParentId != "" {
|
|
conditions = append(conditions, "parent_id="+"'"+html.EscapeString(swag.ParentId)+"'")
|
|
}
|
|
if swag.CatId != "" {
|
|
conditions = append(conditions, "cat_id="+"'"+html.EscapeString(swag.CatId)+"'")
|
|
}
|
|
if swag.ProvinceId != "" {
|
|
conditions = append(conditions, "province_id="+"'"+html.EscapeString(swag.ProvinceId)+"'")
|
|
}
|
|
if swag.CityId != "" {
|
|
conditions = append(conditions, "city_id="+"'"+html.EscapeString(swag.CityId)+"'")
|
|
}
|
|
if swag.AreaId != "" {
|
|
conditions = append(conditions, "area_id="+"'"+html.EscapeString(swag.AreaId)+"'")
|
|
}
|
|
if swag.LinksystemId != "" {
|
|
conditions = append(conditions, "linksystem_id="+"'"+html.EscapeString(swag.LinksystemId)+"'")
|
|
}
|
|
if swag.LinkId != "" {
|
|
conditions = append(conditions, "link_id="+"'"+html.EscapeString(swag.LinkId)+"'")
|
|
}
|
|
if swag.DeleteFlag != 0 {
|
|
conditions = append(conditions, "delete_flag="+"'"+strconv.Itoa(swag.DeleteFlag)+"'")
|
|
} else {
|
|
conditions = append(conditions, "delete_flag='-1'")
|
|
}
|
|
if swag.EnableFlag != 0 {
|
|
conditions = append(conditions, "enable_flag="+"'"+strconv.Itoa(swag.EnableFlag)+"'")
|
|
}
|
|
if swag.Page != 0 {
|
|
query.Page = swag.Page
|
|
} else {
|
|
query.Page = 1
|
|
}
|
|
|
|
if len(conditions) > 0 {
|
|
condition = " AND " + strings.Join(conditions, " AND ")
|
|
} else {
|
|
condition = ""
|
|
}
|
|
query.Conditions = condition
|
|
fmt.Println(query.Conditions)
|
|
|
|
result, message, count, data, failResult := OrgtreeDAO.GetOrgtreeResults(query)
|
|
|
|
return result, message, count, data, failResult
|
|
}
|
|
|
|
func CreateOrgtree(model models.TDataexOrgtree) (bool, string, error) {
|
|
// 校验源业务系统是否存在
|
|
_, e := AccessSystemDao.GetApp(model.LinksystemId)
|
|
if e != nil {
|
|
return false, "源业务系统不存在", nil
|
|
}
|
|
business := new(models.TDataexOrgtree)
|
|
business.Id = CommonUtil.GetUUID()
|
|
business.OrgName = html.EscapeString(model.OrgName)
|
|
business.OrgType = model.OrgType
|
|
business.ParentId = html.EscapeString(model.ParentId)
|
|
business.CatId = html.EscapeString(model.CatId)
|
|
business.ProvinceId = html.EscapeString(model.ProvinceId)
|
|
business.CityId = html.EscapeString(model.CityId)
|
|
business.AreaId = html.EscapeString(model.AreaId)
|
|
business.LinksystemId = html.EscapeString(model.LinksystemId)
|
|
business.LinkId = html.EscapeString(model.LinkId)
|
|
business.CreateTime = time.Now()
|
|
business.DeleteFlag = -1
|
|
business.EnableFlag = 1
|
|
|
|
result, message, error := OrgtreeDAO.CreateOrgtree(business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
func UpdateOrgtree(id string, model models.TDataexOrgtree) (bool, string, error) {
|
|
// 校验源业务系统是否存在
|
|
_, e := AccessSystemDao.GetApp(model.LinksystemId)
|
|
if e != nil {
|
|
return false, "源业务系统不存在", nil
|
|
}
|
|
business := new(models.TDataexOrgtree)
|
|
business.Id = html.EscapeString(id)
|
|
business.OrgName = html.EscapeString(model.OrgName)
|
|
business.OrgType = model.OrgType
|
|
business.ParentId = html.EscapeString(model.ParentId)
|
|
business.CatId = html.EscapeString(model.CatId)
|
|
business.ProvinceId = html.EscapeString(model.ProvinceId)
|
|
business.CityId = html.EscapeString(model.CityId)
|
|
business.AreaId = html.EscapeString(model.AreaId)
|
|
business.LinksystemId = html.EscapeString(model.LinksystemId)
|
|
business.LinkId = html.EscapeString(model.LinkId)
|
|
business.ChangeTime = time.Now()
|
|
business.EnableFlag = model.EnableFlag
|
|
|
|
result, message, error := OrgtreeDAO.UpdateOrgtree(id, business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
func RemoveOrgtree(id string) (bool, string, error) {
|
|
business := new(models.TDataexOrgtree)
|
|
|
|
//清除Redis缓存
|
|
var ids = []string{id}
|
|
var selector = CacheUtil.GetBean("t_dataex_orgtree")
|
|
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 := OrgtreeDAO.RemoveOrgtree(id, business)
|
|
|
|
return result, message, error
|
|
}
|
|
|
|
//func IsOrgtreeExistsById(id string) bool {
|
|
// result := OrgtreeDAO.IsOrgtreeExistsById(id)
|
|
//
|
|
// return result
|
|
//}
|