1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package handler
- import (
- "fmt"
- "github.com/gin-gonic/gin"
- "youngee_b_api/model/http_model"
- "youngee_b_api/service"
- )
- func WrapAddNewSubAccountHandler(ctx *gin.Context) {
- handler := newAddNewSubAccountHandler(ctx)
- baseRun(handler)
- }
- func newAddNewSubAccountHandler(ctx *gin.Context) *AddNewSubAccountHandler {
- return &AddNewSubAccountHandler{
- req: http_model.NewAddSubAccountRequest(),
- resp: http_model.NewAddSubAccountResponse(),
- ctx: ctx,
- }
- }
- type AddNewSubAccountHandler struct {
- req *http_model.AddNewSubAccountRequest
- resp *http_model.CommonResponse
- ctx *gin.Context
- }
- func (h *AddNewSubAccountHandler) getRequest() interface{} {
- return h.req
- }
- func (h *AddNewSubAccountHandler) getContext() *gin.Context {
- return h.ctx
- }
- func (h *AddNewSubAccountHandler) getResponse() interface{} {
- return h.resp
- }
- func (h *AddNewSubAccountHandler) run() {
- // fmt.Println("AddNewSubAccountHandler Running")
- newSubAccount := http_model.AddNewSubAccountRequest{}
- newSubAccount = *h.req
- // 1. 验证码校验
- tag, err := service.LoginAuth.SubAccountAuthCode(h.ctx, newSubAccount.PhoneNumber, newSubAccount.Code)
- if err != nil {
- fmt.Println(err)
- }
- // 2. 校验通过则创建样叽用户和子账号
- if tag == "1" {
- err := service.SubAccount.CreateSubAccount(h.ctx, newSubAccount)
- if err != nil {
- fmt.Println(err)
- h.resp.Message = "创建失败"
- } else {
- h.resp.Message = "成功创建子账号"
- }
- } else {
- // 验证码校验不通过的返回值
- h.resp.Message = tag
- }
- return
- }
- func (h *AddNewSubAccountHandler) checkParam() error {
- return nil
- }
|