12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package settings
- import (
- "nginx-ui/server/base"
- "nginx-ui/server/models"
- )
- type RouteController struct {
- base.Controller
- }
- // List 查看全部路由
- func (c *RouteController) List() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- listVo := RouteListVo{}
- if !c.ReadBody(&listVo) {
- return
- }
- if listVo.Uid == -1 {
- listVo.Uid = current.Id
- }
- list, err := Route.GetList(listVo)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(list).Json()
- }
- // Save 新增或者修改用户
- func (c *RouteController) Save() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- route := models.SettingRoute{}
- if !c.ReadBody(&route) {
- return
- }
- if route.Uid == -1 {
- route.Uid = current.Id
- }
- resp, err := Route.Save(&route)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(resp).Json()
- }
- func (c *RouteController) Delete() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- id := c.GetQuery("id")
- err := Route.Delete(id)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.Json()
- }
|