1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package settings
- import (
- "errors"
- "nginx-ui/server/base"
- "nginx-ui/server/models"
- )
- type SettingController struct {
- base.Controller
- }
- // List 新增或者修改用户
- func (c *SettingController) List() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- list, err := SettingSrv.GetList(ListVo{Enable: -1})
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(list).Json()
- }
- // Save 新增或者修改用户
- func (c *SettingController) Save() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- organize := models.Setting{}
- if !c.ReadBody(&organize) {
- return
- }
- if organize.ConfigKey == "" {
- c.ErrorJson(errors.New("请输入配置的Key"))
- return
- }
- resp, err := SettingSrv.Save(&organize)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.SetData(resp).Json()
- }
- func (c *SettingController) Delete() {
- current := c.RequiredUser()
- if current == nil {
- return
- }
- id, err := c.GetIntQuery("id")
- if err != nil {
- c.ErrorJson(err)
- return
- }
- err = SettingSrv.Delete(id)
- if err != nil {
- c.ErrorJson(err)
- return
- }
- c.Json()
- }
|