user

package
v0.0.0-...-495e01f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(ctx *context.APIContext)
@Tags		add
@Summary	用户添加-注册
@accept		application/json
@Produce	application/json

@Param data body dto_user.AddOption true "权角色id"

@Success	200	{object}	dto.Response	"用户添加-注册api"
@Router		/api/v1/user/add [post]

func Delete

func Delete(ctx *context.APIContext)

delete @Tags delete @Summary 用户删除 @Security ApiKeyAuth @accept application/json @Produce application/json @Param data body dto_user.DeleteOption true "权角色id" @Success 200 {object} dto.Response "用户删除api" @Router /api/v1/user/delete [get]

func LogOut

func LogOut(ctx *context.APIContext)

登录处理函数 Login

@Tags		LogOut
@Summary	用户登录
@accept		application/json
@Produce	application/json
@Success	200	{object}	dto.Response	"用户登出api"
@Router		/api/v1/user/LogOut [get]

func Login

func Login(ctx *context.APIContext)

func Login2(ctx *context.APIContext) { // 解析登录请求的JSON数据

form := web.GetForm(ctx).(*dto_user.LoginOption) // 查询数据库验证用户名和密码 get, err := db.GetEngine(db.DefaultContext).Get(&model_user.User{Name: form.Name, Passwd: form.Password}) fmt.Println("username: ", form.Name) fmt.Println(form.Password)

if err != nil {
	fmt.Println(err)
}
if !get {
	ctx.Error(500, "user not exist", nil)

} log.Info("----------get-------", get) //has, err := engine.Get(&user) // 假设生成的令牌是一个随机字符串 //token := util.GenerateToken(user.na, 0) util.ParseToken(token) _ = util.RedisClient.Set(ctx, "token", token, 3600) key := util.RedisClient.Get(ctx, "token") //store := session.NewRedisStore() //store.Set() fmt.Println("----------key--------------", key) ctx.JSON(http.StatusOK, token) 登录处理函数 Login

@Tags		Login
@Summary	用户登录
@accept		application/json
@Produce	application/json

@Param data body user.LoginOption true "权角色id"

@Success	200	{object}	dto.Response	"用户登录api"
@Router		/api/v1/user/login [post]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL