web

package
v0.0.0-...-6ea431b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes() *gin.Engine

Types

type ArticleHandler

type ArticleHandler struct {
	// contains filtered or unexported fields
}

func (*ArticleHandler) Detail

func (a *ArticleHandler) Detail(ctx *gin.Context, usr ijwt.UserClaims) (ginx.Result, error)

func (*ArticleHandler) Edit

func (h *ArticleHandler) Edit(ctx *gin.Context)

func (*ArticleHandler) Like

func (a *ArticleHandler) Like(ctx *gin.Context, req LikeReq, uc ijwt.UserClaims) (ginx.Result, error)

func (*ArticleHandler) List

func (h *ArticleHandler) List(ctx *gin.Context, req ListReq, uc ijwt.UserClaims) (ginx.Result, error)

func (*ArticleHandler) PubDetail

func (a *ArticleHandler) PubDetail(ctx *gin.Context)

func (*ArticleHandler) Publish

func (h *ArticleHandler) Publish(ctx *gin.Context)

func (*ArticleHandler) RegisterRoutes

func (h *ArticleHandler) RegisterRoutes(server *gin.Engine)

func (*ArticleHandler) Withdraw

func (h *ArticleHandler) Withdraw(ctx *gin.Context)

type ArticleReq

type ArticleReq struct {
	Id      int64  `json:"id"`
	Title   string `json:"title"`
	Content string `json:"content"`
}

type ArticleVO

type ArticleVO struct {
	Id    int64  `json:"id"`
	Title string `json:"title"`
	// 摘要
	Abstract string `json:"abstract"`
	// 内容
	Content string `json:"content"`
	// 注意一点,状态这个东西,可以是前端来处理,也可以是后端处理
	// 0 -> unknown -> 未知状态
	// 1 -> 未发表,手机 APP 这种涉及到发版的问题,那么后端来处理
	// 涉及到国际化,也是后端来处理
	Status uint8  `json:"status"`
	Author string `json:"author"`
	// 计数
	ReadCnt    int64 `json:"read_cnt"`
	LikeCnt    int64 `json:"like_cnt"`
	CollectCnt int64 `json:"collect_cnt"`

	// 我个人有没有收藏,有没有点赞
	Liked     bool `json:"liked"`
	Collected bool `json:"collected"`

	Ctime string `json:"ctime"`
	Utime string `json:"utime"`
}

type LikeReq

type LikeReq struct {
	Id int64 `json:"id"`
	// 点赞和取消点赞,我都准备复用这个
	Like bool `json:"like"`
}

VO view object,就是对标前端的

type ListReq

type ListReq struct {
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
}

type OAuth2WechatHandler

type OAuth2WechatHandler struct {
	ijwt.Handler
	// contains filtered or unexported fields
}

func NewOAuth2WechatHandler

func NewOAuth2WechatHandler(svc wechat.Service,
	userSvc service.UserService,
	jwtHdl ijwt.Handler) *OAuth2WechatHandler

func (*OAuth2WechatHandler) AuthURL

func (h *OAuth2WechatHandler) AuthURL(ctx *gin.Context)

func (*OAuth2WechatHandler) Callback

func (h *OAuth2WechatHandler) Callback(ctx *gin.Context)

func (*OAuth2WechatHandler) RegisterRoutes

func (h *OAuth2WechatHandler) RegisterRoutes(server *gin.Engine)

type Result

type Result struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

type StateClaims

type StateClaims struct {
	State string
	jwt.RegisteredClaims
}

type UserHandler

type UserHandler struct {

	// 只有在使用 JWT 的时候才有用
	ijwt.Handler
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(svc service.UserService,
	codeSvc service.CodeService, jwtHdl ijwt.Handler) *UserHandler

func (*UserHandler) Edit

func (c *UserHandler) Edit(ctx *gin.Context)

Edit 用户编译信息

func (*UserHandler) Login

func (c *UserHandler) Login(ctx *gin.Context)

Login 用户登录接口

func (*UserHandler) LoginJWT

func (c *UserHandler) LoginJWT(ctx *gin.Context)

LoginJWT 用户登录接口,使用的是 JWT,如果你想要测试 JWT,就启用这个

func (*UserHandler) LoginSMS

func (c *UserHandler) LoginSMS(ctx *gin.Context)

func (*UserHandler) LogoutJWT

func (u *UserHandler) LogoutJWT(ctx *gin.Context)

func (*UserHandler) Profile

func (c *UserHandler) Profile(ctx *gin.Context)

Profile 用户详情

func (*UserHandler) ProfileJWT

func (c *UserHandler) ProfileJWT(ctx *gin.Context)

ProfileJWT 用户详情, JWT 版本

func (*UserHandler) RefreshToken

func (u *UserHandler) RefreshToken(ctx *gin.Context)

RefreshToken 可以同时刷新长短 token,用 redis 来记录是否有效,即 refresh_token 是一次性的 参考登录校验部分,比较 User-Agent 来增强安全性

func (*UserHandler) RegisterRoutes

func (c *UserHandler) RegisterRoutes(server *gin.Engine)

func (*UserHandler) SendSMSLoginCode

func (c *UserHandler) SendSMSLoginCode(ctx *gin.Context)

SendSMSLoginCode 发送短信验证码

func (*UserHandler) SignUp

func (c *UserHandler) SignUp(ctx *gin.Context)

SignUp 用户注册接口

Directories

Path Synopsis
jwt
mocks
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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