classify.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "github.com/rdlucklib/rdluck_tools/paging"
  9. )
  10. type Classify struct {
  11. Id int `gorm:"column:id;primaryKey" json:"id"` //`orm:"column(id);pk" gorm:"primaryKey" `
  12. ClassifyName string `gorm:"column:classify_name" json:"classify_name"` //`description:"分类名称"`
  13. Sort int `gorm:"column:sort" json:"sort"` //`json:"-"`
  14. ParentId int `gorm:"column:parent_id" json:"parent_id"` //`description:"父级分类id"`
  15. CreateTime time.Time `gorm:"column:create_time" json:"create_time"` //`description:"创建时间"`
  16. ModifyTime time.Time `gorm:"column:modify_time" json:"modify_time"` //`description:"修改时间"`
  17. Abstract string `gorm:"column:abstract" json:"abstract"` //`description:"栏目简介"`
  18. Descript string `gorm:"column:descript" json:"descript"` //`description:"分享描述"`
  19. ReportAuthor string `gorm:"column:report_author" json:"report_author"` //`description:"栏目作者"`
  20. AuthorDescript string `gorm:"column:author_descript" json:"author_descript"` //`description:"作者简介"`
  21. ColumnImgUrl string `gorm:"column:column_img_url" json:"column_img_url"` //`description:"栏目配图"`
  22. HeadImgUrl string `gorm:"column:head_img_url" json:"head_img_url"` //`description:"头部banner"`
  23. AvatarImgUrl string `gorm:"column:avatar_img_url" json:"avatar_img_url"` //`description:"头像"`
  24. ReportImgUrl string `gorm:"column:report_img_url" json:"report_img_url"` //`description:"报告配图"`
  25. HomeImgUrl string `gorm:"column:home_img_url" json:"home_img_url"` //`description:"首页配图"`
  26. ClassifyLabel string `gorm:"column:classify_label" json:"classify_label"` //`description:"分类标签"`
  27. ShowType int `gorm:"column:show_type" json:"show_type"` //`description:"展示类型:1-列表 2-专栏"`
  28. HasTeleconference int `gorm:"column:has_teleconference" json:"has_teleconference"` //`description:"是否有电话会:0-否 1-是"`
  29. VipTitle string `gorm:"column:vip_title" json:"vip_title"` //`description:"研究员头衔"`
  30. IsShow int `gorm:"column:is_show" json:"is_show"` //`description:"是否在小程序显示:1-显示 0-隐藏"`
  31. YbFiccSort int `gorm:"column:yb_ficc_sort" json:"yb_ficc_sort"` //`description:"小程序FICC页排序"`
  32. YbFiccIcon string `gorm:"column:yb_ficc_icon" json:"yb_ficc_icon"` // `description:"小程序FICC页icon"`
  33. YbFiccPcIcon string `gorm:"column:yb_ficc_pc_icon" json:"yb_ficc_pc_icon"` //`description:"小程序PC端FICC页背景图"`
  34. YbIconUrl string `gorm:"column:yb_icon_url" json:"yb_icon_url"` //`description:"小程序已购页icon"`
  35. YbBgUrl string `gorm:"column:yb_bg_url" json:"yb_bg_url"` //`description:"小程序已购详情背景图"`
  36. YbListImg string `gorm:"column:yb_list_img" json:"yb_list_img"` //`description:"小程序研报列表封面图"`
  37. YbShareBgImg string `gorm:"column:yb_share_bg_img" json:"yb_share_bg_img"` //`description:"小程序研报详情分享背景图"`
  38. YbRightBanner string `gorm:"column:yb_right_banner" json:"yb_right_banner"` //`description:"Pc端详情页,右侧,报告合集背景图"`
  39. RelateTel int `gorm:"column:relate_tel" json:"relate_tel"` //`description:"是否在电话会中可选: 0-否; 1-是"`
  40. RelateVideo int `gorm:"column:relate_video" json:"relate_video"` //`description:"是否在路演视频中可选: 0-否; 1-是"`
  41. IsMassSend int `gorm:"column:is_mass_send" json:"is_mass_send"` //`description:"1:群发,0:非群发"`
  42. Enabled int `gorm:"column:enabled" json:"enabled"` //`description:"是否可用,1可用,0禁用"`
  43. Level int `gorm:"column:level" json:"level"` //`description:"层级"`
  44. HasChild int `gorm:"column:has_child" json:"has_child"` //`description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
  45. ReportDetailShowType int `gorm:"column:report_detail_show_type" json:"report_detail_show_type"` //`description:"报告详情的展示类型:1-拼接;2:目录"`
  46. ClassifyType int `gorm:"column:classify_type" json:"classify_type"` //`description:"分类类型:1-研报;2-PPT"`
  47. IsRemind int `gorm:"column:is_remind" json:"is_remind"` //`description:"是否开启提醒:0-关闭;1-开启"`
  48. RemindTime string `gorm:"column:remind_time" json:"remind_time"` //`description:"提醒时间:可选00:00-23:59"`
  49. ReportNum int `gorm:"column:report_num" json:"report_num"` //`description:"分类下的报告数"`
  50. LevelPath string `gorm:"column:level_path" json:"level_path"` //`description:"分类的层级路径,英文逗号分隔"`
  51. }
  52. type ClassifyAddReq struct {
  53. ClassifyName string `description:"分类名称"`
  54. ParentId int `description:"父级分类id,没有父级分类传0"`
  55. ChartPermissionIdList []int `description:"权限id数组"`
  56. VisibleUserIds []int `description:"可见用户id数组"`
  57. ClassifyType int `description:"分类类型:1-研报;2-PPT"`
  58. IsRemind int `description:"是否开启提醒:0-关闭;1-开启"`
  59. RemindTime string `description:"提醒时间:可选00:00-23:59"`
  60. }
  61. func GetClassifyByName(classifyName string, parentId int) (item *Classify, err error) {
  62. sql := `SELECT * FROM classify WHERE classify_name=? AND parent_id=? `
  63. err = global.DmSQL["rddp"].Raw(sql, classifyName, parentId).First(&item).Error
  64. return
  65. }
  66. func GetClassifyById(classifyId int) (item *Classify, err error) {
  67. sql := `SELECT * FROM classify WHERE id=? `
  68. err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&item).Error
  69. return
  70. }
  71. // 添加分类
  72. func AddClassify(item *Classify, parentId int, visibleUserIds []int) (err error) {
  73. tx := global.DmSQL["rddp"].Begin()
  74. defer func() {
  75. if err != nil {
  76. tx.Rollback()
  77. return
  78. }
  79. tx.Commit()
  80. }()
  81. err = tx.Create(item).Error
  82. if err != nil {
  83. return
  84. }
  85. // 添加可见用户
  86. if len(visibleUserIds) > 0 {
  87. addMappingList := make([]ClassifyVisible, 0)
  88. now := time.Now()
  89. for _, visibleUserId := range visibleUserIds {
  90. addMapping := ClassifyVisible{
  91. ClassifyId: item.Id,
  92. AdminId: visibleUserId,
  93. CreateTime: now,
  94. }
  95. addMappingList = append(addMappingList, addMapping)
  96. }
  97. err = tx.CreateInBatches(addMappingList, utils.MultiAddNum).Error
  98. if err != nil {
  99. return
  100. }
  101. }
  102. // 删除父级分类可见权限
  103. if parentId > 0 {
  104. sql := `DELETE FROM classify_visible WHERE classify_id=? `
  105. err = tx.Exec(sql, parentId).Error
  106. if err != nil {
  107. return
  108. }
  109. }
  110. return
  111. }
  112. func GetReportCountByClassifyId(classifyId int) (count int, err error) {
  113. sql := `SELECT COUNT(1) as num FROM report WHERE classify_id_second=? `
  114. err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&count).Error
  115. return
  116. }
  117. func GetClassifySubCountByClassifyId(classifyId int) (count int, err error) {
  118. sql := `SELECT COUNT(1) as num FROM classify AS a
  119. INNER JOIN report AS b ON a.id=b.classify_id_second
  120. WHERE a.parent_id=? `
  121. err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&count).Error
  122. return
  123. }
  124. func GetClassifySubCountByParentId(classifyId int) (count int, err error) {
  125. sqlCount := `
  126. SELECT COUNT(1) as num FROM classify AS a
  127. WHERE a.parent_id=? `
  128. err = global.DmSQL["rddp"].Raw(sqlCount, classifyId).Scan(&count).Error
  129. return
  130. }
  131. // DeleteClassify 删除分类
  132. func DeleteClassify(classifyIds []int) (err error) {
  133. if len(classifyIds) == 0 {
  134. return
  135. }
  136. sql := fmt.Sprintf(`DELETE FROM classify WHERE id IN (%s)`, utils.GetOrmInReplace(len(classifyIds)))
  137. err = global.DmSQL["rddp"].Exec(sql, classifyIds).Error
  138. if err != nil {
  139. return
  140. }
  141. deleteImgSql := fmt.Sprintf(`DELETE FROM banner WHERE classify_id IN (%s)`, utils.GetOrmInReplace(len(classifyIds)))
  142. err = global.DmSQL["rddp"].Exec(deleteImgSql, classifyIds).Error
  143. return
  144. }
  145. // 根据id获取分类详情
  146. func FindByIdClassify(classifyId int) (item *Classify, err error) {
  147. sql := `SELECT * FROM classify WHERE id=? `
  148. err = global.DmSQL["rddp"].Raw(sql, classifyId).First(&item).Error
  149. return
  150. }
  151. type ClassifyList struct {
  152. Id int `gorm:"column:id"` //`orm:"column(id);pk" gorm:"primaryKey" `
  153. ClassifyName string `gorm:"column:classify_name"` //`description:"分类名称"`
  154. Sort int `gorm:"column:sort"` //`description:"排序"`
  155. ParentId int `gorm:"column:parent_id"` //`description:"父级分类id"`
  156. CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
  157. ModifyTime time.Time `gorm:"column:modify_time"` //`description:"修改时间"`
  158. Abstract string `gorm:"column:abstract"` //`description:"简介"`
  159. Descript string `gorm:"column:descript"` //`description:"描述"`
  160. ClassifyLabel string `gorm:"column:classify_label"` //`description:"分类标签"`
  161. ShowType int `gorm:"column:show_type"` //`description:"展示类型:1-列表 2-专栏"`
  162. HasTeleconference int `gorm:"column:has_teleconference"` //`description:"是否有电话会:0-否 1-是"`
  163. IsShow int `gorm:"column:is_show"` //`description:"是否在小程序显示:1-显示 0-隐藏"`
  164. YbFiccSort int `gorm:"column:yb_ficc_sort"` //`description:"小程序FICC页排序"`
  165. YbFiccIcon string `gorm:"column:yb_ficc_icon"` //`description:"小程序FICC页icon"`
  166. YbFiccPcIcon string `gorm:"column:yb_ficc_pc_icon"` //`description:"小程序PC端FICC页背景图"`
  167. YbIconUrl string `gorm:"column:yb_icon_url"` //`description:"小程序已购页icon"`
  168. YbBgUrl string `gorm:"column:yb_bg_url"` //`description:"小程序已购详情背景图"`
  169. YbListImg string `gorm:"column:yb_list_img"` //`description:"小程序研报列表封面图"`
  170. YbShareBgImg string `gorm:"column:yb_share_bg_img"` //`description:"小程序研报详情分享背景图"`
  171. YbRightBanner string `gorm:"column:yb_right_banner"` //`description:"Pc端详情页,右侧,报告合集背景图"`
  172. RelateTel int `gorm:"column:relate_tel"` //`description:"是否在电话会中可选: 0-否; 1-是"`
  173. RelateVideo int `gorm:"column:relate_video"` //`description:"是否在路演视频中可选: 0-否; 1-是"`
  174. Enabled int `gorm:"column:enabled"` //`description:"是否可用,1可用,0禁用"`
  175. Level int `gorm:"column:level"` //`description:"层级"`
  176. HasChild int `gorm:"column:has_child"` //`description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
  177. ClassifyType int `gorm:"column:classify_type"` //`description:"分类类型:1-研报;2-PPT"`
  178. IsRemind int `gorm:"column:is_remind"` //`description:"是否开启提醒:0-关闭;1-开启"`
  179. RemindTime string `gorm:"column:remind_time"` //`description:"提醒时间:可选00:00-23:59"`
  180. ReportNum int `gorm:"column:report_num"` //`description:"分类下的报告数"`
  181. Child []*ClassifyList `gorm:"-"`
  182. ClassifyMenuId int `gorm:"-"` //`description:"二级分类-子目录ID"`
  183. ClassifyMenuList []*ClassifyMenu `gorm:"-"`
  184. ChartPermissionIdList []int `gorm:"-"` //`description:"绑定的权限ID"`
  185. LevelPath string `gorm:"column:level_path" json:"level_path"` //`description:"分类的层级路径,英文逗号分隔"`
  186. VisiableUsers []int `gorm:"-"`
  187. }
  188. type ClassifyItem struct {
  189. Classify
  190. ClassifyMenuId int `description:"二级分类-子目录ID"`
  191. ClassifyMenuList []*ClassifyMenu
  192. ChartPermissionIdList []int `description:"绑定的权限ID"`
  193. Child []*ClassifyItem
  194. }
  195. type ClassifyListResp struct {
  196. List []*ClassifyList
  197. }
  198. type ClassifyPermissionListResp struct {
  199. List []*ClassifyList
  200. Paging *paging.PagingItem `description:"分页数据"`
  201. }
  202. type CheckDeleteClassifyReq struct {
  203. ClassifyId int `description:"分类ID"`
  204. }
  205. type CheckDeleteClassifyResp struct {
  206. Code int `description:"编码:0:检测成功,可进行删除,1:分类不存在,2:该分类有关联报告,不允许删除,3:二级分类有关联报告,不允许删除,4:该分类下有关联分类,是否确认全部删除"`
  207. Msg string `description:"描述信息"`
  208. }
  209. type DeleteClassifyReq struct {
  210. ClassifyId int `description:"分类ID"`
  211. }
  212. type EditClassifyReq struct {
  213. ClassifyId int `description:"分类ID"`
  214. ClassifyAddReq
  215. }
  216. type FindByIdClassifyReq struct {
  217. ClassifyId int `description:"分类ID"`
  218. }
  219. func GetClassifyChild(parentId int, keyWord string) (items []*Classify, err error) {
  220. sql := ``
  221. pars := make([]interface{}, 0)
  222. if keyWord != "" {
  223. sql = `SELECT * FROM classify WHERE classify_name LIKE ? AND parent_id=? ORDER BY create_time ASC `
  224. pars = append(pars, utils.GetLikeKeyword(keyWord))
  225. } else {
  226. sql = `SELECT * FROM classify WHERE parent_id=? ORDER BY create_time ASC `
  227. }
  228. pars = append(pars, parentId)
  229. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  230. return
  231. }
  232. // EditClassifyPermissionReq 编辑分类权限请求
  233. type EditClassifyPermissionReq struct {
  234. ClassifyId int `description:"分类ID"`
  235. ChartPermissionIdList []int `description:"权限id数组"`
  236. }
  237. // GetAllClassify 获取所有分类
  238. func GetAllClassify() (list []*Classify, err error) {
  239. sql := ` SELECT * FROM classify `
  240. err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
  241. return
  242. }
  243. // UpdateClassify 更新分类
  244. func (classifyInfo *Classify) UpdateClassify(cols []string) (err error) {
  245. err = global.DmSQL["rddp"].Select(cols).Updates(classifyInfo).Error
  246. return
  247. }
  248. // SimpleClassifyList 简版分类列表
  249. type SimpleClassifyList struct {
  250. Id int `description:"分类ID"`
  251. ClassifyName string `description:"分类名称"`
  252. ParentId int `description:"父级ID"`
  253. Sort int `description:"排序"`
  254. Child []*SimpleClassifyList
  255. }
  256. // GetClassifyByCondition 获取分类列表
  257. func GetClassifyByCondition(condition, orderRule string, pars []interface{}) (items []*SimpleClassifyList, err error) {
  258. sql := `SELECT * FROM classify WHERE 1 = 1 `
  259. if condition != `` {
  260. sql += condition
  261. }
  262. order := `sort ASC, create_time ASC`
  263. if orderRule != `` {
  264. order = orderRule
  265. }
  266. sql += ` ORDER BY ` + order
  267. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  268. return
  269. }
  270. // RelateTelSecClassifyWithPermissions 关联了电话会的二级分类及权限
  271. type RelateTelSecClassifyWithPermissions struct {
  272. Id int `description:"分类ID"`
  273. ClassifyName string `description:"分类名称"`
  274. ChartPermissionIds string `description:"权限IDs"`
  275. }
  276. // UpdateClassifySortByParentId 根据父类id更新排序
  277. func UpdateClassifySortByParentId(parentId, permissionId, nowSort int, updateSort string) (err error) {
  278. sql := ` update classify set sort = ` + updateSort + ` WHERE parent_id=? AND sort > ? `
  279. if permissionId > 0 {
  280. sql += ` or ( id > ` + fmt.Sprint(permissionId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
  281. }
  282. err = global.DmSQL["rddp"].Exec(sql, parentId, nowSort).Error
  283. return
  284. }
  285. // GetMaxSortByParentId 获取最大的排序值
  286. func (classifyInfo *Classify) GetMaxSortByParentId(parentId int) (maxSort int, err error) {
  287. sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM classify WHERE parent_id = ? `
  288. err = global.DmSQL["rddp"].Raw(sql, parentId).Scan(&maxSort).Error
  289. return
  290. }
  291. // GetMaxSort 获取最大的排序值
  292. func (classifyInfo *Classify) GetMaxSort() (maxSort int, err error) {
  293. sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM classify`
  294. err = global.DmSQL["rddp"].Raw(sql).Scan(&maxSort).Error
  295. return
  296. }
  297. // GetFirstClassifyByParentId 获取当前父级分类下,且排序数相同 的排序第一条的数据
  298. func (classifyInfo *Classify) GetFirstClassifyByParentId(parentId int) (item *Classify, err error) {
  299. sql := `SELECT * FROM classify WHERE parent_id = ? order by sort asc, id asc limit 1`
  300. err = global.DmSQL["rddp"].Raw(sql, parentId).First(&item).Error
  301. return
  302. }
  303. type ClassifyMoveReq struct {
  304. ClassifyId int `description:"分类ID"`
  305. PrevClassifyId int `description:"上一个兄弟节点分类id"`
  306. NextClassifyId int `description:"下一个兄弟节点分类id"`
  307. }
  308. type ClassifySetEnabledReq struct {
  309. ClassifyId int `description:"分类ID"`
  310. Enabled int `description:"是否可用,1可用,0禁用"`
  311. }
  312. func (classifyInfo *Classify) SetEnabled(id, enabled int) (err error) {
  313. to := global.DmSQL["rddp"].Begin()
  314. defer func() {
  315. if err != nil {
  316. _ = to.Rollback()
  317. } else {
  318. _ = to.Commit()
  319. }
  320. }()
  321. sql := ` UPDATE classify SET enabled =? WHERE id = ?`
  322. err = to.Exec(sql, enabled, id).Error
  323. if err != nil {
  324. return
  325. }
  326. sql = ` UPDATE classify SET enabled =? WHERE parent_id = ?`
  327. err = to.Exec(sql, enabled, id).Error
  328. if err != nil {
  329. return
  330. }
  331. return
  332. }
  333. // GetCountClassifyChildByParentId
  334. // @Description: 获取父级分类下子分类数量
  335. // @author: Roc
  336. // @datetime 2024-06-17 10:58:46
  337. // @param parentId int
  338. // @return total int
  339. // @return err error
  340. func GetCountClassifyChildByParentId(parentId int) (total int, err error) {
  341. sql := `SELECT count(1) AS total FROM classify WHERE parent_id = ? `
  342. err = global.DmSQL["rddp"].Raw(sql, parentId).Scan(&total).Error
  343. return
  344. }
  345. // GetClassifyListByKeyword
  346. // @Description: 获取分类列表
  347. // @author: Roc
  348. // @datetime 2024-06-19 09:49:33
  349. // @param keyWord string
  350. // @param enabled int
  351. // @return items []*ClassifyList
  352. // @return err error
  353. func GetClassifyListByKeyword(keyWord string, enabled, classifyType int) (items []*ClassifyList, err error) {
  354. sql := ``
  355. pars := make([]interface{}, 0)
  356. sql = `SELECT * FROM classify WHERE 1=1 `
  357. if enabled == 1 {
  358. sql += ` AND enabled = 1 `
  359. }
  360. if classifyType > 0 {
  361. sql += fmt.Sprintf(` AND classify_type = %d `, classifyType)
  362. }
  363. if keyWord != `` {
  364. sql += ` AND classify_name LIKE ? `
  365. pars = utils.GetLikeKeywordPars(pars, keyWord, 1)
  366. }
  367. sql += ` ORDER BY sort ASC, create_time ASC`
  368. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  369. return
  370. }
  371. // GetClassifyListByParentIdList
  372. // @Description: 获取分类列表
  373. // @author: Roc
  374. // @datetime 2024-06-19 09:49:33
  375. // @param keyWord string
  376. // @param enabled int
  377. // @return items []*ClassifyList
  378. // @return err error
  379. func GetClassifyListByParentIdList(parentClassifyIdList []int) (items []*ClassifyList, err error) {
  380. num := len(parentClassifyIdList)
  381. if num <= 0 {
  382. return
  383. }
  384. sql := `SELECT * FROM classify WHERE id in (` + utils.GetOrmInReplace(num) + `) ORDER BY sort ASC, create_time ASC`
  385. err = global.DmSQL["rddp"].Raw(sql, parentClassifyIdList).Find(&items).Error
  386. return
  387. }
  388. // GetClassifyListByIdList
  389. // @Description: 根据指标ID列表,获取分类列表
  390. // @author: Roc
  391. // @datetime 2024-06-27 15:23:57
  392. // @param classifyIdList []int
  393. // @return items []*Classify
  394. // @return err error
  395. func GetClassifyListByIdList(classifyIdList []int) (items []*Classify, err error) {
  396. num := len(classifyIdList)
  397. if num <= 0 {
  398. return
  399. }
  400. sql := `SELECT * FROM classify WHERE id IN (` + utils.GetOrmInReplace(num) + `) `
  401. err = global.DmSQL["rddp"].Raw(sql, classifyIdList).Find(&items).Error
  402. return
  403. }
  404. func (m *Classify) TableName() string {
  405. return "classify"
  406. }
  407. func (m *Classify) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*Classify, err error) {
  408. fields := strings.Join(fieldArr, ",")
  409. if len(fieldArr) == 0 {
  410. fields = `*`
  411. }
  412. order := `ORDER BY create_time DESC`
  413. if orderRule != "" {
  414. order = ` ORDER BY ` + orderRule
  415. }
  416. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  417. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  418. return
  419. }