package user import ( "app/commons/constant" "app/commons/core" "fmt" "github.com/gin-gonic/gin" ) func (s *Server) Info(ctx *gin.Context) { c := s.FromContext(ctx) c.Resp(map[string]interface{}{ "uid": c.Uid(), "userId": c.UserId(), "openId": c.OpenId(), }) } func (s *Server) SetParent(ctx *gin.Context) { c := s.FromContext(ctx) type UserReq struct { Code *string `json:"code"` } req := new(UserReq) if err := c.ShouldBindJSON(&req); err != nil { c.Resp(constant.ErrorParams) return } core.Log.Infof("req:%v", req.Code) user, err := s.GetUserByUserId(c.UserId()) if err != nil { c.Resp(constant.ErrorParams) return } dbTx := s.DB().Begin() err = s.CreateUserRelationActionLog(dbTx, user, fmt.Sprintf("SetParentByUser:%s", c.Uid()), "", req.Code) if err != nil { dbTx.Rollback() c.Resp(err.Error()) return } dbTx.Commit() c.Resp(nil) }