123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package user
- import (
- "nginx-ui/server/base"
- "nginx-ui/server/models"
- )
- type RoleController struct {
- base.Controller
- }
- // List 查看全部路由
- func (c *RoleController) List() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- list, err := Role.List()
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(list).Json()
- }
- // Save 新增或者修改用户
- func (c *RoleController) Save() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- route := models.UserRole{}
- if !c.ReadBody(&route) {
- return
- }
- resp, err := Role.Save(&route)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(resp).Json()
- }
- func (c *RoleController) Delete() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- id, err := c.GetIntQuery("id")
- if err != nil {
- c.ErrorJson(err)
- return
- }
- err = Role.Delete(id)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.Json()
- }
|