report_approve_flow.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. package report_approve
  2. import (
  3. "eta/eta_api/utils"
  4. "fmt"
  5. "github.com/beego/beego/v2/client/orm"
  6. "strings"
  7. "time"
  8. )
  9. const (
  10. FlowReportTypeChinese = iota + 1
  11. FlowReportTypeEnglish
  12. FlowReportTypeSmart
  13. )
  14. // ReportApproveFlow 报告审批流表
  15. type ReportApproveFlow struct {
  16. ReportApproveFlowId int `orm:"column(report_approve_flow_id);pk" description:"审批流ID"`
  17. FlowName string `description:"审批流名称"`
  18. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  19. ClassifyFirstId int `description:"一级分类ID"`
  20. ClassifySecondId int `description:"二级分类ID"`
  21. CurrVersion int `description:"当前版本号"`
  22. CreateTime time.Time `description:"创建时间"`
  23. ModifyTime time.Time `description:"修改时间"`
  24. }
  25. func (m *ReportApproveFlow) TableName() string {
  26. return "report_approve_flow"
  27. }
  28. func (m *ReportApproveFlow) PrimaryId() string {
  29. return "report_approve_flow_id"
  30. }
  31. func (m *ReportApproveFlow) Create() (err error) {
  32. o := orm.NewOrmUsingDB("rddp")
  33. id, err := o.Insert(m)
  34. if err != nil {
  35. return
  36. }
  37. m.ReportApproveFlowId = int(id)
  38. return
  39. }
  40. func (m *ReportApproveFlow) CreateMulti(items []*ReportApproveFlow) (err error) {
  41. if len(items) == 0 {
  42. return
  43. }
  44. o := orm.NewOrmUsingDB("rddp")
  45. _, err = o.InsertMulti(len(items), items)
  46. return
  47. }
  48. func (m *ReportApproveFlow) Update(cols []string) (err error) {
  49. o := orm.NewOrmUsingDB("rddp")
  50. _, err = o.Update(m, cols...)
  51. return
  52. }
  53. func (m *ReportApproveFlow) Del() (err error) {
  54. o := orm.NewOrmUsingDB("rddp")
  55. sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  56. _, err = o.Raw(sql, m.ReportApproveFlowId).Exec()
  57. return
  58. }
  59. func (m *ReportApproveFlow) MultiDel(menuIds []int) (err error) {
  60. if len(menuIds) == 0 {
  61. return
  62. }
  63. o := orm.NewOrmUsingDB("rddp")
  64. sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.PrimaryId(), utils.GetOrmInReplace(len(menuIds)))
  65. _, err = o.Raw(sql, menuIds).Exec()
  66. return
  67. }
  68. func (m *ReportApproveFlow) GetItemById(id int) (item *ReportApproveFlow, err error) {
  69. o := orm.NewOrmUsingDB("rddp")
  70. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  71. err = o.Raw(sql, id).QueryRow(&item)
  72. return
  73. }
  74. func (m *ReportApproveFlow) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *ReportApproveFlow, err error) {
  75. o := orm.NewOrmUsingDB("rddp")
  76. order := ``
  77. if orderRule != "" {
  78. order = ` ORDER BY ` + orderRule
  79. }
  80. sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
  81. err = o.Raw(sql, pars).QueryRow(&item)
  82. return
  83. }
  84. func (m *ReportApproveFlow) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  85. o := orm.NewOrmUsingDB("rddp")
  86. sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
  87. err = o.Raw(sql, pars).QueryRow(&count)
  88. return
  89. }
  90. func (m *ReportApproveFlow) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*ReportApproveFlow, err error) {
  91. o := orm.NewOrmUsingDB("rddp")
  92. fields := strings.Join(fieldArr, ",")
  93. if len(fieldArr) == 0 {
  94. fields = `*`
  95. }
  96. order := `ORDER BY create_time DESC`
  97. if orderRule != "" {
  98. order = ` ORDER BY ` + orderRule
  99. }
  100. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  101. _, err = o.Raw(sql, pars).QueryRows(&items)
  102. return
  103. }
  104. func (m *ReportApproveFlow) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*ReportApproveFlow, err error) {
  105. o := orm.NewOrmUsingDB("rddp")
  106. fields := strings.Join(fieldArr, ",")
  107. if len(fieldArr) == 0 {
  108. fields = `*`
  109. }
  110. order := `ORDER BY create_time DESC`
  111. if orderRule != "" {
  112. order = ` ORDER BY ` + orderRule
  113. }
  114. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
  115. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  116. return
  117. }
  118. // ReportApproveFlowItem 报告审批流信息
  119. type ReportApproveFlowItem struct {
  120. ReportApproveFlowId int `description:"审批流ID"`
  121. FlowName string `description:"审批流名称"`
  122. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  123. ClassifyFirstId int `description:"一级分类ID"`
  124. ClassifySecondId int `description:"二级分类ID"`
  125. CurrVersion int `description:"当前版本号"`
  126. CreateTime string `description:"创建时间"`
  127. ModifyTime string `description:"修改时间"`
  128. }
  129. // FormatReportApproveFlow2Item 格式化报告审批流
  130. func FormatReportApproveFlow2Item(origin *ReportApproveFlow) (item *ReportApproveFlowItem) {
  131. item = new(ReportApproveFlowItem)
  132. if origin == nil {
  133. return
  134. }
  135. item.ReportApproveFlowId = origin.ReportApproveFlowId
  136. item.FlowName = origin.FlowName
  137. item.ReportType = origin.ReportType
  138. item.ClassifyFirstId = origin.ClassifyFirstId
  139. item.ClassifySecondId = origin.ClassifySecondId
  140. item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
  141. item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
  142. return
  143. }
  144. // ReportApproveFlowAddReq 新增报告审批流请求体
  145. type ReportApproveFlowAddReq struct {
  146. FlowName string `description:"审批流名称"`
  147. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  148. ClassifyFirstId int `description:"一级分类ID"`
  149. ClassifySecondId int `description:"二级分类ID"`
  150. }
  151. //
  152. //// ReportApproveFlowEditReq 编辑报告审批流请求体
  153. //type ReportApproveFlowEditReq struct {
  154. // ReportApproveFlowAddReq
  155. // ReportApproveFlowId int `description:"报告审批流ID"`
  156. // Content string `description:"内容"`
  157. // ContentStruct string `description:"内容结构"`
  158. //}
  159. //
  160. //// ReportApproveFlowRemoveReq 删除报告审批流请求体
  161. //type ReportApproveFlowRemoveReq struct {
  162. // ReportApproveFlowId int `description:"报告审批流ID"`
  163. //}
  164. //
  165. //// ReportApproveFlowPublishReq 发布报告审批流请求体
  166. //type ReportApproveFlowPublishReq struct {
  167. // ReportApproveFlowId int `description:"报告审批流ID"`
  168. // PublishState int `description:"1-取消发布; 2-发布"`
  169. //}
  170. //
  171. //// ReportApproveFlowPrePublishReq 预发布报告审批流请求体
  172. //type ReportApproveFlowPrePublishReq struct {
  173. // ReportApproveFlowId int `description:"报告审批流ID"`
  174. // PrePublishTime string `description:"预发布时间"`
  175. // PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
  176. //}
  177. //
  178. //// ReportApproveFlowSaveContentReq 保存草稿请求体
  179. //type ReportApproveFlowSaveContentReq struct {
  180. // ReportApproveFlowId int `description:"报告审批流ID"`
  181. // Content string `description:"内容"`
  182. // ContentStruct string `description:"内容结构"`
  183. // NoChange int `description:"内容是否未改变:1:内容未改变"`
  184. //}
  185. //
  186. //// ReportApproveFlowSaveContentResp 保存草稿响应体
  187. //type ReportApproveFlowSaveContentResp struct {
  188. // ReportApproveFlowId int `description:"报告审批流ID"`
  189. //}
  190. //
  191. //// ReportApproveFlowSendMsgReq 消息推送请求体
  192. //type ReportApproveFlowSendMsgReq struct {
  193. // ReportApproveFlowId int `description:"报告审批流ID"`
  194. //}
  195. //
  196. //// ReportApproveFlowMarkEditReq 标记编辑英文研报的请求数据
  197. //type ReportApproveFlowMarkEditReq struct {
  198. // ReportApproveFlowId int `description:"报告审批流ID"`
  199. // Status int `description:"标记状态: 1-编辑中; 2-编辑完成"`
  200. //}
  201. //
  202. //// ReportApproveFlowListResp 报告审批流
  203. //type ReportApproveFlowListResp struct {
  204. // List []*ReportApproveFlowItem
  205. // Paging *paging.PagingItem `description:"分页数据"`
  206. //}
  207. //
  208. //// ElasticReportApproveFlow 报告审批流es
  209. //type ElasticReportApproveFlow struct {
  210. // ReportApproveFlowId int `description:"报告审批流ID"`
  211. // Title string `description:"标题"`
  212. // Abstract string `description:"摘要"`
  213. // BodyContent string `description:"内容"`
  214. // PublishTime string `description:"发布时间"`
  215. // PublishState int `description:"发布状态 1-未发布 2-已发布"`
  216. // Author string `description:"作者"`
  217. // ClassifyIdFirst int `description:"一级分类ID"`
  218. // ClassifyNameFirst string `description:"一级分类名称"`
  219. // ClassifyIdSecond int `description:"二级分类ID"`
  220. // ClassifyNameSecond string `description:"二级分类名称"`
  221. // StageStr string `description:"报告期数"`
  222. // Frequency string `description:"频度"`
  223. //}
  224. //
  225. //// Report2ImgQueueReq 报告详情生成长图队列请求体
  226. //type Report2ImgQueueReq struct {
  227. // ReportType int `description:"报告类型: 1-研报; 2-报告审批流"`
  228. // ReportCode string `description:"报告唯一编码"`
  229. //}
  230. type ReportClassifyTreeItem struct {
  231. ClassifyId int `description:"分类ID"`
  232. ClassifyName string `description:"分类名称"`
  233. ParentId int `description:"父级ID"`
  234. Children []*ReportClassifyTreeItem `description:"子分类"`
  235. }