@@ -1,4 +1,4 @@ | |||||
package dao | |||||
package dao | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/model" | "code.fnuoos.com/zhimeng/model.git/src/model" | ||||
@@ -9,6 +9,7 @@ type AdminDao interface { | |||||
CreateAdminId() (admId int, err error) | CreateAdminId() (admId int, err error) | ||||
AdminDeleteBySession(session *xorm.Session, admId interface{}) (int64, error) | AdminDeleteBySession(session *xorm.Session, admId interface{}) (int64, error) | ||||
GetAdmin(id int) (m *model.Admin, err error) | GetAdmin(id int) (m *model.Admin, err error) | ||||
GetSuperAdmin() (m *model.Admin, err error) | |||||
GetAdminByUserName(userName string) (m *model.Admin, err error) | GetAdminByUserName(userName string) (m *model.Admin, err error) | ||||
GetAdminRolePermission(admId int) (list []*AdminRolePermission, total int64, err error) | GetAdminRolePermission(admId int) (list []*AdminRolePermission, total int64, err error) | ||||
FindAdmin(username string, state, page, limit int) (list []model.Admin, total int64, err error) | FindAdmin(username string, state, page, limit int) (list []model.Admin, total int64, err error) | ||||
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/dao" | "code.fnuoos.com/zhimeng/model.git/src/dao" | ||||
@@ -48,6 +48,17 @@ func (a AdminDb) GetAdmin(id int) (m *model.Admin, err error) { | |||||
} | } | ||||
return m, nil | return m, nil | ||||
} | } | ||||
func (a AdminDb) GetSuperAdmin() (m *model.Admin, err error) { | |||||
m = new(model.Admin) | |||||
has, err := a.Db.Where("is_super_administrator =?", 1).Get(m) | |||||
if err != nil { | |||||
return nil, zhios_order_relate_logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (a AdminDb) GetAdminByUserName(userName string) (m *model.Admin, err error) { | func (a AdminDb) GetAdminByUserName(userName string) (m *model.Admin, err error) { | ||||
m = new(model.Admin) | m = new(model.Admin) | ||||
@@ -29,7 +29,7 @@ func (a MediumBankInfoDb) GetMediumBankInfoList(MediumId int) (medium *model.Med | |||||
func (a MediumBankInfoDb) FindMediumBankInfoList(uuid, name, state string, page, limit int) (list []dao.MediumBankInfoGroup, total int64, err error) { | func (a MediumBankInfoDb) FindMediumBankInfoList(uuid, name, state string, page, limit int) (list []dao.MediumBankInfoGroup, total int64, err error) { | ||||
sess := a.Db.Where("medium_bank_info.state>0").Desc("medium_bank_info.id").Limit(limit, (page-1)*limit) | sess := a.Db.Where("medium_bank_info.state>0").Desc("medium_bank_info.id").Limit(limit, (page-1)*limit) | ||||
if name != "" { | if name != "" { | ||||
sess.And("medium_list.company_name like ?", "%"+name+"%") | |||||
sess.In("medium_list.medium_id", name) | |||||
} | } | ||||
if state != "" { | if state != "" { | ||||
sess.And("medium_bank_info.state = ?", state) | sess.And("medium_bank_info.state = ?", state) | ||||
@@ -29,7 +29,7 @@ func (a MediumContactInfoDb) GetMediumContactInfoList(MediumId int) (medium *mod | |||||
func (a MediumContactInfoDb) FindMediumContactInfoList(uuid, name, state string, page, limit int) (list []dao.MediumContactInfoGroup, total int64, err error) { | func (a MediumContactInfoDb) FindMediumContactInfoList(uuid, name, state string, page, limit int) (list []dao.MediumContactInfoGroup, total int64, err error) { | ||||
sess := a.Db.Where("medium_contact_info.state>0").Desc("medium_contact_info.id").Limit(limit, (page-1)*limit) | sess := a.Db.Where("medium_contact_info.state>0").Desc("medium_contact_info.id").Limit(limit, (page-1)*limit) | ||||
if name != "" { | if name != "" { | ||||
sess.And("medium_list.company_name like ?", "%"+name+"%") | |||||
sess.In("medium_list.medium_id", name) | |||||
} | } | ||||
if state != "" { | if state != "" { | ||||
sess.And("medium_contact_info.state = ?", state) | sess.And("medium_contact_info.state = ?", state) | ||||
@@ -55,7 +55,7 @@ func (m MediumListDb) UpdateMediumList(medium *model.MediumList, columns ...stri | |||||
func (m MediumListDb) FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) { | func (m MediumListDb) FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) { | ||||
sess := m.Db.Desc("id").Limit(limit, (page-1)*limit) | sess := m.Db.Desc("id").Limit(limit, (page-1)*limit) | ||||
if name != "" { | if name != "" { | ||||
sess.And("company_name like ?", "%"+name+"%") | |||||
sess.In("medium_id", name) | |||||
} | } | ||||
if state != "" { | if state != "" { | ||||
sess.And("state = ?", state) | sess.And("state = ?", state) | ||||