1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package api
- import (
- "fmt"
- "gin-vue-admin/controller/servers"
- "gin-vue-admin/model/modelInterface"
- "gin-vue-admin/model/sysModel"
- "github.com/gin-gonic/gin"
- )
- // @Tags authority
- // @Summary 创建角色
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body sysModel.SysAuthority true "创建角色"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /authority/createAuthority [post]
- func CreateAuthority(c *gin.Context) {
- var auth sysModel.SysAuthority
- _ = c.ShouldBindJSON(&auth)
- err, authBack := auth.CreateAuthority()
- if err != nil {
- servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{
- "authority": authBack,
- })
- } else {
- servers.ReportFormat(c, true, "创建成功", gin.H{
- "authority": authBack,
- })
- }
- }
- // @Tags authority
- // @Summary 删除角色
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body sysModel.SysAuthority true "删除角色"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /authority/deleteAuthority [post]
- func DeleteAuthority(c *gin.Context) {
- var a sysModel.SysAuthority
- _ = c.ShouldBindJSON(&a)
- //删除角色之前需要判断是否有用户正在使用此角色
- err := a.DeleteAuthority()
- if err != nil {
- servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{})
- } else {
- servers.ReportFormat(c, true, "删除成功", gin.H{})
- }
- }
- // @Tags authority
- // @Summary 分页获取角色列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body modelInterface.PageInfo true "分页获取用户列表"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /authority/getAuthorityList [post]
- func GetAuthorityList(c *gin.Context) {
- var pageInfo modelInterface.PageInfo
- _ = c.ShouldBindJSON(&pageInfo)
- err, list, total := new(sysModel.SysAuthority).GetInfoList(pageInfo)
- if err != nil {
- servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
- } else {
- servers.ReportFormat(c, true, "获取数据成功", gin.H{
- "list": list,
- "total": total,
- "page": pageInfo.Page,
- "pageSize": pageInfo.PageSize,
- })
- }
- }
- // @Tags authority
- // @Summary 设置角色资源权限
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body sysModel.SysAuthority true "设置角色资源权限"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
- // @Router /authority/setDataAuthority [post]
- func SetDataAuthority(c *gin.Context) {
- var auth sysModel.SysAuthority
- _ = c.ShouldBindJSON(&auth)
- err := auth.SetDataAuthority()
- if err != nil {
- servers.ReportFormat(c, false, fmt.Sprintf("设置关联失败,%v", err), gin.H{})
- } else {
- servers.ReportFormat(c, true, "设置关联成功", gin.H{})
- }
- }
|