From cda47a639101026058888bf10de97274bc36c83e Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 8 Nov 2024 19:25:47 +0800 Subject: [PATCH] update --- .../public_platoon/hdl_basic.go | 46 +++++++++++++++++-- .../public_platoon/md_public_platoon.go | 5 ++ app/router/router.go | 1 + 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/app/hdl/institutional_management/public_platoon/hdl_basic.go b/app/hdl/institutional_management/public_platoon/hdl_basic.go index e5308fc..9310db6 100644 --- a/app/hdl/institutional_management/public_platoon/hdl_basic.go +++ b/app/hdl/institutional_management/public_platoon/hdl_basic.go @@ -6,6 +6,7 @@ import ( "applet/app/md/institutional_management/public_platoon" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "errors" "github.com/gin-gonic/gin" "time" ) @@ -126,7 +127,7 @@ func UpdatePublicPlatoonBasic(c *gin.Context) { // @Router /api/publicPlatoon/relationshipMap [get] func GetRelationshipMap(c *gin.Context) { var req *public_platoon.GetRelationshipMapReq - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBindQuery(&req); err != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } @@ -254,7 +255,7 @@ func GetRelationshipMap(c *gin.Context) { // @Router /api/publicPlatoon/findUserRelationshipMap [get] func FindUserRelationshipMap(c *gin.Context) { var req *public_platoon.FindUserRelationshipMapReq - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBindQuery(&req); err != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } @@ -319,7 +320,7 @@ func FindUserRelationshipMap(c *gin.Context) { // @Router /api/publicPlatoon/findSubUserRelationshipMap [get] func FindSubUserRelationshipMap(c *gin.Context) { var req *public_platoon.FindSubUserRelationshipMapReq - if err := c.ShouldBindJSON(&req); err != nil { + if err := c.ShouldBindQuery(&req); err != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } @@ -375,3 +376,42 @@ func FindSubUserRelationshipMap(c *gin.Context) { } e.OutSuc(c, res, nil) } + +func ExchangeUserPosition(c *gin.Context) { + var req *public_platoon.ExchangeUserPositionReq + if err1 := c.ShouldBindJSON(&req); err1 != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err1) + return + } + + relationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) + relation1, err2 := relationDb.PublicPlatoonUserRelationGetOneByPosition(req.Position1) + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2) + return + } + if relation1 == nil { + e.OutErr(c, e.ERR_BAD_REQUEST, errors.New("position_1 位置有误")) + return + } + + relation2, err3 := relationDb.PublicPlatoonUserRelationGetOneByPosition(req.Position1) + if err3 != nil { + e.OutErr(c, e.ERR_DB_ORM, err3) + return + } + if relation2 == nil { + e.OutErr(c, e.ERR_BAD_REQUEST, errors.New("position_2 位置有误")) + return + } + + if relation1.Uid == 1 || relation2.Uid == 1 { + e.OutErr(c, e.ERR_BAD_REQUEST, errors.New("创始人位置不能被修改")) + } + + //uid1 := relation1.Uid + //uid2 := relation2.Uid + //recommendUid1 := relation1.RecommendUid + //recommendUid2 := relation2.RecommendUid + //relation1.Uid = "" +} diff --git a/app/md/institutional_management/public_platoon/md_public_platoon.go b/app/md/institutional_management/public_platoon/md_public_platoon.go index 700c4b7..d934f51 100644 --- a/app/md/institutional_management/public_platoon/md_public_platoon.go +++ b/app/md/institutional_management/public_platoon/md_public_platoon.go @@ -50,3 +50,8 @@ type FindUserRelationshipMapReq struct { type FindSubUserRelationshipMapReq struct { Uid int64 `json:"uid"` } + +type ExchangeUserPositionReq struct { + Position1 int64 `json:"position_1"` + Position2 int64 `json:"position_2"` +} diff --git a/app/router/router.go b/app/router/router.go index d1cbb08..00f6c1a 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -64,6 +64,7 @@ func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理 rPublicPlatoon.GET("/relationshipMap", public_platoon.GetRelationshipMap) rPublicPlatoon.GET("/findUserRelationshipMap", public_platoon.FindUserRelationshipMap) rPublicPlatoon.GET("/findSubUserRelationshipMap", public_platoon.FindSubUserRelationshipMap) + rPublicPlatoon.POST("/exchangeUserPosition", public_platoon.ExchangeUserPosition) } }