diff --git a/src/dao/applet_application_ad_space_list_dao.go b/src/dao/applet_application_ad_space_list_dao.go index 0641baa..05d4486 100644 --- a/src/dao/applet_application_ad_space_list_dao.go +++ b/src/dao/applet_application_ad_space_list_dao.go @@ -3,9 +3,11 @@ package dao import "code.fnuoos.com/zhimeng/model.git/src/model" type AppletApplicationAdSpaceListDao interface { + GetAppletApplicationAdSpaceListByAdId(adId string) (medium *model.AppletApplicationAdSpaceList, err error) 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) + FindAppletApplicationAdSpaceList(name, platform string, adType, state string, mediumId, page, limit int) (list []AppletApplicationAdSpaceListGroup, total int64, err error) + FindAllAppletApplicationAdSpaceListList(appId string) (list []model.AppletApplicationAdSpaceList, err error) } type AppletApplicationAdSpaceListGroup struct { model.AppletApplicationAdSpaceList `xorm:"extends"` diff --git a/src/dao/applet_application_dao.go b/src/dao/applet_application_dao.go index c662f84..313b8fd 100644 --- a/src/dao/applet_application_dao.go +++ b/src/dao/applet_application_dao.go @@ -7,4 +7,5 @@ type AppletApplicationDao interface { FindAppletApplicationListByIds(id []string) (medium *[]model.AppletApplication, err error) GetAppletApplicationListByAppid(appId string) (medium *model.AppletApplication, err error) FindAppletApplicationList(name, platform string, state []string, mediumId, page, limit int) (list []model.AppletApplication, total int64, err error) + FindAllAppletApplicationList() (list []model.AppletApplication, 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 1365d42..5f95c53 100644 --- a/src/implement/applet_application_ad_space_list_implement.go +++ b/src/implement/applet_application_ad_space_list_implement.go @@ -32,7 +32,7 @@ func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceListByMedium } return medium, nil } -func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceList(name, platform string, state string, mediumId, page, limit int) (list []dao.AppletApplicationAdSpaceListGroup, total int64, err error) { +func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceList(name, platform string, adType, 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 { sess.Limit(limit, (page-1)*limit) @@ -46,6 +46,9 @@ func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceList(name, p if platform != "" { sess.And("applet_application.platform = ?", platform) } + if adType != "" { + sess.And("applet_application_ad_space_list.kind = ?", adType) + } if state != "" { sess.And("applet_application_ad_space_list.state = ?", state) } @@ -56,3 +59,24 @@ func (a AppletApplicationAdSpaceListDb) FindAppletApplicationAdSpaceList(name, p } return } + +func (a AppletApplicationAdSpaceListDb) GetAppletApplicationAdSpaceListByAdId(id string) (medium *model.AppletApplicationAdSpaceList, err error) { + medium = new(model.AppletApplicationAdSpaceList) + has, err := a.Db.Where("ad_id =?", id).Get(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return medium, nil +} + +func (a AppletApplicationAdSpaceListDb) FindAllAppletApplicationAdSpaceListList(appId string) (list []model.AppletApplicationAdSpaceList, err error) { + sess := a.Db.Where("app_id=?", appId).Desc("id") + err = sess.Find(&list) + if err != nil { + return nil, err + } + return +} diff --git a/src/implement/applet_application_implement.go b/src/implement/applet_application_implement.go index b47afc8..05fd304 100644 --- a/src/implement/applet_application_implement.go +++ b/src/implement/applet_application_implement.go @@ -26,6 +26,7 @@ func (a AppletApplicationDb) GetAppletApplicationList(id int) (medium *model.App } return medium, nil } + func (a AppletApplicationDb) FindAppletApplicationListByIds(id []string) (medium *[]model.AppletApplication, err error) { medium = new([]model.AppletApplication) err = a.Db.In("id", id).Find(medium) @@ -47,7 +48,7 @@ func (a AppletApplicationDb) GetAppletApplicationListByAppid(appId string) (medi } func (a AppletApplicationDb) FindAppletApplicationList(name, platform string, state []string, mediumId, page, limit int) (list []model.AppletApplication, total int64, err error) { - sess := a.Db.Where("id>0").Desc("id") + sess := a.Db.Desc("id") if page > 0 { sess.Limit(limit, (page-1)*limit) } @@ -69,3 +70,12 @@ func (a AppletApplicationDb) FindAppletApplicationList(name, platform string, st } return } + +func (a AppletApplicationDb) FindAllAppletApplicationList() (list []model.AppletApplication, err error) { + sess := a.Db.Desc("id") + err = sess.Find(&list) + if err != nil { + return nil, err + } + return +} diff --git a/src/super/dao/agent_with_medium_dao.go b/src/super/dao/agent_with_medium_dao.go index 4dbde6c..cb22410 100644 --- a/src/super/dao/agent_with_medium_dao.go +++ b/src/super/dao/agent_with_medium_dao.go @@ -5,6 +5,7 @@ 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) + FindAgentWithMediumListByMediumIdAll(mediumId int) (list []model.AgentWithMedium, err error) } type AgentWithMediumGroup struct { model.AgentWithMedium `xorm:"extends"` diff --git a/src/super/dao/medium_division_strategy_dao.go b/src/super/dao/medium_division_strategy_dao.go index 38f2d48..8f8d103 100644 --- a/src/super/dao/medium_division_strategy_dao.go +++ b/src/super/dao/medium_division_strategy_dao.go @@ -1,7 +1,12 @@ -package dao +package dao -import "code.fnuoos.com/zhimeng/model.git/src/super/model" +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/model" + "xorm.io/xorm" +) type MediumDivisionStrategyDao interface { GetOriginalWxAdDataByMediumId(mediumId int) (data *model.MediumDivisionStrategy, err error) + GetOriginalWxAdDataByMediumIdSess(sess *xorm.Session, mediumId int) (data *model.MediumDivisionStrategy, err error) + FindMediumDivisionStrategyList(uuid, mediumId string, page, limit int) (list []model.MediumDivisionStrategy, total int64, err error) } diff --git a/src/super/dao/medium_division_strategy_with_agent_flow_dao.go b/src/super/dao/medium_division_strategy_with_agent_flow_dao.go index 9fcb552..9318120 100644 --- a/src/super/dao/medium_division_strategy_with_agent_flow_dao.go +++ b/src/super/dao/medium_division_strategy_with_agent_flow_dao.go @@ -1,7 +1,12 @@ -package dao +package dao -import "code.fnuoos.com/zhimeng/model.git/src/super/model" +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/model" + "xorm.io/xorm" +) type MediumDivisionStrategyWithAgentFlowDao interface { FindMediumDivisionStrategyWithAgentFlowByStrategyId(strategyId int) (*[]model.MediumDivisionStrategyWithAgentFlow, error) + GetMediumDivisionStrategyWithAgentFlowSess(sess *xorm.Session, strategyId, agentId int) (data *model.MediumDivisionStrategyWithAgentFlow, err error) + GetMediumDivisionStrategyWithAgentFlow(strategyId, agentId int) (data *model.MediumDivisionStrategyWithAgentFlow, err error) } diff --git a/src/super/dao/original_wx_ad_data_dao.go b/src/super/dao/original_wx_ad_data_dao.go index c27b3d6..41904a6 100644 --- a/src/super/dao/original_wx_ad_data_dao.go +++ b/src/super/dao/original_wx_ad_data_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -7,6 +7,8 @@ import ( type OriginalWxAdDataDao interface { GetOriginalWxAdData(id int) (data *model.OriginalWxAdData, err error) + GetOriginalWxAdDataSess(sess *xorm.Session, id int) (data *model.OriginalWxAdData, err error) UpdateOriginalWxAdData(m *model.OriginalWxAdData, columns ...string) (int64, error) UpdateOriginalWxAdDataBySession(session *xorm.Session, m *model.OriginalWxAdData, columns ...string) (int64, error) + FindOriginalWxAdDataList(uuid, appId, slotId, date string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) } diff --git a/src/super/implement/agent_with_medium_db.go b/src/super/implement/agent_with_medium_db.go index f753708..6c4f28f 100644 --- a/src/super/implement/agent_with_medium_db.go +++ b/src/super/implement/agent_with_medium_db.go @@ -44,3 +44,14 @@ func (a AgentWithMediumDb) FindAgentWithMediumList(name, state string, agentId, } return } +func (a AgentWithMediumDb) FindAgentWithMediumListByMediumIdAll(mediumId int) (list []model.AgentWithMedium, err error) { + sess := a.Db.Desc("id") + if mediumId > 0 { + sess.And("medium_id = ?", mediumId) + } + err = sess.Find(&list) + if err != nil { + return nil, err + } + return +} diff --git a/src/super/implement/medium_division_strategy_implement.go b/src/super/implement/medium_division_strategy_implement.go index 94b836e..19939f7 100644 --- a/src/super/implement/medium_division_strategy_implement.go +++ b/src/super/implement/medium_division_strategy_implement.go @@ -1,9 +1,10 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" "code.fnuoos.com/zhimeng/model.git/src/super/model" zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "strings" "xorm.io/xorm" ) @@ -26,3 +27,28 @@ func (m MediumDivisionStrategyDb) GetOriginalWxAdDataByMediumId(mediumId int) (d } return data, nil } +func (m MediumDivisionStrategyDb) GetOriginalWxAdDataByMediumIdSess(sess *xorm.Session, mediumId int) (data *model.MediumDivisionStrategy, err error) { + data = new(model.MediumDivisionStrategy) + has, err := sess.Where("medium_id =?", mediumId).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} +func (m MediumDivisionStrategyDb) FindMediumDivisionStrategyList(uuid, mediumId string, page, limit int) (list []model.MediumDivisionStrategy, total int64, err error) { + sess := m.Db.Desc("id").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if mediumId != "" { + sess.In("medium_id", strings.Split(mediumId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_division_strategy_with_agent_flow_implement.go b/src/super/implement/medium_division_strategy_with_agent_flow_implement.go index 4ed5d0c..51d3ebe 100644 --- a/src/super/implement/medium_division_strategy_with_agent_flow_implement.go +++ b/src/super/implement/medium_division_strategy_with_agent_flow_implement.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" @@ -22,3 +22,25 @@ func (m MediumDivisionStrategyWithAgentFlowDb) FindMediumDivisionStrategyWithAge } return &mm, nil } +func (m MediumDivisionStrategyWithAgentFlowDb) GetMediumDivisionStrategyWithAgentFlowSess(sess *xorm.Session, strategyId, agentId int) (data *model.MediumDivisionStrategyWithAgentFlow, err error) { + data = new(model.MediumDivisionStrategyWithAgentFlow) + has, err := sess.Where("strategy_id=? and agent_id =?", strategyId, agentId).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} +func (m MediumDivisionStrategyWithAgentFlowDb) GetMediumDivisionStrategyWithAgentFlow(strategyId, agentId int) (data *model.MediumDivisionStrategyWithAgentFlow, err error) { + data = new(model.MediumDivisionStrategyWithAgentFlow) + has, err := m.Db.Where("strategy_id=? and agent_id =?", strategyId, agentId).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} diff --git a/src/super/implement/original_wx_ad_data_implement.go b/src/super/implement/original_wx_ad_data_implement.go index 6331a11..c0e52c2 100644 --- a/src/super/implement/original_wx_ad_data_implement.go +++ b/src/super/implement/original_wx_ad_data_implement.go @@ -1,9 +1,10 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" "code.fnuoos.com/zhimeng/model.git/src/super/model" zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "strings" "xorm.io/xorm" ) @@ -42,3 +43,34 @@ func (o OriginalWxAdDataDb) GetOriginalWxAdData(id int) (data *model.OriginalWxA } return data, nil } +func (o OriginalWxAdDataDb) GetOriginalWxAdDataSess(sess *xorm.Session, id int) (data *model.OriginalWxAdData, err error) { + data = new(model.OriginalWxAdData) + has, err := sess.Where("id =?", id).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} +func (o OriginalWxAdDataDb) FindOriginalWxAdDataList(uuid, appId, slotId, date string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) { + sess := o.Db.OrderBy("date desc,id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if date != "" { + sess.In("date", strings.Split(date, ",")) + } + if appId != "" { + sess.In("app_id", strings.Split(appId, ",")) + } + if slotId != "" { + sess.In("slot_id", strings.Split(slotId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +}