package authorityApi import ( "github.com/gin-gonic/gin" "stat/api/proto" "stat/common/stdLog" "stat/common/utils" "stat/service/authoritySer" "stat/service/opLogSer" ) // @Tags 权限管理 // @Summary 权限角色列表 // @Description 权限角色列表 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.RoleListReq true "参数列表" // @Success 200 {object} proto.RoleListRes "成功" // @Failure 400 {string} string "失败" // @Security ApiKeyAuth // @Router /api/stat/authority/list [POST] func RoleList(ctx *gin.Context) { param := proto.RoleListReq{} if err := ctx.ShouldBind(¶m); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } code, data, err := authoritySer.RoleList(ctx, param) if err != nil { stdLog.ServerJSON(ctx, code, err) return } stdLog.ServerJSON(ctx, code, data) } // @Tags 权限管理 // @Summary 添加角色 // @Description 添加角色 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.AddRoleReq true "参数列表" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Security ApiKeyAuth // @Router /api/stat/authority/add [POST] func AddRole(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } param := proto.AddRoleReq{} if err := ctx.ShouldBind(¶m); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } code, data, err := authoritySer.AddRole(ctx, param) if err != nil { stdLog.ServerJSON(ctx, code, err) return } // 增加操作日志 opLogSer.AddOpLog(ctx, account, true, param) stdLog.ServerJSON(ctx, code, data) } // @Tags 权限管理 // @Summary 修改角色 // @Description 修改角色 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.UpdateRoleReq true "参数列表" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Security ApiKeyAuth // @Router /api/stat/authority/update [POST] func UpdateRole(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } param := proto.UpdateRoleReq{} if err := ctx.ShouldBind(¶m); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } code, data, err := authoritySer.UpdateRole(ctx, param) if err != nil { stdLog.ServerJSON(ctx, code, err) return } // 增加操作日志 opLogSer.AddOpLog(ctx, account, true, param) stdLog.ServerJSON(ctx, code, data) } // @Tags 权限管理 // @Summary 删除角色 // @Description 删除角色 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.DelRoleReq true "参数列表" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Security ApiKeyAuth // @Router /api/stat/authority/del [DELETE] func DelRole(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } param := proto.DelRoleReq{} if err := ctx.ShouldBind(¶m); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } code, data, err := authoritySer.DelRole(ctx, param) if err != nil { stdLog.ServerJSON(ctx, code, err) return } // 增加操作日志 opLogSer.AddOpLog(ctx, account, true, param) stdLog.ServerJSON(ctx, code, data) }