1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package myself
- import (
- "Cold_Logistic/internal/pkg/common/codex"
- "Cold_Logistic/internal/pkg/common/global"
- "Cold_Logistic/internal/server/application/myselfsrv"
- "Cold_Logistic/internal/server/infra/dao"
- "github.com/gin-gonic/gin"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
- )
- // myselfInfo
- // @Tags 用户-我的
- // @BasePath /clodLogistic/app/api/v1
- // @Summary 个人信息
- // @Success 200 {object} swagger.AccountInfoVo "成功响应的结构体"
- // @Accept application/json
- // @Authorization
- // @Router /app/myself/info [get]
- func (api Api) myselfInfo(c *gin.Context) {
- srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.MyselfInfo(c)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // updateMyselfInfo
- // @Tags 用户-我的
- // @BasePath /clodLogistic/app/api/v1
- // @Summary 修改个人信息
- // @Success 200 {object} swagger.AccountInfoVo "成功响应的结构体"
- // @Param req body myselfsrv.UpdateMyselfInfoReqVO true "请求参数"
- // @Accept application/json
- // @Authorization
- // @Router /app/myself/update [post]
- func (api Api) updateMyselfInfo(c *gin.Context) {
- req := myselfsrv.UpdateMyselfInfoReqVO{}
- if err := c.BindJSON(&req); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
- return
- }
- if err := req.Validate(); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
- return
- }
- srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.UpdateMyselfInfo(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // refreshToken
- // @Tags 用户-我的
- // @BasePath /clodLogistic/app/api/v1
- // @Summary 刷新token
- // @Success 200 {object} myselfsrv.RefreshTokenRespVo "成功响应的结构体"
- // @Accept application/json
- // @Authorization
- // @Router /app/myself/refreshToken [post]
- func (api Api) refreshToken(c *gin.Context) {
- srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.RefreshToken(c)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
|