| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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)
- }
|