diff --git a/src/dao/egg_energy_community_dividends_dao.go b/src/dao/egg_energy_community_dividends_dao.go index d7b4eba..04c62cc 100644 --- a/src/dao/egg_energy_community_dividends_dao.go +++ b/src/dao/egg_energy_community_dividends_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type EggEnergyCommunityDividendsDao interface { //TODO:: You can add specific method definitions here + EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) } diff --git a/src/dao/egg_energy_community_dividends_with_user_dao.go b/src/dao/egg_energy_community_dividends_with_user_dao.go index 6310857..57cf4fe 100644 --- a/src/dao/egg_energy_community_dividends_with_user_dao.go +++ b/src/dao/egg_energy_community_dividends_with_user_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type EggEnergyCommunityDividendsWithUserDao interface { //TODO:: You can add specific method definitions here + EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) } diff --git a/src/dao/public_platoon_free_punish_with_user_dao.go b/src/dao/public_platoon_free_punish_with_user_dao.go index 081f9cb..c1792fd 100644 --- a/src/dao/public_platoon_free_punish_with_user_dao.go +++ b/src/dao/public_platoon_free_punish_with_user_dao.go @@ -9,4 +9,5 @@ type PublicPlatoonFreePunishWithUserDao interface { FindAllPublicPlatoonFreePunishWithUser() (resp map[int64]*model.PublicPlatoonFreePunishWithUser, err error) PublicPlatoonFreePunishWithUserInsert(PublicPlatoonFreePunishWithUser *model.PublicPlatoonFreePunishWithUser) (int, error) PublicPlatoonFreePunishWithUserUpdate(Db *xorm.Engine, id interface{}, PublicPlatoonFreePunishWithUser *model.PublicPlatoonFreePunishWithUser, forceColums ...string) (int64, error) + PublicPlatoonFreePunishWithUserCountAndGetPageByParams(page int, limit int, params map[string]interface{}) ([]model.PublicPlatoonFreePunishWithUser, int64, error) } diff --git a/src/dao/public_platoon_user_relation_dao.go b/src/dao/public_platoon_user_relation_dao.go index 06f5b97..29efc9c 100644 --- a/src/dao/public_platoon_user_relation_dao.go +++ b/src/dao/public_platoon_user_relation_dao.go @@ -13,6 +13,5 @@ type PublicPlatoonUserRelationDao interface { PublicPlatoonUserRelationFindByPid(fatherUid int64, fatherName, positionName string) ([]model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationFindCountByPosition(fatherUid int64, fatherName, positionName string, startPosition, endPosition int64) ([]model.PublicPlatoonUserRelation, int64, error) PublicPlatoonUserRelationFindByParamsByPage(params map[string]interface{}, page, pageSize int) (*[]model.PublicPlatoonUserRelation, error) - PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) } diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index 6d80308..df3f2e2 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -3,6 +3,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type UserDao interface { - //TODO:: You can add specific method definitions here UserGetOneByParams(params map[string]interface{}) (*model.User, error) + UserFindByParams(params map[string]interface{}) ([]model.User, error) } diff --git a/src/implement/egg_energy_community_dividends_implement.go b/src/implement/egg_energy_community_dividends_implement.go index 60bf1a4..17fa65e 100644 --- a/src/implement/egg_energy_community_dividends_implement.go +++ b/src/implement/egg_energy_community_dividends_implement.go @@ -2,6 +2,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "xorm.io/xorm" ) @@ -12,3 +13,11 @@ func NewEggEnergyCommunityDividendsDb(engine *xorm.Engine) dao.EggEnergyCommunit type EggEnergyCommunityDividendsDb struct { Db *xorm.Engine } + +func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) { + _, err := e.Db.InsertOne(EggEnergyCommunityDividends) + if err != nil { + return 0, err + } + return EggEnergyCommunityDividends.Id, nil +} diff --git a/src/implement/egg_energy_community_dividends_with_user_implement.go b/src/implement/egg_energy_community_dividends_with_user_implement.go index e9c5fa7..8443af7 100644 --- a/src/implement/egg_energy_community_dividends_with_user_implement.go +++ b/src/implement/egg_energy_community_dividends_with_user_implement.go @@ -2,6 +2,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "xorm.io/xorm" ) @@ -12,3 +13,11 @@ func NewEggEnergyCommunityDividendsWithUserDb(engine *xorm.Engine) dao.EggEnergy type EggEnergyCommunityDividendsWithUserDb struct { Db *xorm.Engine } + +func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) { + _, err := e.Db.InsertOne(EggEnergyCommunityDividendsWithUser) + if err != nil { + return 0, err + } + return EggEnergyCommunityDividendsWithUser.Id, nil +} diff --git a/src/implement/public_platoon_free_punish_with_user_implement.go b/src/implement/public_platoon_free_punish_with_user_implement.go index 51ba211..1087bda 100644 --- a/src/implement/public_platoon_free_punish_with_user_implement.go +++ b/src/implement/public_platoon_free_punish_with_user_implement.go @@ -4,6 +4,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" "xorm.io/xorm" ) @@ -51,3 +52,26 @@ func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserUpdate } return affected, nil } + +func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserCountAndGetPageByParams(page int, limit int, params map[string]interface{}) ([]model.PublicPlatoonFreePunishWithUser, int64, error) { + + var publicPlatoonFreePunishWithUser model.PublicPlatoonFreePunishWithUser + total, err := p.Db.Where("").Count(&publicPlatoonFreePunishWithUser) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + + var m []model.PublicPlatoonFreePunishWithUser + session := p.Db + var err1 error + if params != nil { + query := fmt.Sprintf("%s = ?", params["key"]) + err1 = session.Where(query, params["value"]).Limit(limit, page-1).Find(&m) + } else { + err1 = session.Where("1=1").Limit(limit, page-1).Find(&m) + } + if err1 != nil { + return nil, 0, zhios_order_relate_logx.Error(err1) + } + return m, total, nil +} diff --git a/src/implement/public_platoon_user_relation_implement.go b/src/implement/public_platoon_user_relation_implement.go index 122da10..eda6e4d 100644 --- a/src/implement/public_platoon_user_relation_implement.go +++ b/src/implement/public_platoon_user_relation_implement.go @@ -120,18 +120,6 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByParamsByPage } } -func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error) { - var parent model.PublicPlatoonUserRelation - has, err := p.Db.Where("uid = ?", uid).Get(&parent) - if err != nil { - return nil, zhios_order_relate_logx.Error(err) - } - if has == false { - return nil, zhios_order_relate_logx.Error("未查询到上级用户公排记录") - } - return &parent, nil -} - func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) { var relation model.PublicPlatoonUserRelation _, err := p.Db.Where("position = ?", position).Get(&relation) @@ -140,27 +128,3 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByPosition(p } return &relation, nil } - -func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUserRelation, leveLimit int) ([]*model.PublicPlatoonUserRelation, error) { - if leveLimit == 0 { - leveLimit = 1 - } - var res []*model.PublicPlatoonUserRelation - var queue []*model.PublicPlatoonUserRelation - queue = append(queue, head) - for len(queue) > 0 { - node := queue[0] - queue = queue[1:] - if node.Level1 > head.Level1+leveLimit { - break - } - res = append(res, node) - var son []*model.PublicPlatoonUserRelation - err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(son) - if err1 != nil { - return nil, zhios_order_relate_logx.Error(err1) - } - queue = append(queue, son...) - } - return res, nil -} diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index 3d59ccd..0646c95 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -3,8 +3,10 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" "fmt" + "reflect" "xorm.io/xorm" ) @@ -24,3 +26,20 @@ func (u UserDb) UserGetOneByParams(params map[string]interface{}) (*model.User, } return &m, nil } + +func (u UserDb) UserFindByParams(params map[string]interface{}) ([]model.User, error) { + var m []model.User + if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { + //指定In查询 + if err := u.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil { + return nil, zhios_order_relate_logx.Warn(err) + } + } else { + var query = fmt.Sprintf("%s =?", params["key"]) + err := u.Db.Where(query, params["value"]).Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + } + return m, nil +}