1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package v1
- import (
- "fmt"
- "gin-vue-admin/global/response"
- "gin-vue-admin/model"
- "github.com/gin-gonic/gin"
- )
- func CreateAuthority(c *gin.Context) {
- var auth model.SysAuthority
- _ = c.ShouldBindJSON(&auth)
- err, authBack := auth.CreateAuthority()
- if err != nil {
- response.Result(response.ERROR, gin.H{}, fmt.Sprintf("创建失败,%v", err), c)
- } else {
- response.Result(response.SUCCESS, gin.H{
- "authority": authBack,
- }, fmt.Sprintf("创建成功,%v", err), c)
- }
- }
- func DeleteAuthority(c *gin.Context) {
- var a model.SysAuthority
- _ = c.ShouldBindJSON(&a)
-
- err := a.DeleteAuthority()
- if err != nil {
- response.Result(response.ERROR, gin.H{}, fmt.Sprintf("删除失败,%v", err), c)
- } else {
- response.Result(response.SUCCESS, gin.H{}, "删除失败", c)
- }
- }
- func GetAuthorityList(c *gin.Context) {
- var pageInfo model.PageInfo
- _ = c.ShouldBindJSON(&pageInfo)
- err, list, total := new(model.SysAuthority).GetInfoList(pageInfo)
- if err != nil {
- response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取数据失败,%v", err), c)
- } else {
- response.Result(response.SUCCESS, gin.H{
- "list": list,
- "total": total,
- "page": pageInfo.Page,
- "pageSize": pageInfo.PageSize,
- }, "获取数据成功", c)
- }
- }
- func SetDataAuthority(c *gin.Context) {
- var auth model.SysAuthority
- _ = c.ShouldBindJSON(&auth)
- err := auth.SetDataAuthority()
- if err != nil {
- response.Result(response.ERROR, gin.H{}, fmt.Sprintf("设置关联失败,%v", err), c)
- } else {
- response.Result(response.SUCCESS, gin.H{}, "获取数据成功", c)
- }
- }
|