123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package knowledge_approve
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "fmt"
- "strings"
- "time"
- )
- type KnowledgeResourceApproveMessage struct {
- Id int `gorm:"primaryKey;column:id"`
- SendUserId int `gorm:"column:send_user_id"` // 发送人Id
- ReceiveUserId int `gorm:"column:receive_user_id"` // 接收者Id
- Content string `gorm:"column:content"` // 消息内容
- Remark string `gorm:"column:remark"` // 备注信息
- KnowledgeResourceApproveId int `gorm:"column:knowledge_resource_approve_id"` // 审批Id
- ApproveState int `gorm:"column:approve_state"` // 审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回
- IsRead int `gorm:"column:is_read"` // 是否已读:0-未读;1-已读
- CreateTime time.Time `gorm:"column:create_time"` // 创建时间
- ModifyTime time.Time `gorm:"column:modify_time"` // 修改时间
- }
- var KnowledgeResourceApproveMessageCols = struct {
- Id string
- SendUserId string
- ReceiveUserId string
- Content string
- Remark string
- KnowledgeResourceApproveId string
- ApproveState string
- IsRead string
- CreateTime string
- ModifyTime string
- }{
- Id: "id",
- SendUserId: "send_user_id",
- ReceiveUserId: "receive_user_id",
- Content: "content",
- Remark: "remark",
- KnowledgeResourceApproveId: "knowledge_resource_approve_id",
- ApproveState: "approve_state",
- IsRead: "is_read",
- CreateTime: "create_time",
- ModifyTime: "modify_time",
- }
- func (r *KnowledgeResourceApproveMessage) TableName() string {
- return "knowledge_resource_approve_message"
- }
- func (r *KnowledgeResourceApproveMessage) Create() (err error) {
- o := global.DmSQL["rddp"]
- err = o.Create(r).Error
- return err
- }
- func (m *KnowledgeResourceApproveMessage) PrimaryId() string {
- return KnowledgeResourceApproveMessageCols.Id
- }
- func (r *KnowledgeResourceApproveMessage) CreateMulti(items []*KnowledgeResourceApproveMessage) (err error) {
- if len(items) == 0 {
- return
- }
- o := global.DmSQL["rddp"]
- err = o.CreateInBatches(items, utils.MultiAddNum).Error
- return
- }
- func (m *KnowledgeResourceApproveMessage) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
- return
- }
- func (m *KnowledgeResourceApproveMessage) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*KnowledgeResourceApproveMessage, err error) {
- 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 = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- func (m *KnowledgeResourceApproveMessage) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*KnowledgeResourceApproveMessage, err error) {
- 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)
- pars = append(pars, startSize, pageSize)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- func (m *KnowledgeResourceApproveMessage) GetItemById(id int) (item *KnowledgeResourceApproveMessage, err error) {
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? `, m.TableName(), m.PrimaryId())
- err = global.DmSQL["rddp"].Raw(sql, id).First(&item).Error
- return
- }
- func (m *KnowledgeResourceApproveMessage) Update(cols []string) (err error) {
- err = global.DmSQL["rddp"].Model(m).Select(cols).Updates(m).Error
- return
- }
|