123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- package knowledge_approve
- import (
- "eta_gn/eta_api/global"
- "fmt"
- "time"
- )
- type KnowledgeResourceApprove struct {
- KnowledgeResourceApproveId int `gorm:"column:knowledge_resource_approve_id;primary_key"`
- KnowledgeResourceId int `gorm:"column:knowledge_resource_id"`
- KnowledgeResourceTitle string `gorm:"column:knowledge_resource_title"`
- ClassifyId int `gorm:"column:classify_id"`
- State int `gorm:"column:state"` // '审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回'
- FlowId int `gorm:"column:flow_id"`
- FlowVersion int `gorm:"column:flow_version"`
- StartNodeId int `gorm:"column:start_node_id"`
- CurrNodeId int `gorm:"column:curr_node_id"`
- ApplyUserId int `gorm:"column:apply_user_id"`
- ApplyUserName string `gorm:"column:apply_user_name"`
- ApproveRemark string `gorm:"column:approve_remark"`
- ApproveTime time.Time `gorm:"column:approve_time"`
- CreateTime time.Time `gorm:"column:create_time"`
- ModifyTime time.Time `gorm:"column:update_time"`
- }
- var KnowledgeResourceApproveCols = struct {
- KnowledgeResourceApproveId string
- KnowledgeResourceId string
- KnowledgeResourceTitle string
- ClassifyId string
- State string // '审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回'
- FlowId string
- FlowVersion string
- StartNodeId string
- CurrNodeId string
- ApplyUserId string
- ApplyUserName string
- ApproveRemark string
- ApproveTime string
- CreateTime string
- ModifyTime string
- }{
- KnowledgeResourceApproveId: "knowledge_resource_approve_id",
- KnowledgeResourceId: "knowledge_resource_id",
- KnowledgeResourceTitle: "knowledge_resource_title",
- ClassifyId: "classify_id",
- State: "state",
- FlowId: "flow_id",
- FlowVersion: "flow_version",
- StartNodeId: "start_node_id",
- CurrNodeId: "curr_node_id",
- ApplyUserId: "apply_user_id",
- ApplyUserName: "apply_user_name",
- ApproveRemark: "approve_remark",
- ApproveTime: "approve_time",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- type KnowledgeResourceApproveItemOrm struct {
- KnowledgeResourceApproveId int `description:"审批ID"`
- KnowledgeResourceApproveRecordId int `description:"审批记录ID"`
- KnowledgeResourceId int `description:"报告ID"`
- KnowledgeResourceTitle string `description:"报告标题"`
- ClassifyId int `description:"分类ID"`
- State int `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
- RecordState int `description:"审批记录状态:1-待审批;2-已通过;3-已驳回"`
- FlowId int `description:"审批流ID"`
- FlowVersion int `description:"审批流版本"`
- StartNodeId int `description:"开始节点ID"`
- CurrNodeId int `description:"当前节点ID"`
- ApplyUserId int `description:"申请人ID"`
- ApplyUserName string `description:"申请人姓名"`
- ApproveRemark string `description:"审批备注"`
- ApproveTime time.Time `description:"审批时间"`
- HandleTime time.Time `description:"处理时间"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- NodeState int `description:"当前节点审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回" json:"-"`
- NodeApproveTime time.Time `description:"当前节点审批时间" json:"-"`
- }
- func (b *KnowledgeResourceApprove) TableName() string {
- return "knowledge_resource_approve"
- }
- func (b *KnowledgeResourceApprove) Update(cols []string) (err error) {
- db := global.DmSQL["rddp"]
- err = db.Model(b).Select(cols).Updates(b).Error
- return
- }
- func (b *KnowledgeResourceApprove) Create() (err error) {
- db := global.DmSQL["rddp"]
- err = db.Create(b).Error
- return
- }
- func GetKnowledgeResourceApproveByFlowIdAndVersionId(knowledgeFlowId int, flowVersion int) (item []*KnowledgeResourceApprove, err error) {
- db := global.DmSQL["rddp"]
- err = db.Where("flow_id = ? AND flow_version = ?", knowledgeFlowId, flowVersion).Find(&item).Error
- return
- }
- func GetKnowledgeResourceApproveById(KnowledgeResourceApproveId int) (item *KnowledgeResourceApprove, err error) {
- db := global.DmSQL["rddp"]
- err = db.Where("knowledge_resource_approve_id = ?", KnowledgeResourceApproveId).First(&item).Error
- return
- }
- // GetApprovingKnowledgeResourceApproveCount 获取待处理的审批分页列表总数
- func GetApprovingKnowledgeResourceApproveCount(cond string, pars []interface{}) (count int, err error) {
- base := fmt.Sprintf(`SELECT a.knowledge_resource_approve_record_id
- FROM knowledge_resource_approve_record AS a
- JOIN knowledge_resource_approve AS b ON a.knowledge_resource_approve_id = b.knowledge_resource_approve_id AND a.node_id = b.curr_node_id
- WHERE 1 = 1 %s`, cond)
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
- return
- }
- // GetApprovingKnowledgeResourceApprovePageList 获取待处理的审批列表-分页
- func GetApprovingKnowledgeResourceApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*KnowledgeResourceApproveItemOrm, err error) {
- order := `ORDER BY a.create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT a.knowledge_resource_approve_record_id, a.state AS record_state, b.*
- FROM knowledge_resource_approve_record AS a
- JOIN knowledge_resource_approve AS b ON a.knowledge_resource_approve_id = b.knowledge_resource_approve_id AND a.node_id = b.curr_node_id
- WHERE 1 = 1 %s %s
- LIMIT ?,?`, cond, order)
- pars = append(pars, startSize, pageSize)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- // GetApprovedKnowledgeResourceApproveCount 获取已处理的审批分页列表总数
- func GetApprovedKnowledgeResourceApproveCount(cond string, pars []interface{}) (count int, err error) {
- base := fmt.Sprintf(`SELECT a.knowledge_resource_approve_record_id
- FROM knowledge_resource_approve_record AS a
- JOIN knowledge_resource_approve AS b ON a.knowledge_resource_approve_id = b.knowledge_resource_approve_id
- WHERE 1 = 1 %s`, cond)
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
- return
- }
- // GetApprovedKnowledgeResourceApprovePageList 获取已处理的审批列表-分页
- func GetApprovedKnowledgeResourceApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*KnowledgeResourceApproveItemOrm, err error) {
- order := `ORDER BY a.create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT a.knowledge_resource_approve_record_id, a.node_state AS record_state,a.node_state,a.node_approve_time, a.node_approve_time AS handle_time, b.*
- FROM knowledge_resource_approve_record AS a
- JOIN knowledge_resource_approve AS b ON a.knowledge_resource_approve_id = b.knowledge_resource_approve_id
- WHERE 1 = 1 %s %s
- LIMIT ?,?`, cond, order)
- pars = append(pars, startSize, pageSize)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- // GetApplyKnowledgeResourceApproveCount 获取我发起的审批分页列表总数
- func GetApplyKnowledgeResourceApproveCount(cond string, pars []interface{}) (count int, err error) {
- base := fmt.Sprintf(`SELECT a.* FROM knowledge_resource_approve AS a WHERE 1 = 1 %s`, cond)
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
- return
- }
- // GetApplyKnowledgeResourceApprovePageList 获取我发起的审批列表-分页
- func GetApplyKnowledgeResourceApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*KnowledgeResourceApproveItemOrm, err error) {
- order := `ORDER BY a.create_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT a.* FROM knowledge_resource_approve AS a WHERE 1 = 1 %s %s LIMIT ?,?`, cond, order)
- pars = append(pars, startSize, pageSize)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- func GetKnowledgeResourceApproveByBoardId(KnowledgeResourceApproveId int) (item *KnowledgeResourceApprove, err error) {
- db := global.DmSQL["rddp"]
- err = db.Where("knowledge_resource_id = ?", KnowledgeResourceApproveId).Order("create_time DESC").First(&item).Error
- return
- }
- func GetKnowledgeResourceApproveCountByState(state int) (count int, err error) {
- db := global.DmSQL["rddp"]
- sql := `SELECT COUNT(*) FROM knowledge_resource_approve WHERE state = ?`
- err = db.Raw(sql, state).Scan(&count).Error
- return
- }
|