Commit 5bce9bff authored by chenweijian's avatar chenweijian

申请加入家族

parent cc0ffcd3
......@@ -43,8 +43,8 @@ func GetGroupPowerApplyJoin(model *domain.Model, userId, familyId uint64) (*Grou
return res, nil
}
func AcceptGroupPowerApplyJoinById(model *domain.Model, id uint64) error {
err := model.Db.Exec("update group_power_apply_join set is_accept = 1 where id=?", id).Error
func OptGroupPowerApplyJoinById(model *domain.Model, id uint64, optType int) error {
err := model.Db.Exec("update group_power_apply_join set is_accept = ? where id=?", optType, id).Error
if err != nil {
return myerr.WrapErr(err)
}
......
......@@ -895,8 +895,9 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
}
// @Tags 家族
// @Summary 批准加入家族
// @Param userExtId query string false "用户extId"
// @Summary 审核加入家族申请
// @Param userExtId formData string false "用户extId"
// @Param type formData int true "1.通过,2.不通过"
// @Success 200
// @Router /v1/groupPower/passApply [post]
func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
......@@ -905,6 +906,14 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
if err != nil {
return myContext, err
}
optType, err := strconv.Atoi(c.PostForm("type"))
if err != nil {
return myContext, bizerr.InvalidParameter
}
if optType < 1 || optType > 2 {
return myContext, bizerr.InvalidParameter
}
model := domain.CreateModelContext(myContext)
// 判断是否加入了家族
......@@ -929,6 +938,16 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, bizerr.GroupPowerHaveNoApply
}
if optType == 2 { // 拒绝
// 更改申请表状态
err = groupPower_m.OptGroupPowerApplyJoinById(model, apply.Id, optType)
if err != nil {
return myContext, err
}
resp.ResponseOk(c, nil)
return myContext, nil
}
err = model.Transaction(func(model *domain.Model) error {
txModel := domain.CreateModel(model.CtxAndDb)
// 插入家族成员表
......@@ -939,7 +958,7 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return err
}
// 更改申请表状态
err = groupPower_m.AcceptGroupPowerApplyJoinById(model, apply.Id)
err = groupPower_m.OptGroupPowerApplyJoinById(model, apply.Id, optType)
if err != nil {
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment