mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
update 修改表名的硬编码问题
This commit is contained in:
+10
-10
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
//sys_operlog
|
||||
type SysOperLog struct {
|
||||
OperId int `json:"operId" gorm:"primary_key;AUTO_INCREMENT"` //日志编码
|
||||
Title string `json:"title" gorm:"size(255);"` //操作模块
|
||||
BusinessType string `json:"businessType" gorm:"type:varchar(128);"` //操作类型
|
||||
OperId int `json:"operId" gorm:"primary_key;AUTO_INCREMENT"` //日志编码
|
||||
Title string `json:"title" gorm:"size(255);"` //操作模块
|
||||
BusinessType string `json:"businessType" gorm:"type:varchar(128);"` //操作类型
|
||||
BusinessTypes string `json:"businessTypes" gorm:"type:varchar(128);"`
|
||||
Method string `json:"method" gorm:"type:varchar(128);"` //函数
|
||||
RequestMethod string `json:"requestMethod" gorm:"type:varchar(128);"` //请求方式
|
||||
@@ -20,7 +20,7 @@ type SysOperLog struct {
|
||||
OperIp string `json:"operIp" gorm:"type:varchar(128);"` //客户端ip
|
||||
OperLocation string `json:"operLocation" gorm:"type:varchar(128);"` //访问位置
|
||||
OperParam string `json:"operParam" gorm:"type:varchar(255);"` //请求参数
|
||||
Status string `json:"status" gorm:"type:int(1);"` //操作状态
|
||||
Status string `json:"status" gorm:"type:int(1);"` //操作状态
|
||||
OperTime time.Time `json:"operTime" gorm:"type:timestamp;"` //操作时间
|
||||
JsonResult string `json:"jsonResult" gorm:"type:varchar(255);"` //返回数据
|
||||
CreateBy string `json:"createBy" gorm:"type:varchar(128);"` //创建人
|
||||
@@ -40,7 +40,7 @@ func (SysOperLog) TableName() string {
|
||||
func (e *SysOperLog) Get() (SysOperLog, error) {
|
||||
var doc SysOperLog
|
||||
|
||||
table := orm.Eloquent.Table("sys_operlog")
|
||||
table := orm.Eloquent.Table(e.TableName())
|
||||
if e.OperIp != "" {
|
||||
table = table.Where("oper_ip = ?", e.OperIp)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (e *SysOperLog) Get() (SysOperLog, error) {
|
||||
func (e *SysOperLog) GetPage(pageSize int, pageIndex int) ([]SysOperLog, int, error) {
|
||||
var doc []SysOperLog
|
||||
|
||||
table := orm.Eloquent.Select("*").Table("sys_operlog")
|
||||
table := orm.Eloquent.Select("*").Table(e.TableName())
|
||||
if e.OperIp != "" {
|
||||
table = table.Where("oper_ip = ?", e.OperIp)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (e *SysOperLog) Create() (SysOperLog, error) {
|
||||
var doc SysOperLog
|
||||
e.CreateBy = "0"
|
||||
e.UpdateBy = "0"
|
||||
result := orm.Eloquent.Table("sys_operlog").Create(&e)
|
||||
result := orm.Eloquent.Table(e.TableName()).Create(&e)
|
||||
if result.Error != nil {
|
||||
err := result.Error
|
||||
return doc, err
|
||||
@@ -94,20 +94,20 @@ func (e *SysOperLog) Create() (SysOperLog, error) {
|
||||
}
|
||||
|
||||
func (e *SysOperLog) Update(id int) (update SysOperLog, err error) {
|
||||
if err = orm.Eloquent.Table("sys_operlog").First(&update, id).Error; err != nil {
|
||||
if err = orm.Eloquent.Table(e.TableName()).First(&update, id).Error; err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//参数1:是要修改的数据
|
||||
//参数2:是修改的数据
|
||||
if err = orm.Eloquent.Table("sys_operlog").Model(&update).Updates(&e).Error; err != nil {
|
||||
if err = orm.Eloquent.Table(e.TableName()).Model(&update).Updates(&e).Error; err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (e *SysOperLog) BatchDelete(id []int) (Result bool, err error) {
|
||||
if err = orm.Eloquent.Table("sys_operlog").Where(" oper_id in (?)", id).Delete(&SysOperLog{}).Error; err != nil {
|
||||
if err = orm.Eloquent.Table(e.TableName()).Where(" oper_id in (?)", id).Delete(&SysOperLog{}).Error; err != nil {
|
||||
return
|
||||
}
|
||||
Result = true
|
||||
|
||||
Reference in New Issue
Block a user