Revert "refactor🎨:注释未使用的对象"

This reverts commit 3358eeb54c.
This commit is contained in:
zhangwenjian committed 2021-06-17 11:28:51 +08:00
1 parent 3358eeb54c
commit a0b7d9969a
6 files changed
+14 -19

No files matched your search

+6 -6
View File
@@ -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, "")
-1
View File
@@ -61,7 +61,6 @@ 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
-3
View File
@@ -87,9 +87,6 @@ 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)
+3 -5
View File
@@ -204,10 +204,8 @@ func (e *SysRole) UpdateDataScope(c *dto.RoleDataScopeReq) *SysRole {
}()
var dlist = make([]models.SysDept, 0)
var model = models.SysRole{}
tx.Preload("SysDept").First(&model, c.RoleId)
if c.DataScope == "2" {
tx.Where("dept_id in ?", c.DeptIds).Find(&dlist)
}
tx.Preload("SysDept").First(&model, c.DeptIds)
tx.Where("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)
@@ -292,4 +290,4 @@ func (e *SysRole) GetById(roleId int) ([]string, error) {
permissions = append(permissions, l[i].Permission)
}
return permissions, nil
}
}
+1 -1
View File
@@ -78,7 +78,7 @@ func (e *SysJob) StartJob(c *dto.GeneralGetDto) error {
return err
}
err = e.Orm.Table(data.TableName()).Where("job_id = ?",c.Id).Updates(&data).Error
err = e.Orm.Table(data.TableName()).Where(c.Id).Updates(&data).Error
if err != nil {
e.Log.Errorf("db error: %s", err)
}
+4 -3
View File
@@ -1,15 +1,16 @@
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")
@@ -23,6 +24,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
}