12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package handler
- import (
- "kpt-pasture/http/middleware"
- "net/http"
- "strconv"
- operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
- "gitee.com/xuyiping_admin/pkg/apierr"
- "gitee.com/xuyiping_admin/pkg/ginutil"
- "gitee.com/xuyiping_admin/pkg/valid"
- "github.com/gin-gonic/gin"
- )
- // GetUserInfo 获取用户信息
- func GetUserInfo(c *gin.Context) {
- token := middleware.GetToken(c)
- if err := valid.Validate(token, valid.Required); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- res, err := middleware.BackendOperation(c).OpsService.GetUserInfo(c, token)
- if err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, res)
- }
- // Details 系统用户详情
- func Details(c *gin.Context) {
- userIdStr := c.Param("user_id")
- userId, _ := strconv.Atoi(userIdStr)
- if err := valid.Validate(userId, valid.Required, valid.Min(1)); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- res, err := middleware.BackendOperation(c).OpsService.DetailsSystemUser(c, int64(userId))
- if err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, res)
- }
- // GetUserMenu 获取系统用户菜单权限
- func GetUserMenu(c *gin.Context) {
- token := middleware.GetToken(c)
- if err := valid.Validate(token, valid.Required); err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- res, err := middleware.BackendOperation(c).OpsService.GetSystemUserPermissions(c, token)
- if err != nil {
- apierr.ClassifiedAbort(c, err)
- return
- }
- ginutil.JSONResp(c, res)
- }
- // Logout 用户登出,
- func Logout(c *gin.Context) {
- ginutil.JSONResp(c, &operationPb.CommonOK{
- Code: http.StatusOK,
- Msg: "ok",
- Data: &operationPb.Success{Success: true},
- })
- }
|