|
@@ -3,7 +3,8 @@ package public_platoon |
|
|
import ( |
|
|
import ( |
|
|
"applet/app/db" |
|
|
"applet/app/db" |
|
|
"applet/app/e" |
|
|
"applet/app/e" |
|
|
"applet/app/md/institutional_management/public_platoon" |
|
|
|
|
|
|
|
|
md "applet/app/md/institutional_management/public_platoon" |
|
|
|
|
|
svc "applet/app/svc/public_platoon" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
"errors" |
|
|
"errors" |
|
@@ -18,7 +19,7 @@ import ( |
|
|
// @Accept json |
|
|
// @Accept json |
|
|
// @Produce json |
|
|
// @Produce json |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
// @Success 200 {object} public_platoon.GetPublicPlatoonBasicResp "具体数据" |
|
|
|
|
|
|
|
|
// @Success 200 {object} md.GetPublicPlatoonBasicResp "具体数据" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Router /api/publicPlatoon/getBasic [get] |
|
|
// @Router /api/publicPlatoon/getBasic [get] |
|
|
func GetPublicPlatoonBasic(c *gin.Context) { |
|
|
func GetPublicPlatoonBasic(c *gin.Context) { |
|
@@ -48,9 +49,8 @@ func GetPublicPlatoonBasic(c *gin.Context) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var resp public_platoon.GetPublicPlatoonBasicResp |
|
|
|
|
|
resp = public_platoon.GetPublicPlatoonBasicResp{ |
|
|
|
|
|
|
|
|
var resp md.GetPublicPlatoonBasicResp |
|
|
|
|
|
resp = md.GetPublicPlatoonBasicResp{ |
|
|
IsOpen: publicPlatoonBasic.IsOpen, |
|
|
IsOpen: publicPlatoonBasic.IsOpen, |
|
|
OriginatorUid: publicPlatoonBasic.OriginatorUid, |
|
|
OriginatorUid: publicPlatoonBasic.OriginatorUid, |
|
|
SeveralTimes: publicPlatoonBasic.SeveralTimes, |
|
|
SeveralTimes: publicPlatoonBasic.SeveralTimes, |
|
@@ -75,7 +75,7 @@ func GetPublicPlatoonBasic(c *gin.Context) { |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Router /api/publicPlatoon/getBasic [post] |
|
|
// @Router /api/publicPlatoon/getBasic [post] |
|
|
func UpdatePublicPlatoonBasic(c *gin.Context) { |
|
|
func UpdatePublicPlatoonBasic(c *gin.Context) { |
|
|
var req *public_platoon.UpdatePublicPlatoonBasicReq |
|
|
|
|
|
|
|
|
var req *md.UpdatePublicPlatoonBasicReq |
|
|
if err := c.ShouldBindJSON(&req); err != nil { |
|
|
if err := c.ShouldBindJSON(&req); err != nil { |
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
return |
|
|
return |
|
@@ -121,125 +121,55 @@ func UpdatePublicPlatoonBasic(c *gin.Context) { |
|
|
// @Accept json |
|
|
// @Accept json |
|
|
// @Produce json |
|
|
// @Produce json |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
// @Param req query public_platoon.GetRelationshipMapReq false "用户ID 手机号" |
|
|
|
|
|
// @Success 200 {object} public_platoon.RelationshipMapResp "具体数据" |
|
|
|
|
|
|
|
|
// @param phone query string true "phone" |
|
|
|
|
|
// @param uid query string true "uid" |
|
|
|
|
|
// @Success 200 {object} md.TreeNode "具体数据" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Router /api/publicPlatoon/relationshipMap [get] |
|
|
// @Router /api/publicPlatoon/relationshipMap [get] |
|
|
func GetRelationshipMap(c *gin.Context) { |
|
|
func GetRelationshipMap(c *gin.Context) { |
|
|
var req *public_platoon.GetRelationshipMapReq |
|
|
|
|
|
if err := c.ShouldBindQuery(&req); err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
phone := c.Query("phone") |
|
|
|
|
|
uid := c.Query("uid") |
|
|
userDb := implement.NewUserDb(db.Db) |
|
|
userDb := implement.NewUserDb(db.Db) |
|
|
var uid int64 |
|
|
|
|
|
if req.Phone != 0 { |
|
|
|
|
|
user, err1 := userDb.UserGetOneByPhone(req.Phone) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
var relation *model.PublicPlatoonUserRelation |
|
|
|
|
|
var err error |
|
|
|
|
|
if phone != "" { |
|
|
|
|
|
user, err1 := userDb.UserGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "phone", |
|
|
|
|
|
"value": phone, |
|
|
|
|
|
}) |
|
|
if err1 != nil { |
|
|
if err1 != nil { |
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
} |
|
|
} |
|
|
uid = user.Id |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if req.Uid != 0 { |
|
|
|
|
|
uid = req.Uid |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UserRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
relations, err2 := UserRelationDb.PublicPlatoonUserRelationFind(uid) |
|
|
|
|
|
if err2 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
user, err3 := userDb.UserGetOneById(relations[0].Uid) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var son []public_platoon.RelationshipMap |
|
|
|
|
|
res := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: user.Avatar, |
|
|
|
|
|
Phone: user.Phone, |
|
|
|
|
|
Nickname: user.Nickname, |
|
|
|
|
|
Uid: user.Id, |
|
|
|
|
|
Pid: relations[0].RecommendUid, |
|
|
|
|
|
Level: relations[0].Level1, |
|
|
|
|
|
Position: relations[0].Position1, |
|
|
|
|
|
SystemID: relations[0].Id, |
|
|
|
|
|
Son: son, |
|
|
|
|
|
} |
|
|
|
|
|
m := make(map[int64]public_platoon.RelationshipMap) |
|
|
|
|
|
m[res.Uid] = res |
|
|
|
|
|
for i := 1; i < len(relations); i++ { |
|
|
|
|
|
currentUser, err4 := userDb.UserGetOneById(relations[i].Uid) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
|
|
|
|
|
relation, err = userRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "uid", |
|
|
|
|
|
"value": user.Id, |
|
|
|
|
|
}) |
|
|
|
|
|
} else if uid != "" { |
|
|
|
|
|
relation, err = userRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "uid", |
|
|
|
|
|
"value": uid, |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
relation, err = userRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "level_total", |
|
|
|
|
|
"value": 1, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var sonNodes []public_platoon.RelationshipMap |
|
|
|
|
|
node := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: currentUser.Avatar, |
|
|
|
|
|
Phone: currentUser.Phone, |
|
|
|
|
|
Nickname: currentUser.Nickname, |
|
|
|
|
|
Uid: currentUser.Id, |
|
|
|
|
|
Pid: relations[i].RecommendUid, |
|
|
|
|
|
Level: relations[i].Level1, |
|
|
|
|
|
Position: relations[i].Position1, |
|
|
|
|
|
SystemID: relations[i].Id, |
|
|
|
|
|
Son: sonNodes, |
|
|
|
|
|
} |
|
|
|
|
|
m[node.Uid] = node |
|
|
|
|
|
if fatherNode, isOk := m[relations[i].FatherUid1]; isOk { |
|
|
|
|
|
fatherNode.Son = append(fatherNode.Son, node) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
publicPlatoonBasicDb := implement.NewPublicPlatoonBasicSettingDb(db.Db) |
|
|
|
|
|
publicPlatoonBasic, err := publicPlatoonBasicDb.PublicPlatoonBasicSettingGetOne() |
|
|
|
|
|
|
|
|
var list *md.TreeNode |
|
|
|
|
|
list, err = svc.GetTrees(db.Db, relation, 3) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
e.OutErr(c, e.ERR_DB_ORM, err) |
|
|
|
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
now := time.Now() |
|
|
|
|
|
if publicPlatoonBasic == nil { |
|
|
|
|
|
publicPlatoonBasic = &model.PublicPlatoonBasicSetting{ |
|
|
|
|
|
IsOpen: 1, |
|
|
|
|
|
OriginatorUid: 0, |
|
|
|
|
|
SeveralTimes: 0, |
|
|
|
|
|
SeveralRows: 0, |
|
|
|
|
|
SystemPunishReplace: 0, |
|
|
|
|
|
SystemPunishReplaceValue: 0, |
|
|
|
|
|
IsSelfActiveGetTeamRevenue: 0, |
|
|
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
|
|
} |
|
|
|
|
|
_, err1 := publicPlatoonBasicDb.PublicPlatoonBasicSettingInsert(publicPlatoonBasic) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
var basicSetting public_platoon.GetPublicPlatoonBasicResp |
|
|
|
|
|
basicSetting = public_platoon.GetPublicPlatoonBasicResp{ |
|
|
|
|
|
IsOpen: publicPlatoonBasic.IsOpen, |
|
|
|
|
|
OriginatorUid: publicPlatoonBasic.OriginatorUid, |
|
|
|
|
|
SeveralTimes: publicPlatoonBasic.SeveralTimes, |
|
|
|
|
|
SeveralRows: publicPlatoonBasic.SeveralRows, |
|
|
|
|
|
SystemPunishReplace: publicPlatoonBasic.SystemPunishReplace, |
|
|
|
|
|
SystemPunishReplaceValue: publicPlatoonBasic.SystemPunishReplaceValue, |
|
|
|
|
|
IsSelfActiveGetTeamRevenue: publicPlatoonBasic.IsSelfActiveGetTeamRevenue, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if uid == 0 { |
|
|
|
|
|
uid = relations[0].Uid |
|
|
|
|
|
} |
|
|
|
|
|
var resp public_platoon.RelationshipMapResp |
|
|
|
|
|
resp = public_platoon.RelationshipMapResp{ |
|
|
|
|
|
Map: res, |
|
|
|
|
|
BasicSetting: basicSetting, |
|
|
|
|
|
SearchUid: uid, |
|
|
|
|
|
} |
|
|
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
|
|
|
|
|
e.OutSuc(c, list, nil) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// FindUserRelationshipMap |
|
|
// FindUserRelationshipMap |
|
@@ -253,132 +183,132 @@ func GetRelationshipMap(c *gin.Context) { |
|
|
// @Success 200 {object} public_platoon.RelationshipMap "具体数据" |
|
|
// @Success 200 {object} public_platoon.RelationshipMap "具体数据" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Router /api/publicPlatoon/findUserRelationshipMap [get] |
|
|
// @Router /api/publicPlatoon/findUserRelationshipMap [get] |
|
|
func FindUserRelationshipMap(c *gin.Context) { |
|
|
|
|
|
var req *public_platoon.FindUserRelationshipMapReq |
|
|
|
|
|
if err := c.ShouldBindQuery(&req); err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
relations, err1 := RelationDb.PublicPlatoonUserRelationFindByUid(req.Uid) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userDb := implement.NewUserDb(db.Db) |
|
|
|
|
|
user, err3 := userDb.UserGetOneById(relations[0].Uid) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var son []public_platoon.RelationshipMap |
|
|
|
|
|
res := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: user.Avatar, |
|
|
|
|
|
Phone: user.Phone, |
|
|
|
|
|
Nickname: user.Nickname, |
|
|
|
|
|
Uid: user.Id, |
|
|
|
|
|
Pid: relations[0].RecommendUid, |
|
|
|
|
|
Level: relations[0].Level1, |
|
|
|
|
|
Position: relations[0].Position1, |
|
|
|
|
|
SystemID: relations[0].Id, |
|
|
|
|
|
Son: son, |
|
|
|
|
|
} |
|
|
|
|
|
for i := 1; i < len(relations); i++ { |
|
|
|
|
|
user, err4 := userDb.UserGetOneById(relations[i].Uid) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
node := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: user.Avatar, |
|
|
|
|
|
Phone: user.Phone, |
|
|
|
|
|
Nickname: user.Nickname, |
|
|
|
|
|
Uid: user.Id, |
|
|
|
|
|
Pid: relations[i].RecommendUid, |
|
|
|
|
|
Level: relations[i].Level1, |
|
|
|
|
|
Position: relations[i].Position1, |
|
|
|
|
|
SystemID: relations[i].Id, |
|
|
|
|
|
Son: nil, |
|
|
|
|
|
} |
|
|
|
|
|
res.Son = append(res.Son, node) |
|
|
|
|
|
} |
|
|
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FindSubUserRelationshipMap |
|
|
|
|
|
// @Summary 制度中心-公排管理-关系分布图(获取指定用户上级) |
|
|
|
|
|
// @Tags 公排管理 |
|
|
|
|
|
// @Description 关系分布图(获取指定用户上级) |
|
|
|
|
|
// @Accept json |
|
|
|
|
|
// @Produce json |
|
|
|
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
|
|
|
// @Param req query public_platoon.FindSubUserRelationshipMapReq true "用户ID" |
|
|
|
|
|
// @Success 200 {object} public_platoon.RelationshipMap "具体数据" |
|
|
|
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
|
|
|
// @Router /api/publicPlatoon/findSubUserRelationshipMap [get] |
|
|
|
|
|
func FindSubUserRelationshipMap(c *gin.Context) { |
|
|
|
|
|
var req *public_platoon.FindSubUserRelationshipMapReq |
|
|
|
|
|
if err := c.ShouldBindQuery(&req); err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
sonRelation, err1 := RelationDb.PublicPlatoonUserRelationGetOneByUid(req.Uid) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
parentRelation, err2 := RelationDb.PublicPlatoonUserRelationGetOneByUid(sonRelation.FatherUid1) |
|
|
|
|
|
if err2 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userDb := implement.NewUserDb(db.Db) |
|
|
|
|
|
son, err3 := userDb.UserGetOneById(sonRelation.Uid) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parent, err4 := userDb.UserGetOneById(parentRelation.Uid) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var sonNode []public_platoon.RelationshipMap |
|
|
|
|
|
sonNode1 := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: son.Avatar, |
|
|
|
|
|
Phone: son.Phone, |
|
|
|
|
|
Nickname: son.Nickname, |
|
|
|
|
|
Uid: son.Id, |
|
|
|
|
|
Pid: sonRelation.RecommendUid, |
|
|
|
|
|
Level: sonRelation.Level1, |
|
|
|
|
|
Position: sonRelation.Position1, |
|
|
|
|
|
SystemID: sonRelation.Id, |
|
|
|
|
|
Son: nil, |
|
|
|
|
|
} |
|
|
|
|
|
sonNode = append(sonNode, sonNode1) |
|
|
|
|
|
res := public_platoon.RelationshipMap{ |
|
|
|
|
|
AvatarUrl: parent.Avatar, |
|
|
|
|
|
Phone: parent.Phone, |
|
|
|
|
|
Nickname: parent.Nickname, |
|
|
|
|
|
Uid: parent.Id, |
|
|
|
|
|
Pid: parentRelation.RecommendUid, |
|
|
|
|
|
Level: parentRelation.Level1, |
|
|
|
|
|
Position: parentRelation.Position1, |
|
|
|
|
|
SystemID: parentRelation.Id, |
|
|
|
|
|
Son: sonNode, |
|
|
|
|
|
} |
|
|
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//func FindUserRelationshipMap(c *gin.Context) { |
|
|
|
|
|
// var req *public_platoon.FindUserRelationshipMapReq |
|
|
|
|
|
// if err := c.ShouldBindQuery(&req); err != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// RelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
// relations, err1 := RelationDb.PublicPlatoonUserRelationFindByUid(req.Uid) |
|
|
|
|
|
// if err1 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err1) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// userDb := implement.NewUserDb(db.Db) |
|
|
|
|
|
// user, err3 := userDb.UserGetOneById(relations[0].Uid) |
|
|
|
|
|
// if err3 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// var son []public_platoon.RelationshipMap |
|
|
|
|
|
// res := public_platoon.RelationshipMap{ |
|
|
|
|
|
// AvatarUrl: user.Avatar, |
|
|
|
|
|
// Phone: user.Phone, |
|
|
|
|
|
// Nickname: user.Nickname, |
|
|
|
|
|
// Uid: user.Id, |
|
|
|
|
|
// Pid: relations[0].RecommendUid, |
|
|
|
|
|
// Level: relations[0].Level1, |
|
|
|
|
|
// Position: relations[0].Position1, |
|
|
|
|
|
// SystemID: relations[0].Id, |
|
|
|
|
|
// Son: son, |
|
|
|
|
|
// } |
|
|
|
|
|
// for i := 1; i < len(relations); i++ { |
|
|
|
|
|
// user, err4 := userDb.UserGetOneById(relations[i].Uid) |
|
|
|
|
|
// if err4 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// node := public_platoon.RelationshipMap{ |
|
|
|
|
|
// AvatarUrl: user.Avatar, |
|
|
|
|
|
// Phone: user.Phone, |
|
|
|
|
|
// Nickname: user.Nickname, |
|
|
|
|
|
// Uid: user.Id, |
|
|
|
|
|
// Pid: relations[i].RecommendUid, |
|
|
|
|
|
// Level: relations[i].Level1, |
|
|
|
|
|
// Position: relations[i].Position1, |
|
|
|
|
|
// SystemID: relations[i].Id, |
|
|
|
|
|
// Son: nil, |
|
|
|
|
|
// } |
|
|
|
|
|
// res.Son = append(res.Son, node) |
|
|
|
|
|
// } |
|
|
|
|
|
// e.OutSuc(c, res, nil) |
|
|
|
|
|
//} |
|
|
|
|
|
// |
|
|
|
|
|
//// FindSubUserRelationshipMap |
|
|
|
|
|
//// @Summary 制度中心-公排管理-关系分布图(获取指定用户上级) |
|
|
|
|
|
//// @Tags 公排管理 |
|
|
|
|
|
//// @Description 关系分布图(获取指定用户上级) |
|
|
|
|
|
//// @Accept json |
|
|
|
|
|
//// @Produce json |
|
|
|
|
|
//// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
|
|
|
//// @Param req query public_platoon.FindSubUserRelationshipMapReq true "用户ID" |
|
|
|
|
|
//// @Success 200 {object} public_platoon.RelationshipMap "具体数据" |
|
|
|
|
|
//// @Failure 400 {object} md.Response "具体错误" |
|
|
|
|
|
//// @Router /api/publicPlatoon/findSubUserRelationshipMap [get] |
|
|
|
|
|
//func FindSubUserRelationshipMap(c *gin.Context) { |
|
|
|
|
|
// var req *public_platoon.FindSubUserRelationshipMapReq |
|
|
|
|
|
// if err := c.ShouldBindQuery(&req); err != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// RelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) |
|
|
|
|
|
// sonRelation, err1 := RelationDb.PublicPlatoonUserRelationGetOneByUid(req.Uid) |
|
|
|
|
|
// if err1 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err1) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// parentRelation, err2 := RelationDb.PublicPlatoonUserRelationGetOneByUid(sonRelation.FatherUid1) |
|
|
|
|
|
// if err2 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// userDb := implement.NewUserDb(db.Db) |
|
|
|
|
|
// son, err3 := userDb.UserGetOneById(sonRelation.Uid) |
|
|
|
|
|
// if err3 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// parent, err4 := userDb.UserGetOneById(parentRelation.Uid) |
|
|
|
|
|
// if err4 != nil { |
|
|
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
|
|
// return |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// var sonNode []public_platoon.RelationshipMap |
|
|
|
|
|
// sonNode1 := public_platoon.RelationshipMap{ |
|
|
|
|
|
// AvatarUrl: son.Avatar, |
|
|
|
|
|
// Phone: son.Phone, |
|
|
|
|
|
// Nickname: son.Nickname, |
|
|
|
|
|
// Uid: son.Id, |
|
|
|
|
|
// Pid: sonRelation.RecommendUid, |
|
|
|
|
|
// Level: sonRelation.Level1, |
|
|
|
|
|
// Position: sonRelation.Position1, |
|
|
|
|
|
// SystemID: sonRelation.Id, |
|
|
|
|
|
// Son: nil, |
|
|
|
|
|
// } |
|
|
|
|
|
// sonNode = append(sonNode, sonNode1) |
|
|
|
|
|
// res := public_platoon.RelationshipMap{ |
|
|
|
|
|
// AvatarUrl: parent.Avatar, |
|
|
|
|
|
// Phone: parent.Phone, |
|
|
|
|
|
// Nickname: parent.Nickname, |
|
|
|
|
|
// Uid: parent.Id, |
|
|
|
|
|
// Pid: parentRelation.RecommendUid, |
|
|
|
|
|
// Level: parentRelation.Level1, |
|
|
|
|
|
// Position: parentRelation.Position1, |
|
|
|
|
|
// SystemID: parentRelation.Id, |
|
|
|
|
|
// Son: sonNode, |
|
|
|
|
|
// } |
|
|
|
|
|
// e.OutSuc(c, res, nil) |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
func ExchangeUserPosition(c *gin.Context) { |
|
|
func ExchangeUserPosition(c *gin.Context) { |
|
|
var req *public_platoon.ExchangeUserPositionReq |
|
|
|
|
|
|
|
|
var req *md.ExchangeUserPositionReq |
|
|
if err1 := c.ShouldBindJSON(&req); err1 != nil { |
|
|
if err1 := c.ShouldBindJSON(&req); err1 != nil { |
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err1) |
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err1) |
|
|
return |
|
|
return |
|
|