diff --git a/src/super/dao/agent_list_dao.go b/src/super/dao/agent_list_dao.go index 5c6443d..adccf75 100644 --- a/src/super/dao/agent_list_dao.go +++ b/src/super/dao/agent_list_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -6,4 +6,5 @@ type AgentListDao interface { GetAgentList(agentId int) (medium *model.AgentList, err error) AgentListInsert(m *model.AgentList) (int64, error) UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) + FindAgentList(name, state string, page, limit int) (list []model.AgentList, total int64, err error) } diff --git a/src/super/dao/medium_list_dao.go b/src/super/dao/medium_list_dao.go index 1170254..23d47ae 100644 --- a/src/super/dao/medium_list_dao.go +++ b/src/super/dao/medium_list_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -6,4 +6,5 @@ type MediumListDao interface { GetMediumList(mediumId int) (medium *model.MediumList, err error) MediumListInsert(m *model.MediumList) (int64, error) UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) + FindMediumList(name, state string, page, limit int) (list []model.MediumList, total int64, err error) } diff --git a/src/super/implement/agent_list_implement.go b/src/super/implement/agent_list_implement.go index e973c71..3cacb55 100644 --- a/src/super/implement/agent_list_implement.go +++ b/src/super/implement/agent_list_implement.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" @@ -42,3 +42,17 @@ func (a AgentListDb) UpdateAgentList(m *model.AgentList, columns ...string) (int } return affected, nil } +func (a AgentListDb) FindAgentList(name, state string, page, limit int) (list []model.AgentList, total int64, err error) { + sess := a.Db.Where("state>0").Desc("id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("state = ?", state) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_list_implement.go b/src/super/implement/medium_list_implement.go index 2db54c6..f73bdc4 100644 --- a/src/super/implement/medium_list_implement.go +++ b/src/super/implement/medium_list_implement.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" @@ -42,3 +42,17 @@ func (m MediumListDb) UpdateMediumList(medium *model.MediumList, columns ...stri } return affected, nil } +func (m MediumListDb) FindMediumList(name, state string, page, limit int) (list []model.MediumList, total int64, err error) { + sess := m.Db.Where("state>0").Desc("id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("state = ?", state) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/model/agent_list.go b/src/super/model/agent_list.go index 3c2debf..6a7b303 100644 --- a/src/super/model/agent_list.go +++ b/src/super/model/agent_list.go @@ -22,4 +22,5 @@ type AgentList struct { State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` } diff --git a/src/super/model/medium_list.go b/src/super/model/medium_list.go index 7cdba50..8b59767 100644 --- a/src/super/model/medium_list.go +++ b/src/super/model/medium_list.go @@ -22,4 +22,5 @@ type MediumList struct { State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` }