perf👌 : 登陆日志和操作日志功能优化
This commit is contained in:
1 parent
0db58170ee
commit
abe9c42aff
6 files changed
+90
-102
No files matched your search
@@ -8,7 +8,6 @@ import (
|
|||||||
"go-admin/app/admin/service/dto"
|
"go-admin/app/admin/service/dto"
|
||||||
"go-admin/common/apis"
|
"go-admin/common/apis"
|
||||||
"go-admin/common/log"
|
"go-admin/common/log"
|
||||||
common "go-admin/common/models"
|
|
||||||
"go-admin/tools"
|
"go-admin/tools"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -27,10 +26,8 @@ func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req := d.Generate()
|
|
||||||
|
|
||||||
//查询列表
|
//查询列表
|
||||||
err = req.Bind(c)
|
err = d.Bind(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
@@ -41,13 +38,13 @@ func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) {
|
|||||||
serviceStudent := service.SysLoginLog{}
|
serviceStudent := service.SysLoginLog{}
|
||||||
serviceStudent.MsgID = msgID
|
serviceStudent.MsgID = msgID
|
||||||
serviceStudent.Orm = db
|
serviceStudent.Orm = db
|
||||||
err = serviceStudent.GetSysLoginLogPage(req, &list, &count)
|
err = serviceStudent.GetSysLoginLogPage(d, &list, &count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
||||||
@@ -60,8 +57,7 @@ func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//查看详情
|
//查看详情
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
@@ -71,7 +67,7 @@ func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) {
|
|||||||
serviceSysLoginLog := service.SysLoginLog{}
|
serviceSysLoginLog := service.SysLoginLog{}
|
||||||
serviceSysLoginLog.MsgID = msgID
|
serviceSysLoginLog.MsgID = msgID
|
||||||
serviceSysLoginLog.Orm = db
|
serviceSysLoginLog.Orm = db
|
||||||
err = serviceSysLoginLog.GetSysLoginLog(req, &object)
|
err = serviceSysLoginLog.GetSysLoginLog(control, &object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||||
return
|
return
|
||||||
@@ -90,14 +86,12 @@ func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//新增操作
|
//新增操作
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
object, err := control.Generate()
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||||
return
|
return
|
||||||
@@ -127,15 +121,13 @@ func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
req := control.Generate()
|
|
||||||
//更新操作
|
//更新操作
|
||||||
err = req.Bind(c)
|
err = control.Bind(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
object, err := control.Generate()
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||||
return
|
return
|
||||||
@@ -163,15 +155,13 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//删除操作
|
//删除操作
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
object, err := control.GenerateM()
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||||
return
|
return
|
||||||
@@ -183,7 +173,7 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) {
|
|||||||
serviceSysLoginLog := service.SysLoginLog{}
|
serviceSysLoginLog := service.SysLoginLog{}
|
||||||
serviceSysLoginLog.Orm = db
|
serviceSysLoginLog.Orm = db
|
||||||
serviceSysLoginLog.MsgID = msgID
|
serviceSysLoginLog.MsgID = msgID
|
||||||
err = serviceSysLoginLog.RemoveSysLoginLog(req, object)
|
err = serviceSysLoginLog.RemoveSysLoginLog(control, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"go-admin/app/admin/service/dto"
|
"go-admin/app/admin/service/dto"
|
||||||
"go-admin/common/apis"
|
"go-admin/common/apis"
|
||||||
"go-admin/common/log"
|
"go-admin/common/log"
|
||||||
common "go-admin/common/models"
|
|
||||||
"go-admin/tools"
|
"go-admin/tools"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -27,10 +26,8 @@ func (e *SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req := d.Generate()
|
|
||||||
|
|
||||||
//查询列表
|
//查询列表
|
||||||
err = req.Bind(c)
|
err = d.Bind(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
@@ -41,13 +38,13 @@ func (e *SysOperaLog) GetSysOperaLogList(c *gin.Context) {
|
|||||||
serviceStudent := service.SysOperaLog{}
|
serviceStudent := service.SysOperaLog{}
|
||||||
serviceStudent.MsgID = msgID
|
serviceStudent.MsgID = msgID
|
||||||
serviceStudent.Orm = db
|
serviceStudent.Orm = db
|
||||||
err = serviceStudent.GetSysOperaLogPage(req, &list, &count)
|
err = serviceStudent.GetSysOperaLogPage(d, &list, &count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.PageOK(c, list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
e.PageOK(c, list, int(count), d.GetPageIndex(), d.GetPageSize(), "查询成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
||||||
@@ -60,8 +57,7 @@ func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//查看详情
|
//查看详情
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
@@ -71,7 +67,7 @@ func (e *SysOperaLog) GetSysOperaLog(c *gin.Context) {
|
|||||||
serviceSysOperlog := service.SysOperaLog{}
|
serviceSysOperlog := service.SysOperaLog{}
|
||||||
serviceSysOperlog.MsgID = msgID
|
serviceSysOperlog.MsgID = msgID
|
||||||
serviceSysOperlog.Orm = db
|
serviceSysOperlog.Orm = db
|
||||||
err = serviceSysOperlog.GetSysOperaLog(req, &object)
|
err = serviceSysOperlog.GetSysOperaLog(control, &object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "查询失败")
|
||||||
return
|
return
|
||||||
@@ -90,14 +86,12 @@ func (e *SysOperaLog) InsertSysOperaLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//新增操作
|
//新增操作
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
object, err := control.Generate()
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||||
return
|
return
|
||||||
@@ -127,15 +121,13 @@ func (e *SysOperaLog) UpdateSysOperaLog(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
req := control.Generate()
|
|
||||||
//更新操作
|
//更新操作
|
||||||
err = req.Bind(c)
|
err = control.Bind(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
object, err := control.Generate()
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||||
return
|
return
|
||||||
@@ -163,30 +155,20 @@ func (e *SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
|
|||||||
|
|
||||||
msgID := tools.GenerateMsgIDFromContext(c)
|
msgID := tools.GenerateMsgIDFromContext(c)
|
||||||
//删除操作
|
//删除操作
|
||||||
req := control.Generate()
|
err = control.Bind(c)
|
||||||
err = req.Bind(c)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
||||||
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
e.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var object common.ActiveRecord
|
|
||||||
object, err = req.GenerateM()
|
|
||||||
if err != nil {
|
|
||||||
e.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置编辑人
|
|
||||||
object.SetUpdateBy(tools.GetUserId(c))
|
|
||||||
|
|
||||||
serviceSysOperaLog := service.SysOperaLog{}
|
serviceSysOperaLog := service.SysOperaLog{}
|
||||||
serviceSysOperaLog.Orm = db
|
serviceSysOperaLog.Orm = db
|
||||||
serviceSysOperaLog.MsgID = msgID
|
serviceSysOperaLog.MsgID = msgID
|
||||||
err = serviceSysOperaLog.RemoveSysOperaLog(req, object)
|
err = serviceSysOperaLog.RemoveSysOperaLog(control)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK(c, object.GetId(), "删除成功")
|
e.OK(c, control.GetId(), "删除成功")
|
||||||
}
|
}
|
||||||
@@ -13,11 +13,10 @@ import (
|
|||||||
|
|
||||||
type SysLoginLogSearch struct {
|
type SysLoginLogSearch struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
|
Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"`
|
||||||
Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"`
|
Status string `form:"status" search:"type:exact;column:status;table:sys_login_log" comment:"状态"`
|
||||||
Status string `form:"status" search:"type:exact;column:status;table:sys_login_log" comment:"状态"`
|
Ipaddr string `form:"ipaddr" search:"type:exact;column:ipaddr;table:sys_login_log" comment:"ip地址"`
|
||||||
Ipaddr string `form:"ipaddr" search:"type:exact;column:ipaddr;table:sys_login_log" comment:"ip地址"`
|
LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_login_log" comment:"归属地"`
|
||||||
LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_login_log" comment:"归属地"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysLoginLogSearch) GetNeedSearch() interface{} {
|
func (m *SysLoginLogSearch) GetNeedSearch() interface{} {
|
||||||
@@ -33,13 +32,8 @@ func (m *SysLoginLogSearch) Bind(ctx *gin.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysLoginLogSearch) Generate() dto.Index {
|
|
||||||
o := *m
|
|
||||||
return &o
|
|
||||||
}
|
|
||||||
|
|
||||||
type SysLoginLogControl struct {
|
type SysLoginLogControl struct {
|
||||||
ID int `uri:"ID" comment:"主键"` // 主键
|
ID int `uri:"ID" comment:"主键"` // 主键
|
||||||
Username string `json:"username" comment:"用户名"`
|
Username string `json:"username" comment:"用户名"`
|
||||||
Status string `json:"status" comment:"状态"`
|
Status string `json:"status" comment:"状态"`
|
||||||
Ipaddr string `json:"ipaddr" comment:"ip地址"`
|
Ipaddr string `json:"ipaddr" comment:"ip地址"`
|
||||||
@@ -66,12 +60,7 @@ func (s *SysLoginLogControl) Bind(ctx *gin.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysLoginLogControl) Generate() dto.Control {
|
func (s *SysLoginLogControl) Generate() (*system.SysLoginLog, error) {
|
||||||
cp := *s
|
|
||||||
return &cp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysLoginLogControl) GenerateM() (common.ActiveRecord, error) {
|
|
||||||
return &system.SysLoginLog{
|
return &system.SysLoginLog{
|
||||||
Model: common.Model{ID: s.ID},
|
Model: common.Model{ID: s.ID},
|
||||||
Username: s.Username,
|
Username: s.Username,
|
||||||
@@ -92,14 +81,33 @@ func (s *SysLoginLogControl) GetId() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SysLoginLogById struct {
|
type SysLoginLogById struct {
|
||||||
dto.ObjectById
|
Id int `uri:"id"`
|
||||||
|
Ids []int `json:"ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysLoginLogById) Generate() dto.Control {
|
func (s *SysLoginLogById) GetId() interface{} {
|
||||||
|
return s.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysLoginLogById) 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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysLoginLogById) Generate() *SysLoginLogById {
|
||||||
cp := *s
|
cp := *s
|
||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysLoginLogById) GenerateM() (common.ActiveRecord, error) {
|
func (s *SysLoginLogById) GenerateM() (*system.SysLoginLog, error) {
|
||||||
return &system.SysLoginLog{}, nil
|
return &system.SysLoginLog{}, nil
|
||||||
}
|
}
|
||||||
@@ -34,13 +34,8 @@ func (m *SysOperaLogSearch) Bind(ctx *gin.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysOperaLogSearch) Generate() dto.Index {
|
|
||||||
o := *m
|
|
||||||
return &o
|
|
||||||
}
|
|
||||||
|
|
||||||
type SysOperaLogControl struct {
|
type SysOperaLogControl struct {
|
||||||
ID int `uri:"ID" comment:"编码"` // 编码
|
ID int `uri:"ID" comment:"编码"` // 编码
|
||||||
Title string `json:"title" comment:"操作模块"`
|
Title string `json:"title" comment:"操作模块"`
|
||||||
BusinessType string `json:"businessType" comment:"操作类型"`
|
BusinessType string `json:"businessType" comment:"操作类型"`
|
||||||
BusinessTypes string `json:"businessTypes" comment:""`
|
BusinessTypes string `json:"businessTypes" comment:""`
|
||||||
@@ -75,12 +70,7 @@ func (s *SysOperaLogControl) Bind(ctx *gin.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysOperaLogControl) Generate() dto.Control {
|
func (s *SysOperaLogControl) Generate() (*system.SysOperaLog, error) {
|
||||||
cp := *s
|
|
||||||
return &cp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysOperaLogControl) GenerateM() (common.ActiveRecord, error) {
|
|
||||||
return &system.SysOperaLog{
|
return &system.SysOperaLog{
|
||||||
Model: common.Model{ID: s.ID},
|
Model: common.Model{ID: s.ID},
|
||||||
Title: s.Title,
|
Title: s.Title,
|
||||||
@@ -109,14 +99,32 @@ func (s *SysOperaLogControl) GetId() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SysOperaLogById struct {
|
type SysOperaLogById struct {
|
||||||
dto.ObjectById
|
Id int `uri:"id"`
|
||||||
|
Ids []int `json:"ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysOperaLogById) Generate() dto.Control {
|
func (s *SysOperaLogById) GetId() interface{} {
|
||||||
cp := *s
|
if len(s.Ids) > 0 {
|
||||||
return &cp
|
s.Ids = append(s.Ids, s.Id)
|
||||||
|
return s.Ids
|
||||||
|
}
|
||||||
|
return s.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysOperaLogById) GenerateM() (common.ActiveRecord, error) {
|
func (s *SysOperaLogById) Bind(ctx *gin.Context) error {
|
||||||
return &system.SysOperaLog{}, nil
|
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 *SysOperaLogById) SetUpdateBy(id int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"go-admin/app/admin/models/system"
|
"go-admin/app/admin/models/system"
|
||||||
|
"go-admin/app/admin/service/dto"
|
||||||
cDto "go-admin/common/dto"
|
cDto "go-admin/common/dto"
|
||||||
"go-admin/common/log"
|
"go-admin/common/log"
|
||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
@@ -15,7 +16,7 @@ type SysLoginLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSysLoginLogPage 获取SysLoginLog列表
|
// GetSysLoginLogPage 获取SysLoginLog列表
|
||||||
func (e *SysLoginLog) GetSysLoginLogPage(c cDto.Index, list *[]system.SysLoginLog, count *int64) error {
|
func (e *SysLoginLog) GetSysLoginLogPage(c *dto.SysLoginLogSearch, list *[]system.SysLoginLog, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysLoginLog
|
var data system.SysLoginLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -35,7 +36,7 @@ func (e *SysLoginLog) GetSysLoginLogPage(c cDto.Index, list *[]system.SysLoginLo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSysLoginLog 获取SysLoginLog对象
|
// GetSysLoginLog 获取SysLoginLog对象
|
||||||
func (e *SysLoginLog) GetSysLoginLog(d cDto.Control, model *system.SysLoginLog) error {
|
func (e *SysLoginLog) GetSysLoginLog(d *dto.SysLoginLogById, model *system.SysLoginLog) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysLoginLog
|
var data system.SysLoginLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -90,7 +91,7 @@ func (e *SysLoginLog) UpdateSysLoginLog(c common.ActiveRecord) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveSysLoginLog 删除SysLoginLog
|
// RemoveSysLoginLog 删除SysLoginLog
|
||||||
func (e *SysLoginLog) RemoveSysLoginLog(d cDto.Control, c common.ActiveRecord) error {
|
func (e *SysLoginLog) RemoveSysLoginLog(d *dto.SysLoginLogById, c common.ActiveRecord) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysLoginLog
|
var data system.SysLoginLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package service
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"go-admin/app/admin/models/system"
|
"go-admin/app/admin/models/system"
|
||||||
|
"go-admin/app/admin/service/dto"
|
||||||
cDto "go-admin/common/dto"
|
cDto "go-admin/common/dto"
|
||||||
"go-admin/common/log"
|
"go-admin/common/log"
|
||||||
common "go-admin/common/models"
|
|
||||||
"go-admin/common/service"
|
"go-admin/common/service"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ type SysOperaLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSysOperaLogPage 获取SysOperaLog列表
|
// GetSysOperaLogPage 获取SysOperaLog列表
|
||||||
func (e *SysOperaLog) GetSysOperaLogPage(c cDto.Index, list *[]system.SysOperaLog, count *int64) error {
|
func (e *SysOperaLog) GetSysOperaLogPage(c *dto.SysOperaLogSearch, list *[]system.SysOperaLog, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysOperaLog
|
var data system.SysOperaLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -35,7 +35,7 @@ func (e *SysOperaLog) GetSysOperaLogPage(c cDto.Index, list *[]system.SysOperaLo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSysOperaLog 获取SysOperaLog对象
|
// GetSysOperaLog 获取SysOperaLog对象
|
||||||
func (e *SysOperaLog) GetSysOperaLog(d cDto.Control, model *system.SysOperaLog) error {
|
func (e *SysOperaLog) GetSysOperaLog(d *dto.SysOperaLogById, model *system.SysOperaLog) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysOperaLog
|
var data system.SysOperaLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -56,7 +56,7 @@ func (e *SysOperaLog) GetSysOperaLog(d cDto.Control, model *system.SysOperaLog)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InsertSysOperaLog 创建SysOperaLog对象
|
// InsertSysOperaLog 创建SysOperaLog对象
|
||||||
func (e *SysOperaLog) InsertSysOperaLog(model common.ActiveRecord) error {
|
func (e *SysOperaLog) InsertSysOperaLog(model *system.SysOperaLog) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysOperaLog
|
var data system.SysOperaLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -71,7 +71,7 @@ func (e *SysOperaLog) InsertSysOperaLog(model common.ActiveRecord) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSysOperaLog 修改SysOperaLog对象
|
// UpdateSysOperaLog 修改SysOperaLog对象
|
||||||
func (e *SysOperaLog) UpdateSysOperaLog(c common.ActiveRecord) error {
|
func (e *SysOperaLog) UpdateSysOperaLog(c *system.SysOperaLog) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysOperaLog
|
var data system.SysOperaLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
@@ -90,13 +90,12 @@ func (e *SysOperaLog) UpdateSysOperaLog(c common.ActiveRecord) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveSysOperaLog 删除SysOperaLog
|
// RemoveSysOperaLog 删除SysOperaLog
|
||||||
func (e *SysOperaLog) RemoveSysOperaLog(d cDto.Control, c common.ActiveRecord) error {
|
func (e *SysOperaLog) RemoveSysOperaLog(d *dto.SysOperaLogById) error {
|
||||||
var err error
|
var err error
|
||||||
var data system.SysOperaLog
|
var data system.SysOperaLog
|
||||||
msgID := e.MsgID
|
msgID := e.MsgID
|
||||||
|
|
||||||
db := e.Orm.Model(&data).
|
db := e.Orm.Model(&data).Delete(&data, d.GetId())
|
||||||
Where(d.GetId()).Delete(c)
|
|
||||||
if db.Error != nil {
|
if db.Error != nil {
|
||||||
err = db.Error
|
err = db.Error
|
||||||
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
|
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
|
||||||
@@ -107,4 +106,4 @@ func (e *SysOperaLog) RemoveSysOperaLog(d cDto.Control, c common.ActiveRecord) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user