From c8cad18c59298670f7cf37638eb5722809cef855 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 22 Aug 2024 16:17:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/applet_application_ad_space_list.go | 2 +- src/super/dao/medium_bank_info_dao.go | 2 +- src/super/dao/medium_contact_info_dao.go | 2 +- src/super/dao/medium_list_dao.go | 2 +- src/super/implement/medium_bank_info_db.go | 5 ++++- src/super/implement/medium_contact_info_db.go | 5 ++++- src/super/implement/medium_list_implement.go | 5 ++++- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/model/applet_application_ad_space_list.go b/src/model/applet_application_ad_space_list.go index 4ccf038..c4de96b 100644 --- a/src/model/applet_application_ad_space_list.go +++ b/src/model/applet_application_ad_space_list.go @@ -9,7 +9,7 @@ type AppletApplicationAdSpaceList struct { Name string `json:"name" xorm:"default '' comment('广告位名称') VARCHAR(255)"` AppId string `json:"app_id" xorm:"not null default '' comment('小程序appid') VARCHAR(255)"` AdId string `json:"ad_id" xorm:"not null default '' comment('广告位id') VARCHAR(255)"` - Kind int `json:"kind" xorm:"not null default 1 comment('广告位类型(1:banner 2:激励视频 3:插屏广告 4:视频广告 5:视频贴片广告)') TINYINT(1)"` + Kind string `json:"kind" xorm:"not null default '' comment('广告位类型(SLOT_ID_WEAPP_BANNER:banner SLOT_ID_WEAPP_REWARD_VIDEO:激励视频 SLOT_ID_WEAPP_INTERSTITIAL:插屏广告 SLOT_ID_WEAPP_VIDEO_FEEDS:视频广告 SLOT_ID_WEAPP_VIDEO_BEGIN:视频贴片广告)') VARCHAR(255)"` State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝 3:封禁中)') TINYINT(1)"` CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` diff --git a/src/super/dao/medium_bank_info_dao.go b/src/super/dao/medium_bank_info_dao.go index 15a8da9..83e59be 100644 --- a/src/super/dao/medium_bank_info_dao.go +++ b/src/super/dao/medium_bank_info_dao.go @@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" type MediumBankInfoDao interface { GetMediumBankInfoList(MediumId int) (medium *model.MediumBankInfo, err error) - FindMediumBankInfoList(name, state string, page, limit int) (list []MediumBankInfoGroup, total int64, err error) + FindMediumBankInfoList(uuid, name, state string, page, limit int) (list []MediumBankInfoGroup, total int64, err error) } type MediumBankInfoGroup struct { model.MediumList `xorm:"extends"` diff --git a/src/super/dao/medium_contact_info_dao.go b/src/super/dao/medium_contact_info_dao.go index de27098..f15ae1e 100644 --- a/src/super/dao/medium_contact_info_dao.go +++ b/src/super/dao/medium_contact_info_dao.go @@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" type MediumContactInfoDao interface { GetMediumContactInfoList(MediumId int) (medium *model.MediumContactInfo, err error) - FindMediumContactInfoList(name, state string, page, limit int) (list []MediumContactInfoGroup, total int64, err error) + FindMediumContactInfoList(uuid, name, state string, page, limit int) (list []MediumContactInfoGroup, total int64, err error) } type MediumContactInfoGroup struct { model.MediumList `xorm:"extends"` diff --git a/src/super/dao/medium_list_dao.go b/src/super/dao/medium_list_dao.go index 23d47ae..04b77e1 100644 --- a/src/super/dao/medium_list_dao.go +++ b/src/super/dao/medium_list_dao.go @@ -6,5 +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) + FindMediumList(uuid, name, state string, page, limit int) (list []model.MediumList, total int64, err error) } diff --git a/src/super/implement/medium_bank_info_db.go b/src/super/implement/medium_bank_info_db.go index 8856b14..27becf7 100644 --- a/src/super/implement/medium_bank_info_db.go +++ b/src/super/implement/medium_bank_info_db.go @@ -26,7 +26,7 @@ func (a MediumBankInfoDb) GetMediumBankInfoList(MediumId int) (medium *model.Med } return medium, nil } -func (a MediumBankInfoDb) FindMediumBankInfoList(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) if name != "" { sess.And("medium_list.company_name like ?", "%"+name+"%") @@ -34,6 +34,9 @@ func (a MediumBankInfoDb) FindMediumBankInfoList(name, state string, page, limit if state != "" { sess.And("medium_bank_info.state = ?", state) } + if uuid != "" { + sess.And("medium_bank_info.uuid = ?", uuid) + } sess.Join("LEFT", "medium_list", "medium_list.medium_id = medium_bank_info.medium_id") total, err = sess.FindAndCount(&list) if err != nil { diff --git a/src/super/implement/medium_contact_info_db.go b/src/super/implement/medium_contact_info_db.go index d8e0bfb..69968b3 100644 --- a/src/super/implement/medium_contact_info_db.go +++ b/src/super/implement/medium_contact_info_db.go @@ -26,7 +26,7 @@ func (a MediumContactInfoDb) GetMediumContactInfoList(MediumId int) (medium *mod } return medium, nil } -func (a MediumContactInfoDb) FindMediumContactInfoList(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) if name != "" { sess.And("medium_list.company_name like ?", "%"+name+"%") @@ -34,6 +34,9 @@ func (a MediumContactInfoDb) FindMediumContactInfoList(name, state string, page, if state != "" { sess.And("medium_contact_info.state = ?", state) } + if uuid != "" { + sess.And("medium_contact_info.uuid = ?", uuid) + } sess.Join("LEFT", "medium_list", "medium_list.medium_id = medium_contact_info.medium_id") total, err = sess.FindAndCount(&list) if err != nil { diff --git a/src/super/implement/medium_list_implement.go b/src/super/implement/medium_list_implement.go index f73bdc4..716824e 100644 --- a/src/super/implement/medium_list_implement.go +++ b/src/super/implement/medium_list_implement.go @@ -42,7 +42,7 @@ 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) { +func (m MediumListDb) FindMediumList(uuid, 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+"%") @@ -50,6 +50,9 @@ func (m MediumListDb) FindMediumList(name, state string, page, limit int) (list if state != "" { sess.And("state = ?", state) } + if uuid != "" { + sess.And("uuid = ?", uuid) + } total, err = sess.FindAndCount(&list) if err != nil { return nil, 0, err From f18aa08f09b1bcda1951c3f2035a38bea663ea7b Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 22 Aug 2024 17:50:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/applet_application_ad_space_list_dao.go | 1 + .../applet_application_ad_space_list_implement.go | 9 +++++++++ src/model/applet_application_ad_space_list.go | 1 + 3 files changed, 11 insertions(+) diff --git a/src/dao/applet_application_ad_space_list_dao.go b/src/dao/applet_application_ad_space_list_dao.go index 49f4adf..0641baa 100644 --- a/src/dao/applet_application_ad_space_list_dao.go +++ b/src/dao/applet_application_ad_space_list_dao.go @@ -3,6 +3,7 @@ package dao import "code.fnuoos.com/zhimeng/model.git/src/model" type AppletApplicationAdSpaceListDao interface { + FindAppletApplicationAdSpaceListByMediumId(mediumId int) (medium *[]model.AppletApplicationAdSpaceList, err error) FindAppletApplicationAdSpaceListByIds(id []string) (medium *[]model.AppletApplicationAdSpaceList, err error) FindAppletApplicationAdSpaceList(name, platform string, state string, mediumId, page, limit int) (list []AppletApplicationAdSpaceListGroup, total int64, err error) } diff --git a/src/implement/applet_application_ad_space_list_implement.go b/src/implement/applet_application_ad_space_list_implement.go index 6e37a6d..1365d42 100644 --- a/src/implement/applet_application_ad_space_list_implement.go +++ b/src/implement/applet_application_ad_space_list_implement.go @@ -23,6 +23,15 @@ func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceListByIds(id } return medium, nil } +func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceListByMediumId(mediumId int) (medium *[]model.AppletApplicationAdSpaceList, err error) { + + medium = new([]model.AppletApplicationAdSpaceList) + err = a.Db.Where("medium_id=?", mediumId).Find(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return medium, nil +} func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceList(name, platform string, state string, mediumId, page, limit int) (list []dao.AppletApplicationAdSpaceListGroup, total int64, err error) { sess := a.Db.Where("applet_application_ad_space_list.id>0").Desc("applet_application_ad_space_list.id") if page > 0 { diff --git a/src/model/applet_application_ad_space_list.go b/src/model/applet_application_ad_space_list.go index c4de96b..21116fa 100644 --- a/src/model/applet_application_ad_space_list.go +++ b/src/model/applet_application_ad_space_list.go @@ -11,6 +11,7 @@ type AppletApplicationAdSpaceList struct { AdId string `json:"ad_id" xorm:"not null default '' comment('广告位id') VARCHAR(255)"` Kind string `json:"kind" xorm:"not null default '' comment('广告位类型(SLOT_ID_WEAPP_BANNER:banner SLOT_ID_WEAPP_REWARD_VIDEO:激励视频 SLOT_ID_WEAPP_INTERSTITIAL:插屏广告 SLOT_ID_WEAPP_VIDEO_FEEDS:视频广告 SLOT_ID_WEAPP_VIDEO_BEGIN:视频贴片广告)') VARCHAR(255)"` State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝 3:封禁中)') TINYINT(1)"` + UseState int `json:"use_state" xorm:"not null default 1 comment('广告位微信平台状态(1开通 2关闭)') TINYINT(1)"` CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` MediumId int `json:"medium_id" xorm:"not null comment('媒体id') default '0' INT(10)"` From 34202e969e8d90ee1f6b6147e362cefe4992db04 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 23 Aug 2024 11:40:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B8=A0=E9=81=93=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd_super_implement.bat | 2 +- etc/template/template_implement.tpl | 2 +- etc/template/template_super_implement.tpl | 14 ++++++ src/dao/agent_dao.go | 4 +- src/dao/medium_dao.go | 1 + src/implement/agent_implement.go | 22 +++++++++- src/implement/medium_implement.go | 9 ++++ src/super/dao/agent_bank_info_dao.go | 2 +- src/super/dao/agent_contact_info_dao.go | 2 +- src/super/dao/agent_list_dao.go | 2 +- src/super/dao/agent_with_medium_dao.go | 17 ++++++++ src/super/dao/medium_list_dao.go | 2 +- src/super/implement/agent_bank_info_db.go | 5 ++- src/super/implement/agent_contact_info_db.go | 5 ++- src/super/implement/agent_list_implement.go | 10 ++++- src/super/implement/agent_with_medium_db.go | 46 ++++++++++++++++++++ src/super/implement/medium_list_implement.go | 7 ++- src/super/model/agent_with_medium.go | 13 ++++++ 18 files changed, 151 insertions(+), 14 deletions(-) create mode 100644 etc/template/template_super_implement.tpl create mode 100644 src/super/dao/agent_with_medium_dao.go create mode 100644 src/super/implement/agent_with_medium_db.go create mode 100644 src/super/model/agent_with_medium.go diff --git a/cmd_super_implement.bat b/cmd_super_implement.bat index 83457cf..06db61c 100644 --- a/cmd_super_implement.bat +++ b/cmd_super_implement.bat @@ -13,7 +13,7 @@ REM 将文件名转换成大驼峰格式并设置成最终实现类名 for /f "delims=" %%i in ('powershell -File "%BasePath%etc\ps\ConvertToUpperCase.ps1" -inputString "%FileName%"') do set "ImplementName=%%i" REM 使用 PowerShell 替换接口名称,并指定 UTF-8 编码 -powershell -Command "(Get-Content '%BasePath%etc\template\template_implement.tpl') -replace 'DemoImplement', '%ImplementName%' | Out-File -FilePath '%BasePath%temp_implement.go' -Encoding UTF8" +powershell -Command "(Get-Content '%BasePath%etc\template\template_super_implement.tpl') -replace 'DemoImplement', '%ImplementName%' | Out-File -FilePath '%BasePath%temp_implement.go' -Encoding UTF8" REM 如果需要,将临时文件重命名为最终文件(取决于move Y?N) move /Y "%BasePath%temp_implement.go" "%FinalFile%" diff --git a/etc/template/template_implement.tpl b/etc/template/template_implement.tpl index ecc280f..c3dcaf2 100644 --- a/etc/template/template_implement.tpl +++ b/etc/template/template_implement.tpl @@ -1,7 +1,7 @@ package implement import ( - "applet/app/db/dao" + "code.fnuoos.com/zhimeng/model.git/src/dao" "xorm.io/xorm" ) diff --git a/etc/template/template_super_implement.tpl b/etc/template/template_super_implement.tpl new file mode 100644 index 0000000..85d5bb6 --- /dev/null +++ b/etc/template/template_super_implement.tpl @@ -0,0 +1,14 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "xorm.io/xorm" +) + +func NewDemoImplementDb(engine *xorm.Engine) dao.DemoImplementDao { + return &DemoImplementDb{Db: engine} +} + +type DemoImplementDb struct { + Db *xorm.Engine +} \ No newline at end of file diff --git a/src/dao/agent_dao.go b/src/dao/agent_dao.go index ae3b6aa..27866b6 100644 --- a/src/dao/agent_dao.go +++ b/src/dao/agent_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/zhimeng/model.git/src/model" @@ -14,6 +14,8 @@ type AgentDao interface { FindAdmin(username string, state, page, limit int) (list []model.Agent, total int64, err error) GetAgent(id int) (m *model.Agent, err error) FindAgentRolePermissionGroup(id int) (list []*AgentWithRolePermissionGroup, total int64, err error) + GetSuperAdmin(agentId int) (list *model.Agent) + GetSuperAgentByUsername(username string) (agent *model.Agent, err error) } type AgentWithRolePermissionGroup struct { diff --git a/src/dao/medium_dao.go b/src/dao/medium_dao.go index e6bd389..d497dc6 100644 --- a/src/dao/medium_dao.go +++ b/src/dao/medium_dao.go @@ -15,6 +15,7 @@ type MediumDao interface { GetMedium(id int) (m *model.Medium, err error) FindMediumRolePermissionGroup(id int) (list []*MediumWithRolePermissionGroup, total int64, err error) FindSuperAdmin(username, memo string, page, limit int) (list []model.Medium, total int64, err error) + GetSuperAdmin(mediumId int) (list *model.Medium) } type MediumWithRolePermissionGroup struct { diff --git a/src/implement/agent_implement.go b/src/implement/agent_implement.go index 7fbb2ad..8d9ec6a 100644 --- a/src/implement/agent_implement.go +++ b/src/implement/agent_implement.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/dao" @@ -98,3 +98,23 @@ func (a AgentDb) FindAgentRolePermissionGroup(id int) (list []*dao.AgentWithRole FindAndCount(&list) return } +func (a AgentDb) GetSuperAdmin(agentId int) (list *model.Agent) { + list = new(model.Agent) + sess := a.Db.Where("is_super_administrator=1 and agent_id=?", agentId) + get, err := sess.Get(list) + if err != nil || get == false { + return nil + } + return list +} +func (a AgentDb) GetSuperAgentByUsername(username string) (agent *model.Agent, err error) { + agent = new(model.Agent) + has, err := a.Db.Where("is_super_administrator=1 and username =?", username).Get(agent) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return agent, nil +} diff --git a/src/implement/medium_implement.go b/src/implement/medium_implement.go index cefff0c..1d31a5c 100644 --- a/src/implement/medium_implement.go +++ b/src/implement/medium_implement.go @@ -112,3 +112,12 @@ func (m MediumDb) FindSuperAdmin(username, memo string, page, limit int) (list [ } return } +func (m MediumDb) GetSuperAdmin(mediumId int) (list *model.Medium) { + list = new(model.Medium) + sess := m.Db.Where("is_super_administrator=1 and medium_id=?", mediumId) + get, err := sess.Get(list) + if err != nil || get == false { + return nil + } + return list +} diff --git a/src/super/dao/agent_bank_info_dao.go b/src/super/dao/agent_bank_info_dao.go index fe01d16..f10118b 100644 --- a/src/super/dao/agent_bank_info_dao.go +++ b/src/super/dao/agent_bank_info_dao.go @@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" type AgentBankInfoDao interface { GetAgentBankInfoList(agentId int) (medium *model.AgentBankInfo, err error) - FindAgentBankInfoList(name, state string, page, limit int) (list []AgentBankInfoGroup, total int64, err error) + FindAgentBankInfoList(uuid, name, state string, page, limit int) (list []AgentBankInfoGroup, total int64, err error) } type AgentBankInfoGroup struct { model.AgentList `xorm:"extends"` diff --git a/src/super/dao/agent_contact_info_dao.go b/src/super/dao/agent_contact_info_dao.go index 171a380..d665f40 100644 --- a/src/super/dao/agent_contact_info_dao.go +++ b/src/super/dao/agent_contact_info_dao.go @@ -4,7 +4,7 @@ import "code.fnuoos.com/zhimeng/model.git/src/super/model" type AgentContactInfoDao interface { GetAgentContactInfoList(agentId int) (medium *model.AgentContactInfo, err error) - FindAgentContactInfoList(name, state string, page, limit int) (list []AgentContactInfoGroup, total int64, err error) + FindAgentContactInfoList(uuid, name, state string, page, limit int) (list []AgentContactInfoGroup, total int64, err error) } type AgentContactInfoGroup struct { model.AgentList `xorm:"extends"` diff --git a/src/super/dao/agent_list_dao.go b/src/super/dao/agent_list_dao.go index adccf75..3c83a91 100644 --- a/src/super/dao/agent_list_dao.go +++ b/src/super/dao/agent_list_dao.go @@ -6,5 +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) + FindAgentList(uuid, name, state string, minState, page, limit int) (list []model.AgentList, total int64, err error) } diff --git a/src/super/dao/agent_with_medium_dao.go b/src/super/dao/agent_with_medium_dao.go new file mode 100644 index 0000000..4dbde6c --- /dev/null +++ b/src/super/dao/agent_with_medium_dao.go @@ -0,0 +1,17 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type AgentWithMediumDao interface { + FindAgentWithMediumList(name, state string, agentId, mediumId, page, limit int) (list []AgentWithMediumGroup, total int64, err error) + GetAgentWithMediumByMediumIdAndAgentId(mediumId, agentId int) (medium *model.AgentWithMedium) +} +type AgentWithMediumGroup struct { + model.AgentWithMedium `xorm:"extends"` + model.MediumList `xorm:"extends"` + model.AgentList `xorm:"extends"` +} + +func (AgentWithMediumGroup) TableName() string { + return "agent_with_medium" +} diff --git a/src/super/dao/medium_list_dao.go b/src/super/dao/medium_list_dao.go index 04b77e1..376a32c 100644 --- a/src/super/dao/medium_list_dao.go +++ b/src/super/dao/medium_list_dao.go @@ -6,5 +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(uuid, name, state string, page, limit int) (list []model.MediumList, total int64, err error) + FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) } diff --git a/src/super/implement/agent_bank_info_db.go b/src/super/implement/agent_bank_info_db.go index 3b49a94..3c7fd98 100644 --- a/src/super/implement/agent_bank_info_db.go +++ b/src/super/implement/agent_bank_info_db.go @@ -26,7 +26,7 @@ func (a AgentBankInfoDb) GetAgentBankInfoList(agentId int) (medium *model.AgentB } return medium, nil } -func (a AgentBankInfoDb) FindAgentBankInfoList(name, state string, page, limit int) (list []dao.AgentBankInfoGroup, total int64, err error) { +func (a AgentBankInfoDb) FindAgentBankInfoList(uuid, name, state string, page, limit int) (list []dao.AgentBankInfoGroup, total int64, err error) { sess := a.Db.Where("agent_bank_info.state>0").Desc("agent_bank_info.id").Limit(limit, (page-1)*limit) if name != "" { sess.And("agent_list.company_name like ?", "%"+name+"%") @@ -34,6 +34,9 @@ func (a AgentBankInfoDb) FindAgentBankInfoList(name, state string, page, limit i if state != "" { sess.And("agent_bank_info.state = ?", state) } + if uuid != "" { + sess.And("agent_bank_info.uuid = ?", uuid) + } sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_bank_info.agent_id") total, err = sess.FindAndCount(&list) if err != nil { diff --git a/src/super/implement/agent_contact_info_db.go b/src/super/implement/agent_contact_info_db.go index 0ec85b5..caba0b3 100644 --- a/src/super/implement/agent_contact_info_db.go +++ b/src/super/implement/agent_contact_info_db.go @@ -26,7 +26,7 @@ func (a AgentContactInfoDb) GetAgentContactInfoList(agentId int) (medium *model. } return medium, nil } -func (a AgentContactInfoDb) FindAgentContactInfoList(name, state string, page, limit int) (list []dao.AgentContactInfoGroup, total int64, err error) { +func (a AgentContactInfoDb) FindAgentContactInfoList(uuid, name, state string, page, limit int) (list []dao.AgentContactInfoGroup, total int64, err error) { sess := a.Db.Where("agent_contact_info.state>0").Desc("agent_contact_info.id").Limit(limit, (page-1)*limit) if name != "" { sess.And("agent_list.company_name like ?", "%"+name+"%") @@ -34,6 +34,9 @@ func (a AgentContactInfoDb) FindAgentContactInfoList(name, state string, page, l if state != "" { sess.And("agent_contact_info.state = ?", state) } + if uuid != "" { + sess.And("agent_contact_info.uuid = ?", uuid) + } sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_contact_info.agent_id") total, err = sess.FindAndCount(&list) if err != nil { diff --git a/src/super/implement/agent_list_implement.go b/src/super/implement/agent_list_implement.go index 3cacb55..7cdbf43 100644 --- a/src/super/implement/agent_list_implement.go +++ b/src/super/implement/agent_list_implement.go @@ -42,14 +42,20 @@ 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) +func (a AgentListDb) FindAgentList(uuid, name, state string, minState, page, limit int) (list []model.AgentList, total int64, err error) { + sess := a.Db.Desc("id").Limit(limit, (page-1)*limit) if name != "" { sess.And("company_name like ?", "%"+name+"%") } if state != "" { sess.And("state = ?", state) } + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if minState > 0 { + sess.And("state >= ?", minState) + } total, err = sess.FindAndCount(&list) if err != nil { return nil, 0, err diff --git a/src/super/implement/agent_with_medium_db.go b/src/super/implement/agent_with_medium_db.go new file mode 100644 index 0000000..f753708 --- /dev/null +++ b/src/super/implement/agent_with_medium_db.go @@ -0,0 +1,46 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + "xorm.io/xorm" +) + +func NewAgentWithMediumDb(engine *xorm.Engine) dao.AgentWithMediumDao { + return &AgentWithMediumDb{Db: engine} +} + +type AgentWithMediumDb struct { + Db *xorm.Engine +} + +func (a AgentWithMediumDb) GetAgentWithMediumByMediumIdAndAgentId(mediumId, agentId int) (medium *model.AgentWithMedium) { + medium = new(model.AgentWithMedium) + get, err := a.Db.Where("medium_id=? and agent_id=?", mediumId, agentId).Get(medium) + if get == false || err != nil { + return nil + } + return medium +} +func (a AgentWithMediumDb) FindAgentWithMediumList(name, state string, agentId, mediumId, page, limit int) (list []dao.AgentWithMediumGroup, total int64, err error) { + sess := a.Db.Desc("agent_with_medium.id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("medium_list.company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("medium_list.state = ?", state) + } + if agentId > 0 { + sess.And("agent_with_medium.agent_id = ?", agentId) + } + if mediumId > 0 { + sess.And("agent_with_medium.medium_id = ?", mediumId) + } + sess.Join("LEFT", "medium_list", "medium_list.medium_id = agent_with_medium.medium_id") + sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_with_medium.agent_id") + 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 716824e..b3059b2 100644 --- a/src/super/implement/medium_list_implement.go +++ b/src/super/implement/medium_list_implement.go @@ -42,8 +42,8 @@ func (m MediumListDb) UpdateMediumList(medium *model.MediumList, columns ...stri } return affected, nil } -func (m MediumListDb) FindMediumList(uuid, 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) +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) if name != "" { sess.And("company_name like ?", "%"+name+"%") } @@ -53,6 +53,9 @@ func (m MediumListDb) FindMediumList(uuid, name, state string, page, limit int) if uuid != "" { sess.And("uuid = ?", uuid) } + if minState > 0 { + sess.And("state >= ?", minState) + } total, err = sess.FindAndCount(&list) if err != nil { return nil, 0, err diff --git a/src/super/model/agent_with_medium.go b/src/super/model/agent_with_medium.go new file mode 100644 index 0000000..f8fb75a --- /dev/null +++ b/src/super/model/agent_with_medium.go @@ -0,0 +1,13 @@ +package model + +import ( + "time" +) + +type AgentWithMedium struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + AgentId int `json:"agent_id" xorm:"not null default 0 comment('代理id') INT(11)"` + MediumId int `json:"medium_id" xorm:"not null default 0 comment('媒体id') INT(11)"` + CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` +}