123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- package report_approve
- import (
- "eta/eta_api/utils"
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "strings"
- "time"
- )
- const (
- FlowReportTypeChinese = iota + 1
- FlowReportTypeEnglish
- FlowReportTypeSmart
- )
- // ReportApproveFlow 报告审批流表
- type ReportApproveFlow struct {
- ReportApproveFlowId int `orm:"column(report_approve_flow_id);pk" description:"审批流ID"`
- FlowName string `description:"审批流名称"`
- ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
- ClassifyFirstId int `description:"一级分类ID"`
- ClassifySecondId int `description:"二级分类ID"`
- CurrVersion int `description:"当前版本号"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func (m *ReportApproveFlow) TableName() string {
- return "report_approve_flow"
- }
- func (m *ReportApproveFlow) PrimaryId() string {
- return "report_approve_flow_id"
- }
- func (m *ReportApproveFlow) Create() (err error) {
- o := orm.NewOrmUsingDB("rddp")
- id, err := o.Insert(m)
- if err != nil {
- return
- }
- m.ReportApproveFlowId = int(id)
- return
- }
- func (m *ReportApproveFlow) CreateMulti(items []*ReportApproveFlow) (err error) {
- if len(items) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.InsertMulti(len(items), items)
- return
- }
- func (m *ReportApproveFlow) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Update(m, cols...)
- return
- }
- func (m *ReportApproveFlow) Del() (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- _, err = o.Raw(sql, m.ReportApproveFlowId).Exec()
- return
- }
- func (m *ReportApproveFlow) MultiDel(menuIds []int) (err error) {
- if len(menuIds) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("rddp")
- sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.PrimaryId(), utils.GetOrmInReplace(len(menuIds)))
- _, err = o.Raw(sql, menuIds).Exec()
- return
- }
- func (m *ReportApproveFlow) GetItemById(id int) (item *ReportApproveFlow, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- err = o.Raw(sql, id).QueryRow(&item)
- return
- }
- func (m *ReportApproveFlow) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *ReportApproveFlow, err error) {
- o := orm.NewOrmUsingDB("rddp")
- order := ``
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
- err = o.Raw(sql, pars).QueryRow(&item)
- return
- }
- func (m *ReportApproveFlow) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- func (m *ReportApproveFlow) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*ReportApproveFlow, err error) {
- o := orm.NewOrmUsingDB("rddp")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- func (m *ReportApproveFlow) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*ReportApproveFlow, err error) {
- o := orm.NewOrmUsingDB("rddp")
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // ReportApproveFlowItem 报告审批流信息
- type ReportApproveFlowItem struct {
- ReportApproveFlowId int `description:"审批流ID"`
- FlowName string `description:"审批流名称"`
- ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
- ClassifyFirstId int `description:"一级分类ID"`
- ClassifySecondId int `description:"二级分类ID"`
- CurrVersion int `description:"当前版本号"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"修改时间"`
- }
- // FormatReportApproveFlow2Item 格式化报告审批流
- func FormatReportApproveFlow2Item(origin *ReportApproveFlow) (item *ReportApproveFlowItem) {
- item = new(ReportApproveFlowItem)
- if origin == nil {
- return
- }
- item.ReportApproveFlowId = origin.ReportApproveFlowId
- item.FlowName = origin.FlowName
- item.ReportType = origin.ReportType
- item.ClassifyFirstId = origin.ClassifyFirstId
- item.ClassifySecondId = origin.ClassifySecondId
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- return
- }
- // ReportApproveFlowAddReq 新增报告审批流请求体
- type ReportApproveFlowAddReq struct {
- FlowName string `description:"审批流名称"`
- ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
- ClassifyFirstId int `description:"一级分类ID"`
- ClassifySecondId int `description:"二级分类ID"`
- }
- //
- //// ReportApproveFlowEditReq 编辑报告审批流请求体
- //type ReportApproveFlowEditReq struct {
- // ReportApproveFlowAddReq
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // Content string `description:"内容"`
- // ContentStruct string `description:"内容结构"`
- //}
- //
- //// ReportApproveFlowRemoveReq 删除报告审批流请求体
- //type ReportApproveFlowRemoveReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- //}
- //
- //// ReportApproveFlowPublishReq 发布报告审批流请求体
- //type ReportApproveFlowPublishReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // PublishState int `description:"1-取消发布; 2-发布"`
- //}
- //
- //// ReportApproveFlowPrePublishReq 预发布报告审批流请求体
- //type ReportApproveFlowPrePublishReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // PrePublishTime string `description:"预发布时间"`
- // PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
- //}
- //
- //// ReportApproveFlowSaveContentReq 保存草稿请求体
- //type ReportApproveFlowSaveContentReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // Content string `description:"内容"`
- // ContentStruct string `description:"内容结构"`
- // NoChange int `description:"内容是否未改变:1:内容未改变"`
- //}
- //
- //// ReportApproveFlowSaveContentResp 保存草稿响应体
- //type ReportApproveFlowSaveContentResp struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- //}
- //
- //// ReportApproveFlowSendMsgReq 消息推送请求体
- //type ReportApproveFlowSendMsgReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- //}
- //
- //// ReportApproveFlowMarkEditReq 标记编辑英文研报的请求数据
- //type ReportApproveFlowMarkEditReq struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // Status int `description:"标记状态: 1-编辑中; 2-编辑完成"`
- //}
- //
- //// ReportApproveFlowListResp 报告审批流
- //type ReportApproveFlowListResp struct {
- // List []*ReportApproveFlowItem
- // Paging *paging.PagingItem `description:"分页数据"`
- //}
- //
- //// ElasticReportApproveFlow 报告审批流es
- //type ElasticReportApproveFlow struct {
- // ReportApproveFlowId int `description:"报告审批流ID"`
- // Title string `description:"标题"`
- // Abstract string `description:"摘要"`
- // BodyContent string `description:"内容"`
- // PublishTime string `description:"发布时间"`
- // PublishState int `description:"发布状态 1-未发布 2-已发布"`
- // Author string `description:"作者"`
- // ClassifyIdFirst int `description:"一级分类ID"`
- // ClassifyNameFirst string `description:"一级分类名称"`
- // ClassifyIdSecond int `description:"二级分类ID"`
- // ClassifyNameSecond string `description:"二级分类名称"`
- // StageStr string `description:"报告期数"`
- // Frequency string `description:"频度"`
- //}
- //
- //// Report2ImgQueueReq 报告详情生成长图队列请求体
- //type Report2ImgQueueReq struct {
- // ReportType int `description:"报告类型: 1-研报; 2-报告审批流"`
- // ReportCode string `description:"报告唯一编码"`
- //}
- type ReportClassifyTreeItem struct {
- ClassifyId int `description:"分类ID"`
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级ID"`
- Children []*ReportClassifyTreeItem `description:"子分类"`
- }
|