@@ -1,4 +1,4 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/zhimeng/model.git/src/super/model" | 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) | GetAgentList(agentId int) (medium *model.AgentList, err error) | ||||
AgentListInsert(m *model.AgentList) (int64, error) | AgentListInsert(m *model.AgentList) (int64, error) | ||||
UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) | UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) | ||||
FindAgentList(name, state string, page, limit int) (list []model.AgentList, total int64, err error) | |||||
} | } |
@@ -1,4 +1,4 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/zhimeng/model.git/src/super/model" | 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) | GetMediumList(mediumId int) (medium *model.MediumList, err error) | ||||
MediumListInsert(m *model.MediumList) (int64, error) | MediumListInsert(m *model.MediumList) (int64, error) | ||||
UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) | UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) | ||||
FindMediumList(name, state string, page, limit int) (list []model.MediumList, total int64, err error) | |||||
} | } |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/super/dao" | "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 | 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 | |||||
} |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/super/dao" | "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 | 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 | |||||
} |
@@ -22,4 +22,5 @@ type AgentList struct { | |||||
State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` | 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"` | CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | ||||
UpdateAt string `json:"update_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)"` | |||||
} | } |
@@ -22,4 +22,5 @@ type MediumList struct { | |||||
State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` | 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"` | CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | ||||
UpdateAt string `json:"update_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)"` | |||||
} | } |