123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package knowledge_approve
- import (
- "eta_gn/eta_api/global"
- "fmt"
- "strings"
- "time"
- )
- type KnowledgeResourceApproveNode struct {
- KnowledgeResourceApproveNodeId int `gorm:"column:knowledge_resource_approve_node_id;primaryKey"`
- KnowledgeResourceApproveFlowId int `gorm:"column:knowledge_resource_approve_flow_id"`
- PrevNodeId int `gorm:"column:prev_node_id"`
- NextNodeId int `gorm:"column:next_node_id"`
- NodeType int `gorm:"column:node_type"`
- ApproveType int `gorm:"column:approve_type"`
- Users string `gorm:"column:users"`
- CurrVersion int `gorm:"column:curr_version"`
- CreatedTime time.Time `gorm:"column:created_time"`
- }
- var KnowledgeResourceApproveNodeCols = struct {
- KnowledgeResourceApproveNodeId string
- KnowledgeResourceApproveFlowId string
- PrevNodeId string
- NextNodeId string
- NodeType string
- ApproveType string
- Users string
- CurrVersion string
- CreatedTime string
- }{
- KnowledgeResourceApproveNodeId: "knowledge_resource_approve_node_id",
- KnowledgeResourceApproveFlowId: "knowledge_resource_approve_flow_id",
- PrevNodeId: "prev_node_id",
- NextNodeId: "next_node_id",
- NodeType: "node_type",
- ApproveType: "approve_type",
- Users: "users",
- CurrVersion: "curr_version",
- CreatedTime: "created_time",
- }
- func (b *KnowledgeResourceApproveNode) TableName() string {
- return "knowledge_resource_approve_node"
- }
- func (m *KnowledgeResourceApproveNode) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*KnowledgeResourceApproveNode, err error) {
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY created_time DESC, knowledge_resource_approve_node_id ASC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- func UpdateNextNodes(nodes []*KnowledgeResourceApproveNode) (err error) {
- if len(nodes) == 0 {
- return
- }
- updateCols := []string{"NextNodeId"}
- for _, v := range nodes {
- e := global.DmSQL["rddp"].Select(updateCols).Updates(v).Error
- if e != nil {
- err = fmt.Errorf("prev node update err: %v", e)
- return
- }
- }
- return
- }
- func GetKnowledgeResourceApproveNodeByCondition(condition string, pars []interface{}) (node []*KnowledgeResourceApproveNode, err error) {
- o := global.DmSQL["rddp"]
- sql := "SELECT * FROM knowledge_resource_approve_node WHERE 1=1 "
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql, pars...).Find(&node).Error
- return
- }
- func GetKnowledgeResourceApproveNodeByFlowIdAndVersionId(flowId int, versionId int) (node []*KnowledgeResourceApproveNode, err error) {
- err = global.DmSQL["rddp"].Model(&KnowledgeResourceApproveNode{}).Where("knowledge_resource_approve_flow_id =? AND curr_version =?", flowId, versionId).Scan(&node).Error
- return
- }
|