refactor🎨:注释未使用的对象
This commit is contained in:
1 parent
d32751ea5d
commit
3358eeb54c
6 files changed
+19
-14
No files matched your search
@@ -267,12 +267,12 @@ func (e SysRole) Update2DataScope(c *gin.Context) {
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
data := &models.SysRole{
|
||||
RoleId: req.RoleId,
|
||||
DataScope: req.DataScope,
|
||||
DeptIds: req.DeptIds,
|
||||
}
|
||||
data.UpdateBy = user.GetUserId(c)
|
||||
//data := &models.SysRole{
|
||||
// RoleId: req.RoleId,
|
||||
// DataScope: req.DataScope,
|
||||
// DeptIds: req.DeptIds,
|
||||
//}
|
||||
//data.UpdateBy = user.GetUserId(c)
|
||||
err = s.UpdateDataScope(&req).Error
|
||||
if err != nil {
|
||||
e.Error(http.StatusInternalServerError, err, "")
|
||||
|
||||
@@ -61,6 +61,7 @@ func (s *SysMenuControl) Generate(model *models.SysMenu) {
|
||||
model.Paths = s.Paths
|
||||
model.MenuType = s.MenuType
|
||||
model.Action = s.Action
|
||||
model.Apis = s.Apis
|
||||
model.SysApi = s.SysApi
|
||||
model.Permission = s.Permission
|
||||
model.ParentId = s.ParentId
|
||||
|
||||
@@ -87,6 +87,9 @@ func (e *SysMenu) Insert(c *dto.SysMenuControl) *SysMenu {
|
||||
var err error
|
||||
var data models.SysMenu
|
||||
c.Generate(&data)
|
||||
sysApi := make([]models.SysApi, 0)
|
||||
e.Orm.Where("id in ?", c.Apis).Find(&sysApi)
|
||||
data.SysApi = sysApi
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
|
||||
@@ -204,8 +204,10 @@ func (e *SysRole) UpdateDataScope(c *dto.RoleDataScopeReq) *SysRole {
|
||||
}()
|
||||
var dlist = make([]models.SysDept, 0)
|
||||
var model = models.SysRole{}
|
||||
tx.Preload("SysDept").First(&model, c.DeptIds)
|
||||
tx.Where("id in ?", c.DeptIds).Find(&dlist)
|
||||
tx.Preload("SysDept").First(&model, c.RoleId)
|
||||
if c.DataScope == "2" {
|
||||
tx.Where("dept_id in ?", c.DeptIds).Find(&dlist)
|
||||
}
|
||||
err = tx.Model(&model).Association("SysDept").Delete(model.SysDept)
|
||||
if err != nil {
|
||||
e.Log.Errorf("delete SysDept error:%s", err)
|
||||
@@ -290,4 +292,4 @@ func (e *SysRole) GetById(roleId int) ([]string, error) {
|
||||
permissions = append(permissions, l[i].Permission)
|
||||
}
|
||||
return permissions, nil
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = e.Orm.Table(data.TableName()).Where(c.Id).Updates(&data).Error
|
||||
err = e.Orm.Table(data.TableName()).Where("job_id = ?",c.Id).Updates(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error: %s", err)
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,16 +1,15 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetClientIP(c *gin.Context) string {
|
||||
ClientIP := c.ClientIP()
|
||||
fmt.Println("ClientIP:", ClientIP)
|
||||
//fmt.Println("ClientIP:", ClientIP)
|
||||
RemoteIP, _ := c.RemoteIP()
|
||||
fmt.Println("RemoteIP:", RemoteIP)
|
||||
//fmt.Println("RemoteIP:", RemoteIP)
|
||||
ip := c.Request.Header.Get("X-Forwarded-For")
|
||||
if strings.Contains(ip, "127.0.0.1") || ip == "" {
|
||||
ip = c.Request.Header.Get("X-real-ip")
|
||||
@@ -24,6 +23,6 @@ func GetClientIP(c *gin.Context) string {
|
||||
if ClientIP != "127.0.0.1" {
|
||||
ip = ClientIP
|
||||
}
|
||||
fmt.Println("ip:", ip)
|
||||
//fmt.Println("ip:", ip)
|
||||
return ip
|
||||
}
|
||||
Reference in new issue
Block a user