refactor🎨 : uint 调整为 int

This commit is contained in:
zhangwenjian
2020-12-21 22:04:20 +08:00
parent ab7c34f817
commit 46ea5f18aa
17 changed files with 125 additions and 172 deletions
+30 -49
View File
@@ -3,7 +3,6 @@ package sys_file
import (
"github.com/gin-gonic/gin"
"go-admin/app/admin/service"
common "go-admin/common/models"
"net/http"
"go-admin/app/admin/models"
@@ -20,27 +19,23 @@ type SysFileDir struct {
func (e *SysFileDir) GetSysFileDirList(c *gin.Context) {
msgID := tools.GenerateMsgIDFromContext(c)
d := new(dto.SysFileDirSearch)
search := new(dto.SysFileDirSearch)
db, err := tools.GetOrm(c)
if err != nil {
log.Error(err)
return
}
req := d.Generate()
//查询列表
err = req.Bind(c)
err = c.ShouldBind(search)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
}
var list *[]models.SysFileDirL
serviceStudent := service.SysFileDir{}
serviceStudent.MsgID = msgID
serviceStudent.Orm = db
list, err = serviceStudent.SetSysFileDir(req)
list, err = serviceStudent.SetSysFileDir(search)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
return
@@ -59,18 +54,17 @@ func (e *SysFileDir) GetSysFileDir(c *gin.Context) {
msgID := tools.GenerateMsgIDFromContext(c)
//查看详情
req := control.Generate()
err = req.Bind(c)
err = c.ShouldBindUri(control)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
}
var object models.SysFileDir
serviceSysFileDir := service.SysFileDir{}
serviceSysFileDir.MsgID = msgID
serviceSysFileDir.Orm = db
err = serviceSysFileDir.GetSysFileDir(req, &object)
err = serviceSysFileDir.GetSysFileDir(control, &object)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
return
@@ -89,32 +83,28 @@ func (e *SysFileDir) InsertSysFileDir(c *gin.Context) {
msgID := tools.GenerateMsgIDFromContext(c)
//新增操作
req := control.Generate()
err = req.Bind(c)
err = c.ShouldBindUri(control)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
}
var object common.ActiveRecord
object, err = req.GenerateM()
err = c.ShouldBind(control)
if err != nil {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
// 设置创建人
object.SetCreateBy(tools.GetUserIdUint(c))
control.CreateBy = tools.GetUserId(c)
serviceSysFileDir := service.SysFileDir{}
serviceSysFileDir.Orm = db
serviceSysFileDir.MsgID = msgID
err = serviceSysFileDir.InsertSysFileDir(object)
err = serviceSysFileDir.InsertSysFileDir(control)
if err != nil {
log.Error(err)
e.Error(c, http.StatusInternalServerError, err, "创建失败")
return
}
e.OK(c, object.GetId(), "创建成功")
e.OK(c, control.ID, "创建成功")
}
func (e *SysFileDir) UpdateSysFileDir(c *gin.Context) {
@@ -126,20 +116,16 @@ func (e *SysFileDir) UpdateSysFileDir(c *gin.Context) {
}
msgID := tools.GenerateMsgIDFromContext(c)
req := control.Generate()
//更新操作
err = req.Bind(c)
err = c.ShouldBindUri(control)
if err != nil {
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
}
var object common.ActiveRecord
object, err = req.GenerateM()
err = c.ShouldBind(control)
if err != nil {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
object.SetUpdateBy(tools.GetUserIdUint(c))
// 设置创建人
control.UpdateBy = tools.GetUserId(c)
//数据权限检查
p := actions.GetPermissionFromContext(c)
@@ -147,12 +133,12 @@ func (e *SysFileDir) UpdateSysFileDir(c *gin.Context) {
serviceSysFileDir := service.SysFileDir{}
serviceSysFileDir.Orm = db
serviceSysFileDir.MsgID = msgID
err = serviceSysFileDir.UpdateSysFileDir(object, p)
err = serviceSysFileDir.UpdateSysFileDir(control, p)
if err != nil {
log.Error(err)
return
}
e.OK(c, object.GetId(), "更新成功")
e.OK(c, control.ID, "更新成功")
}
func (e *SysFileDir) DeleteSysFileDir(c *gin.Context) {
@@ -165,22 +151,17 @@ func (e *SysFileDir) DeleteSysFileDir(c *gin.Context) {
msgID := tools.GenerateMsgIDFromContext(c)
//删除操作
req := control.Generate()
err = req.Bind(c)
err = c.ShouldBindUri(control)
if err != nil {
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
}
var object common.ActiveRecord
object, err = req.GenerateM()
err = c.ShouldBind(control)
if err != nil {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
// 设置编辑人
object.SetUpdateBy(tools.GetUserIdUint(c))
control.UpdateBy = tools.GetUserId(c)
// 数据权限检查
p := actions.GetPermissionFromContext(c)
@@ -188,10 +169,10 @@ func (e *SysFileDir) DeleteSysFileDir(c *gin.Context) {
serviceSysFileDir := service.SysFileDir{}
serviceSysFileDir.Orm = db
serviceSysFileDir.MsgID = msgID
err = serviceSysFileDir.RemoveSysFileDir(req, object, p)
err = serviceSysFileDir.RemoveSysFileDir(control, p)
if err != nil {
log.Error(err)
return
}
e.OK(c, object.GetId(), "删除成功")
e.OK(c, control.Id, "删除成功")
}
@@ -103,7 +103,7 @@ func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) {
return
}
// 设置创建人
object.SetCreateBy(tools.GetUserIdUint(c))
object.SetCreateBy(tools.GetUserId(c))
serviceSysLoginLog := service.SysLoginLog{}
serviceSysLoginLog.Orm = db
@@ -140,7 +140,7 @@ func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
}
object.SetUpdateBy(tools.GetUserIdUint(c))
object.SetUpdateBy(tools.GetUserId(c))
serviceSysLoginLog := service.SysLoginLog{}
serviceSysLoginLog.Orm = db
@@ -178,7 +178,7 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
}
// 设置编辑人
object.SetUpdateBy(tools.GetUserIdUint(c))
object.SetUpdateBy(tools.GetUserId(c))
serviceSysLoginLog := service.SysLoginLog{}
serviceSysLoginLog.Orm = db
@@ -103,7 +103,7 @@ func (e *SysOperaLog) InsertSysOperaLog(c *gin.Context) {
return
}
// 设置创建人
object.SetCreateBy(tools.GetUserIdUint(c))
object.SetCreateBy(tools.GetUserId(c))
serviceSysOperaLog := service.SysOperaLog{}
serviceSysOperaLog.Orm = db
@@ -140,7 +140,7 @@ func (e *SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
return
}
object.SetUpdateBy(tools.GetUserIdUint(c))
object.SetUpdateBy(tools.GetUserId(c))
serviceSysOperaLog := service.SysOperaLog{}
serviceSysOperaLog.Orm = db
@@ -178,7 +178,7 @@ func (e *SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
}
// 设置编辑人
object.SetUpdateBy(tools.GetUserIdUint(c))
object.SetUpdateBy(tools.GetUserId(c))
serviceSysOperaLog := service.SysOperaLog{}
serviceSysOperaLog.Orm = db
+11 -13
View File
@@ -1,30 +1,28 @@
package models
import (
"gorm.io/gorm"
"go-admin/common/models"
)
type SysFileDir struct {
gorm.Model
models.ControlBy
models.Model
Label string `json:"label" gorm:"type:varchar(255);comment:目录名称"` // 目录名称
PId uint `json:"pId" gorm:"type:int(11);comment:上级目录"` // 上级目录
PId int `json:"pId" gorm:"type:int(11);comment:上级目录"` // 上级目录
Sort string `json:"sort" gorm:"type:bigint(20);comment:排序"` // 排序
Path string `json:"path" gorm:"type:varchar(255);comment:路径"` // 路径
models.ControlBy
models.ModelTime
}
type SysFileDirL struct {
gorm.Model
models.Model
Label string `json:"label" gorm:"type:varchar(255);comment:目录名称"` // 目录名称
PId int `json:"pId" gorm:"type:int(11);comment:上级目录"` // 上级目录
Sort string `json:"sort" gorm:"type:bigint(20);comment:排序"` // 排序
Path string `json:"path" gorm:"type:varchar(255);comment:路径"` // 路径
models.ControlBy
Label string `json:"label" gorm:"type:varchar(255);comment:目录名称"` // 目录名称
PId uint `json:"pId" gorm:"type:int(11);comment:上级目录"` // 上级目录
Sort string `json:"sort" gorm:"type:bigint(20);comment:排序"` // 排序
Path string `json:"path" gorm:"type:varchar(255);comment:路径"` // 路径
Children []SysFileDirL `json:"children" gorm:"-"` // 下级信息
models.ModelTime
Children []SysFileDirL `json:"children" gorm:"-"` // 下级信息
}
func (SysFileDir) TableName() string { /**/
+9 -11
View File
@@ -1,24 +1,22 @@
package models
import (
"gorm.io/gorm"
"go-admin/common/models"
)
type SysCategory struct {
gorm.Model
models.ControlBy
Name string `json:"name" gorm:"type:varchar(255);comment:名称"` //
Img string `json:"img" gorm:"type:varchar(255);comment:图标"` //
Sort string `json:"sort" gorm:"type:int(4);comment:排序"` //
Status string `json:"status" gorm:"type:int(1);comment:状态"` //
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
models.Model
Name string `json:"name" gorm:"type:varchar(255);comment:名称"` //
Img string `json:"img" gorm:"type:varchar(255);comment:图标"` //
Sort string `json:"sort" gorm:"type:int(4);comment:排序"` //
Status string `json:"status" gorm:"type:int(1);comment:状态"` //
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
models.ControlBy
models.ModelTime
}
func (SysCategory) TableName() string {
return "sys_category"
return "sys_category"
}
func (e *SysCategory) Generate() models.ActiveRecord {
+3 -3
View File
@@ -9,7 +9,7 @@ import (
)
type SysJob struct {
JobId uint `json:"jobId" gorm:"primary_key;AUTO_INCREMENT"` // 编码
JobId int `json:"jobId" gorm:"primary_key;AUTO_INCREMENT"` // 编码
JobName string `json:"jobName" gorm:"size:255;"` // 名称
JobGroup string `json:"jobGroup" gorm:"size:255;"` // 任务分组
JobType int `json:"jobType" gorm:"size:1;"` // 任务类型
@@ -40,11 +40,11 @@ func (e *SysJob) GetId() interface{} {
return e.JobId
}
func (e *SysJob) SetCreateBy(createBy uint) {
func (e *SysJob) SetCreateBy(createBy int) {
e.CreateBy = strconv.Itoa(int(createBy))
}
func (e *SysJob) SetUpdateBy(updateBy uint) {
func (e *SysJob) SetUpdateBy(updateBy int) {
e.UpdateBy = strconv.Itoa(int(updateBy))
}
+3 -4
View File
@@ -1,19 +1,18 @@
package system
import (
"gorm.io/gorm"
"go-admin/common/models"
)
type SysConfig struct {
gorm.Model
models.ControlBy
models.Model
ConfigName string `json:"configName" gorm:"type:varchar(128);comment:ConfigName"` //
ConfigKey string `json:"configKey" gorm:"type:varchar(128);comment:ConfigKey"` //
ConfigValue string `json:"configValue" gorm:"type:varchar(255);comment:ConfigValue"` //
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"` //
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"` //
models.ControlBy
models.ModelTime
}
func (SysConfig) TableName() string {
+3 -5
View File
@@ -1,17 +1,13 @@
package system
import (
"gorm.io/gorm"
"go-admin/common/models"
"time"
)
type SysLoginLog struct {
gorm.Model
models.ControlBy
models.Model
Username string `json:"username" gorm:"type:varchar(128);comment:用户名"` //
Status string `json:"status" gorm:"type:varchar(4);comment:状态"` //
Ipaddr string `json:"ipaddr" gorm:"type:varchar(255);comment:ip地址"` //
@@ -22,6 +18,8 @@ type SysLoginLog struct {
LoginTime time.Time `json:"loginTime" gorm:"type:timestamp;comment:登录时间"` //
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
Msg string `json:"msg" gorm:"type:varchar(255);comment:信息"` //
models.ControlBy
models.ModelTime
}
func (SysLoginLog) TableName() string {
+3 -5
View File
@@ -1,17 +1,13 @@
package system
import (
"gorm.io/gorm"
"go-admin/common/models"
"time"
)
type SysOperaLog struct {
gorm.Model
models.ControlBy
models.Model
Title string `json:"title" gorm:"type:varchar(255);comment:操作模块"` //
BusinessType string `json:"businessType" gorm:"type:varchar(128);comment:操作类型"` //
BusinessTypes string `json:"businessTypes" gorm:"type:varchar(128);comment:BusinessTypes"` //
@@ -30,6 +26,8 @@ type SysOperaLog struct {
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
LatencyTime string `json:"latencyTime" gorm:"type:varchar(128);comment:耗时"` //
UserAgent string `json:"userAgent" gorm:"type:varchar(255);comment:ua"` //
models.ControlBy
models.ModelTime
}
func (SysOperaLog) TableName() string {
+32 -43
View File
@@ -2,8 +2,6 @@ package dto
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"go-admin/app/admin/models"
"go-admin/common/dto"
"go-admin/common/log"
@@ -12,12 +10,10 @@ import (
)
type SysCategorySearch struct {
dto.Pagination `search:"-"`
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
dto.Pagination `search:"-"`
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
}
func (m *SysCategorySearch) GetNeedSearch() interface{} {
@@ -25,12 +21,12 @@ func (m *SysCategorySearch) GetNeedSearch() interface{} {
}
func (m *SysCategorySearch) Bind(ctx *gin.Context) error {
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
}
return err
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
}
return err
}
func (m *SysCategorySearch) Generate() dto.Index {
@@ -39,37 +35,31 @@ func (m *SysCategorySearch) Generate() dto.Index {
}
type SysCategoryControl struct {
ID uint `uri:"ID" comment:"标识"` // 标识
ID int `uri:"ID" comment:"标识"` // 标识
Name string `json:"name" comment:"名称"`
Name string `json:"name" comment:"名称"`
Img string `json:"img" comment:"图标"`
Img string `json:"img" comment:"图标"`
Sort string `json:"sort" comment:"排序"`
Sort string `json:"sort" comment:"排序"`
Status string `json:"status" comment:"状态"`
Status string `json:"status" comment:"状态"`
Remark string `json:"remark" comment:"备注"`
Remark string `json:"remark" comment:"备注"`
}
func (s *SysCategoryControl) Bind(ctx *gin.Context) error {
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
return err
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
return err
}
func (s *SysCategoryControl) Generate() dto.Control {
@@ -79,13 +69,12 @@ func (s *SysCategoryControl) Generate() dto.Control {
func (s *SysCategoryControl) GenerateM() (common.ActiveRecord, error) {
return &models.SysCategory{
Model: gorm.Model{ID: s.ID},
Name: s.Name,
Img: s.Img,
Sort: s.Sort,
Status: s.Status,
Remark: s.Remark,
Model: common.Model{ID: s.ID},
Name: s.Name,
Img: s.Img,
Sort: s.Sort,
Status: s.Status,
Remark: s.Remark,
}, nil
}
+2 -4
View File
@@ -3,8 +3,6 @@ package dto
import (
"github.com/gin-gonic/gin"
"go-admin/app/admin/models/system"
"gorm.io/gorm"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
@@ -37,7 +35,7 @@ func (m *SysConfigSearch) Generate() dto.Index {
}
type SysConfigControl struct {
ID uint `uri:"ID" comment:"编码"` // 编码
ID int `uri:"ID" comment:"编码"` // 编码
ConfigName string `json:"configName" comment:""`
ConfigKey string `json:"configKey" comment:""`
ConfigValue string `json:"configValue" comment:""`
@@ -66,7 +64,7 @@ func (s *SysConfigControl) Generate() dto.Control {
func (s *SysConfigControl) GenerateM() (common.ActiveRecord, error) {
return &system.SysConfig{
Model: gorm.Model{ID: s.ID},
Model: common.Model{ID: s.ID},
ConfigName: s.ConfigName,
ConfigKey: s.ConfigKey,
ConfigValue: s.ConfigValue,
+7 -6
View File
@@ -2,8 +2,6 @@ package dto
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"go-admin/app/admin/models"
"go-admin/common/dto"
"go-admin/common/log"
@@ -14,7 +12,7 @@ import (
type SysFileDirSearch struct {
dto.Pagination `search:"-"`
ID uint `form:"ID" search:"type:exact;column:id;table:sys_file_dir" comment:"标识"`
ID int `form:"ID" search:"type:exact;column:id;table:sys_file_dir" comment:"标识"`
Label string `form:"label" search:"type:exact;column:label;table:sys_file_dir" comment:"目录名称"`
PId string `form:"pId" search:"type:exact;column:p_id;table:sys_file_dir" comment:"上级目录"`
Sort string `form:"sort" search:"type:exact;column:sort;table:sys_file_dir" comment:"排序"`
@@ -40,11 +38,13 @@ func (m *SysFileDirSearch) Generate() dto.Index {
}
type SysFileDirControl struct {
ID uint `uri:"ID" comment:"标识"` // 标识
ID int `uri:"ID" comment:"标识"` // 标识
Label string `json:"label" comment:"目录名称"`
PId uint `json:"pId" comment:"上级目录"`
PId int `json:"pId" comment:"上级目录"`
Sort string `json:"sort" comment:"排序"`
Path string `json:"path" comment:"路径"`
CreateBy int `json:"-"`
UpdateBy int `json:"-"`
}
func (s *SysFileDirControl) Bind(ctx *gin.Context) error {
@@ -68,7 +68,7 @@ func (s *SysFileDirControl) Generate() dto.Control {
func (s *SysFileDirControl) GenerateM() (common.ActiveRecord, error) {
return &models.SysFileDir{
Model: gorm.Model{ID: s.ID},
Model: common.Model{ID: s.ID},
Label: s.Label,
PId: s.PId,
Sort: s.Sort,
@@ -82,6 +82,7 @@ func (s *SysFileDirControl) GetId() interface{} {
type SysFileDirById struct {
dto.ObjectById
UpdateBy int `json:"-"`
}
func (s *SysFileDirById) Generate() dto.Control {
+2 -5
View File
@@ -2,8 +2,6 @@ package dto
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
@@ -41,7 +39,7 @@ func (m *SysLoginLogSearch) Generate() dto.Index {
}
type SysLoginLogControl struct {
ID uint `uri:"ID" comment:"主键"` // 主键
ID int `uri:"ID" comment:"主键"` // 主键
Username string `json:"username" comment:"用户名"`
Status string `json:"status" comment:"状态"`
Ipaddr string `json:"ipaddr" comment:"ip地址"`
@@ -75,8 +73,7 @@ func (s *SysLoginLogControl) Generate() dto.Control {
func (s *SysLoginLogControl) GenerateM() (common.ActiveRecord, error) {
return &system.SysLoginLog{
Model: gorm.Model{ID: s.ID},
Model: common.Model{ID: s.ID},
Username: s.Username,
Status: s.Status,
Ipaddr: s.Ipaddr,
+2 -4
View File
@@ -2,8 +2,6 @@ package dto
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
@@ -42,7 +40,7 @@ func (m *SysOperaLogSearch) Generate() dto.Index {
}
type SysOperaLogControl struct {
ID uint `uri:"ID" comment:"编码"` // 编码
ID int `uri:"ID" comment:"编码"` // 编码
Title string `json:"title" comment:"操作模块"`
BusinessType string `json:"businessType" comment:"操作类型"`
BusinessTypes string `json:"businessTypes" comment:""`
@@ -84,7 +82,7 @@ func (s *SysOperaLogControl) Generate() dto.Control {
func (s *SysOperaLogControl) GenerateM() (common.ActiveRecord, error) {
return &system.SysOperaLog{
Model: gorm.Model{ID: s.ID},
Model: common.Model{ID: s.ID},
Title: s.Title,
BusinessType: s.BusinessType,
BusinessTypes: s.BusinessTypes,
+2 -2
View File
@@ -37,7 +37,7 @@ func (m *SysJobSearch) Generate() dto.Index {
}
type SysJobControl struct {
JobId uint `json:"jobId"`
JobId int `json:"jobId"`
JobName string `json:"jobName" validate:"required"` // 名称
JobGroup string `json:"jobGroup"` // 任务分组
JobType int `json:"jobType"` // 任务类型
@@ -93,7 +93,7 @@ func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
}
type SysJobItem struct {
JobId uint `json:"jobId"`
JobId int `json:"jobId"`
JobName string `json:"jobName" validate:"required"` // 名称
JobGroup string `json:"jobGroup"` // 任务分组
JobType int `json:"jobType"` // 任务类型
+9 -11
View File
@@ -3,10 +3,10 @@ package service
import (
"errors"
"go-admin/app/admin/models"
"go-admin/app/admin/service/dto"
"go-admin/common/actions"
cDto "go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/common/service"
"go-admin/tools"
"gorm.io/gorm"
@@ -17,7 +17,7 @@ type SysFileDir struct {
}
// GetSysFileDirPage 获取SysFileDir列表
func (e *SysFileDir) GetSysFileDirPage(c cDto.Index, list *[]models.SysFileDirL) error {
func (e *SysFileDir) GetSysFileDirPage(c *dto.SysFileDirSearch, list *[]models.SysFileDirL) error {
var err error
var data models.SysFileDir
msgID := e.MsgID
@@ -25,7 +25,6 @@ func (e *SysFileDir) GetSysFileDirPage(c cDto.Index, list *[]models.SysFileDirL)
err = e.Orm.Model(&data).
Scopes(
cDto.MakeCondition(c.GetNeedSearch()),
//cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
).
Find(list). //Limit(-1).Offset(-1).
Error
@@ -58,7 +57,7 @@ func (e *SysFileDir) GetSysFileDir(d cDto.Control, model *models.SysFileDir) err
}
// InsertSysFileDir 创建SysFileDir对象
func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
func (e *SysFileDir) InsertSysFileDir(model *dto.SysFileDirControl) error {
var err error
var data models.SysFileDir
msgID := e.MsgID
@@ -70,7 +69,7 @@ func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
return err
}
id := model.GetId()
path := "/" + tools.UIntToString(id.(uint))
path := "/" + tools.IntToString(id.(int))
db = e.Orm.Model(&data).
First(&data, model.GetId())
err = db.Error
@@ -92,7 +91,7 @@ func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
}
// UpdateSysFileDir 修改SysFileDir对象
func (e *SysFileDir) UpdateSysFileDir(c common.ActiveRecord, p *actions.DataPermission) error {
func (e *SysFileDir) UpdateSysFileDir(c *dto.SysFileDirControl, p *actions.DataPermission) error {
var err error
var data models.SysFileDir
msgID := e.MsgID
@@ -100,20 +99,19 @@ func (e *SysFileDir) UpdateSysFileDir(c common.ActiveRecord, p *actions.DataPerm
db := e.Orm.Model(&data).
Scopes(
actions.Permission(data.TableName(), p),
).Where(c.GetId()).Updates(c)
).Where(c.ID).Updates(c)
if db.Error != nil {
log.Errorf("msgID[%s] db error:%s", msgID, err)
return err
}
if db.RowsAffected == 0 {
return errors.New("无权更新该数据")
}
return nil
}
// RemoveSysFileDir 删除SysFileDir
func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *actions.DataPermission) error {
func (e *SysFileDir) RemoveSysFileDir(d *dto.SysFileDirById, p *actions.DataPermission) error {
var err error
var data models.SysFileDir
msgID := e.MsgID
@@ -121,7 +119,7 @@ func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *
db := e.Orm.Model(&data).
Scopes(
actions.Permission(data.TableName(), p),
).Where(d.GetId()).Delete(c)
).Where(d.Id).Delete(&data)
if db.Error != nil {
err = db.Error
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
@@ -134,7 +132,7 @@ func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *
return nil
}
func (e *SysFileDir) SetSysFileDir(c cDto.Index) (*[]models.SysFileDirL, error) {
func (e *SysFileDir) SetSysFileDir(c *dto.SysFileDirSearch) (*[]models.SysFileDirL, error) {
var list []models.SysFileDirL
err := e.GetSysFileDirPage(c, &list)
m := make([]models.SysFileDirL, 0)
+1 -1
View File
@@ -22,7 +22,7 @@ var lock sync.Mutex
type JobCore struct {
InvokeTarget string
Name string
JobId uint
JobId int
EntryId int
CronExpression string
Args string