| 123456789101112131415161718192021222324252627282930313233343536373839 |
- package admin
- import (
- "strings"
- "think-go/controllers/services"
- )
- type UserController struct {
- BaseController
- }
- // @router /user/add [get,post]
- func (c *UserController) Add() {
- c.Ctx.WriteString("this is add user")
- }
- // @router /user/:id [get]
- func (c *UserController) GetUser() {
- mobile := c.Ctx.Input.Param(":id")
- password := c.GetString("password")
- if strings.TrimSpace(mobile) == "" {
- c.Error("mobile is required", 400)
- return
- }
- if strings.TrimSpace(password) == "" {
- c.Error("password is required", 400)
- return
- }
- svc := &services.SaasUserService{}
- result, err := svc.Login(mobile, password)
- if err != nil {
- c.Error(err.Error(), 400)
- return
- }
- c.Success(result, "login success")
- }
|