123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package handler
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- log "github.com/sirupsen/logrus"
- "youngee_m_api/consts"
- "youngee_m_api/db"
- "youngee_m_api/model/http_model"
- "youngee_m_api/service"
- "youngee_m_api/util"
- )
- func WrapEditSubAccountHandler(ctx *gin.Context) {
- handler := newUpdateSubAccountHandler(ctx)
- BaseRun(handler)
- }
- func newUpdateSubAccountHandler(ctx *gin.Context) *UpdateSubAccountInfoHandler {
- return &UpdateSubAccountInfoHandler{
- req: http_model.NewUpdateSubAccountInfoRequest(),
- resp: http_model.NewUpdateSubAccountInfoResponse(),
- ctx: ctx,
- }
- }
- type UpdateSubAccountInfoHandler struct {
- req *http_model.UpdateSubaccountInfoRequest
- resp *http_model.CommonResponse
- ctx *gin.Context
- }
- func (u UpdateSubAccountInfoHandler) getContext() *gin.Context { return u.ctx }
- func (u UpdateSubAccountInfoHandler) getResponse() interface{} {
- return u.resp
- }
- func (u UpdateSubAccountInfoHandler) getRequest() interface{} {
- return u.req
- }
- func (u UpdateSubAccountInfoHandler) run() {
- data := http_model.UpdateSubaccountInfoRequest{}
- data = *u.req
- message, err := service.Register.CodeJudge(u.ctx, data.PhoneNumber, data.Code)
- if err != nil {
- logrus.Errorf("[UpdateSubaccountInfoHandler] call UpdateSubaccountInfo err:%+v\n", err)
- util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
- logrus.Info("UpdateSubaccountInfoHandler fail,req:%+v", u.req)
- return
- }
- if message == "" {
- res, Error := db.UPdateSubaccountInfo(u.ctx, &data)
- if Error != nil {
- logrus.Errorf("[UpdateSubaccountInfoHandler] call UpdateSubaccountInfo err:%+v\n", err)
- util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
- log.Info("UpdateSubaccountInfo fail,req:%+v", u.req)
- return
- }
- u.resp.Message = "编辑成功"
- u.resp.Data = res
- } else {
- u.resp.Message = message
- }
- }
- func (u UpdateSubAccountInfoHandler) checkParam() error {
- return nil
- }
|