数据库字段风格统一

This commit is contained in:
zhangwenjian
2020-04-08 13:22:52 +08:00
parent 098dfc4d1d
commit 6d187db36a
12 changed files with 128 additions and 121 deletions
+1
View File
@@ -0,0 +1 @@
package blog
+1 -1
View File
@@ -170,7 +170,7 @@ func InsertSysUser(c *gin.Context) {
sysuser.CreateTime = utils.GetCurrntTime()
sysuser.UpdateTime = utils.GetCurrntTime()
sysuser.CreateBy = utils.GetUserIdStr(c)
sysuser.IsDel = "0"
sysuser.IsDel = 0
id, err := sysuser.Insert()
var res models.Response
if err != nil {
+1 -1
View File
@@ -122,7 +122,7 @@ func InsertSysTable(c *gin.Context) {
column.ColumnComment = dbcolumn[i].ColumnComment
column.ColumnName = dbcolumn[i].ColumnName
column.ColumnType = dbcolumn[i].ColumnType
column.Sort = utils.IntToString(i + 1)
column.Sort = i + 1
column.Insert = true
column.IsInsert = "1"
column.QueryType = "EQ"
+14 -14
View File
@@ -8,15 +8,15 @@ import (
type Config struct {
//编码
ConfigId int64 `json:"configId" gorm:"column:configId;primary_key"`
ConfigId int64 `json:"configId" gorm:"column:config_id;primary_key"`
//参数名称
ConfigName string `json:"configName" gorm:"column:configName"`
ConfigName string `json:"configName" gorm:"column:config_name"`
//参数键名
ConfigKey string `json:"configKey" gorm:"column:configKey"`
ConfigKey string `json:"configKey" gorm:"column:config_key"`
//参数键值
ConfigValue string `json:"configValue" gorm:"column:configValue"`
ConfigValue string `json:"configValue" gorm:"column:config_value"`
//是否系统内置
ConfigType string `json:"configType" gorm:"column:configType"`
ConfigType string `json:"configType" gorm:"column:config_type"`
//备注
Remark string `json:"remark" gorm:"column:remark"`
@@ -26,13 +26,13 @@ type Config struct {
UpdateTime string `json:"updateTime" gorm:"column:update_time"`
DataScope string `json:"dataScope" gorm:"-"`
Params string `json:"params" gorm:"column:params"`
IsDel string `json:"isDel" gorm:"column:is_del"`
IsDel int `json:"isDel" gorm:"column:is_del"`
}
// Config 创建
func (e *Config) Create() (Config, error) {
var doc Config
doc.IsDel = "0"
doc.IsDel = 0
e.CreateTime = utils.GetCurrntTime()
e.UpdateTime = utils.GetCurrntTime()
result := orm.Eloquent.Table("sys_config").Create(&e)
@@ -50,11 +50,11 @@ func (e *Config) Get() (Config, error) {
table := orm.Eloquent.Table("sys_config")
if e.ConfigId != 0 {
table = table.Where("configId = ?", e.ConfigId)
table = table.Where("config_id = ?", e.ConfigId)
}
if e.ConfigKey != "" {
table = table.Where("configKey = ?", e.ConfigKey)
table = table.Where("config_key = ?", e.ConfigKey)
}
if err := table.Where("is_del = 0").First(&doc).Error; err != nil {
@@ -69,13 +69,13 @@ func (e *Config) GetPage(pageSize int, pageIndex int) ([]Config, int32, error) {
table := orm.Eloquent.Select("*").Table("sys_config")
if e.ConfigName != "" {
table = table.Where("configName = ?", e.ConfigName)
table = table.Where("config_name = ?", e.ConfigName)
}
if e.ConfigKey != "" {
table = table.Where("configKey = ?", e.ConfigKey)
table = table.Where("config_key = ?", e.ConfigKey)
}
if e.ConfigType != "" {
table = table.Where("configType = ?", e.ConfigType)
table = table.Where("config_type = ?", e.ConfigType)
}
// 数据权限控制
@@ -94,7 +94,7 @@ func (e *Config) GetPage(pageSize int, pageIndex int) ([]Config, int32, error) {
func (e *Config) Update(id int64) (update Config, err error) {
e.UpdateTime = utils.GetCurrntTime()
if err = orm.Eloquent.Table("sys_config").Where("configId = ?", id).First(&update).Error; err != nil {
if err = orm.Eloquent.Table("sys_config").Where("config_id = ?", id).First(&update).Error; err != nil {
return
}
@@ -111,7 +111,7 @@ func (e *Config) Delete(id int64) (success bool, err error) {
mp["is_del"] = "1"
mp["update_time"] = utils.GetCurrntTime()
mp["update_by"] = e.UpdateBy
if err = orm.Eloquent.Table("sys_config").Where("configId = ?", id).Update(mp).Error; err != nil {
if err = orm.Eloquent.Table("sys_config").Where("config_id = ?", id).Update(mp).Error; err != nil {
success = false
return
}
+15 -16
View File
@@ -7,7 +7,7 @@ import (
type Dept struct {
//部门编码
Deptid int64 `gorm:"column:deptId;primary_key" json:"deptId" example:"1" extensions:"x-description=标示"`
Deptid int64 `gorm:"column:dept_id;primary_key" json:"deptId" example:"1" extensions:"x-description=标示"`
//上级部门
ParentId int64 `gorm:"column:parent_id" json:"parent_id"`
@@ -32,28 +32,27 @@ type Dept struct {
//状态
Status string `gorm:"column:status" json:"status"`
CreateBy string `json:"createBy" gorm:"column:create_by"`
CreateTime string `json:"createTime" gorm:"column:create_time"`
UpdateBy string `json:"updateBy" gorm:"column:update_by"`
UpdateTime string `json:"updateTime" gorm:"column:update_time"`
DataScope string `json:"dataScope" gorm:"-"`
Params string `json:"params" gorm:"column:params"`
IsDel string `json:"isDel" gorm:"column:is_del"`
Children []Dept `json:"children"`
CreateBy string `gorm:"column:create_by" json:"createBy"`
CreateTime string `gorm:"column:create_time" json:"createTime"`
UpdateBy string `gorm:"column:update_by" json:"updateBy"`
UpdateTime string `gorm:"column:update_time" json:"updateTime"`
DataScope string `gorm:"-" json:"dataScope"`
Params string `gorm:"-" json:"params"`
IsDel int `gorm:"column:is_del" json:"isDel"`
Children []Dept `gorm:"-"json:"children"`
}
type DeptLable struct {
Id int64 `json:"id" gorm:"-"`
Label string `json:"label" gorm:"-"`
Children []DeptLable `json:"children" gorm:"-"`
Id int64 `gorm:"-" json:"id"`
Label string `gorm:"-" json:"label"`
Children []DeptLable `gorm:"-" json:"children"`
}
func (e *Dept) Create() (Dept, error) {
var doc Dept
e.CreateTime = utils.GetCurrntTime()
e.UpdateTime = utils.GetCurrntTime()
e.IsDel = "0"
e.IsDel = 0
result := orm.Eloquent.Table("sys_dept").Create(&e)
if result.Error != nil {
err := result.Error
@@ -109,7 +108,7 @@ func (e *Dept) GetList() ([]Dept, error) {
table = table.Where("status = ?", e.Status)
}
if err := table.Where("is_del = 0").Find(&doc).Error; err != nil {
if err := table.Where("is_del = 0").Order("sort").Find(&doc).Error; err != nil {
return doc, err
}
return doc, nil
@@ -138,7 +137,7 @@ func (e *Dept) GetPage(bl bool) ([]Dept, error) {
table = dataPermission.GetDataScope("sys_dept", table)
}
if err := table.Where("is_del = 0").Find(&doc).Error; err != nil {
if err := table.Where("is_del = 0").Order("sort").Find(&doc).Error; err != nil {
return nil, err
}
return doc, nil
+23 -23
View File
@@ -7,22 +7,22 @@ import (
type DictData struct {
//字典编码
DictCode int64 `gorm:"column:dictCode;primary_key" json:"dictCode" example:"1"`
DictCode int64 `gorm:"column:dict_code;primary_key" json:"dictCode" example:"1"`
//显示顺序
DictSort int64 `gorm:"column:dictSort" json:"dictSort" example:"1"`
DictSort int `gorm:"column:dict_sort" json:"dictSort" example:"1"`
//数据标签
DictLabel string `gorm:"column:dictLabel" json:"dictLabel"`
DictLabel string `gorm:"column:dict_label" json:"dictLabel"`
//数据键值
DictValue string `gorm:"column:dictValue" json:"dictValue"`
DictValue string `gorm:"column:dict_value" json:"dictValue"`
//字典类型
DictType string `gorm:"column:dictType" json:"dictType"`
CssClass string `gorm:"column:cssClass" json:"cssClass"`
ListClass string `gorm:"column:listClass" json:"listClass"`
IsDefault string `gorm:"column:isDefault" json:"isDefault"`
DictType string `gorm:"column:dict_type" json:"dictType"`
CssClass string `gorm:"column:css_class" json:"cssClass"`
ListClass string `gorm:"column:list_class" json:"listClass"`
IsDefault string `gorm:"column:is_default" json:"isDefault"`
//状态
Status string `gorm:"column:status" json:"status"`
@@ -35,8 +35,8 @@ type DictData struct {
//备注
Remark string `gorm:"column:remark" json:"remark"`
Params string `gorm:"column:params" json:"params"`
DataScope string `gorm:"column:dataScope" json:"dataScope"`
IsDel string `gorm:"column:is_del" json:"isDel"`
DataScope string `gorm:"column:data_scope" json:"dataScope"`
IsDel int `gorm:"column:is_del" json:"isDel"`
}
func (e *DictData) Create() (DictData, error) {
@@ -57,13 +57,13 @@ func (e *DictData) GetByCode() (DictData, error) {
table := orm.Eloquent.Table("sys_dict_data")
if e.DictCode != 0 {
table = table.Where("dictCode = ?", e.DictCode)
table = table.Where("dict_code = ?", e.DictCode)
}
if e.DictLabel != "" {
table = table.Where("dictLabel = ?", e.DictLabel)
table = table.Where("dict_label = ?", e.DictLabel)
}
if e.DictType != "" {
table = table.Where("dictType = ?", e.DictType)
table = table.Where("dict_type = ?", e.DictType)
}
if err := table.Where("is_del = 0").First(&doc).Error; err != nil {
@@ -77,16 +77,16 @@ func (e *DictData) Get() ([]DictData, error) {
table := orm.Eloquent.Table("sys_dict_data")
if e.DictCode != 0 {
table = table.Where("dictCode = ?", e.DictCode)
table = table.Where("dict_code = ?", e.DictCode)
}
if e.DictLabel != "" {
table = table.Where("dictLabel = ?", e.DictLabel)
table = table.Where("dict_label = ?", e.DictLabel)
}
if e.DictType != "" {
table = table.Where("dictType = ?", e.DictType)
table = table.Where("dict_type = ?", e.DictType)
}
if err := table.Where("is_del = 0").Find(&doc).Error; err != nil {
if err := table.Where("is_del = 0").Order("dict_sort").Find(&doc).Error; err != nil {
return doc, err
}
return doc, nil
@@ -97,13 +97,13 @@ func (e *DictData) GetPage(pageSize int, pageIndex int) ([]DictData, int32, erro
table := orm.Eloquent.Select("*").Table("sys_dict_data")
if e.DictCode != 0 {
table = table.Where("dictCode = ?", e.DictCode)
table = table.Where("dict_code = ?", e.DictCode)
}
if e.DictType != "" {
table = table.Where("dictType = ?", e.DictType)
table = table.Where("dict_type = ?", e.DictType)
}
if e.DictLabel != "" {
table = table.Where("dictLabel = ?", e.DictLabel)
table = table.Where("dict_label = ?", e.DictLabel)
}
if e.Status != "" {
table = table.Where("status = ?", e.Status)
@@ -116,7 +116,7 @@ func (e *DictData) GetPage(pageSize int, pageIndex int) ([]DictData, int32, erro
var count int32
if err := table.Where("is_del = 0").Order("dictSort").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
if err := table.Where("is_del = 0").Order("dict_sort").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
return nil, 0, err
}
table.Where("is_del = 0").Count(&count)
@@ -125,7 +125,7 @@ func (e *DictData) GetPage(pageSize int, pageIndex int) ([]DictData, int32, erro
func (e *DictData) Update(id int64) (update DictData, err error) {
e.UpdateTime = utils.GetCurrntTime()
if err = orm.Eloquent.Table("sys_dict_data").Where("dictCode = ?", id).First(&update).Error; err != nil {
if err = orm.Eloquent.Table("sys_dict_data").Where("dict_code = ?", id).First(&update).Error; err != nil {
return
}
@@ -142,7 +142,7 @@ func (e *DictData) Delete(id int64) (success bool, err error) {
mp["is_del"] = "1"
mp["update_time"] = utils.GetCurrntTime()
mp["update_by"] = e.UpdateBy
if err = orm.Eloquent.Table("sys_dict_data").Where("dictCode = ?", id).Update(mp).Error; err != nil {
if err = orm.Eloquent.Table("sys_dict_data").Where("dict_code = ?", id).Update(mp).Error; err != nil {
success = false
return
}
+14 -14
View File
@@ -6,17 +6,17 @@ import (
)
type DictType struct {
DictId int64 `gorm:"column:dictId;primary_key" json:"dictId" example:"1"`
DictId int64 `gorm:"column:dict_id;primary_key" json:"dictId" example:"1"`
//字典名称
DictName string `gorm:"column:dictName" json:"dictName"`
DictName string `gorm:"column:dict_name" json:"dictName"`
//字典类型
DictType string `gorm:"column:dictType" json:"dictType"`
DictType string `gorm:"column:dict_type" json:"dictType"`
//状态
Status string `gorm:"column:status" json:"status"`
DataScope string `gorm:"-" json:"dataScope"`
Params string `gorm:"column:params" json:"params"`
Params string `gorm:"-" json:"params"`
//创建者
CreateBy string `gorm:"column:create_by" json:"createBy"`
//创建时间
@@ -27,7 +27,7 @@ type DictType struct {
UpdateTime string `gorm:"column:update_time" json:"updateTime"`
//备注
Remark string `gorm:"column:remark" json:"remark"`
IsDel string `gorm:"column:is_del" json:"isDel"`
IsDel int `gorm:"column:is_del" json:"isDel"`
}
func (e *DictType) Create() (DictType, error) {
@@ -48,13 +48,13 @@ func (e *DictType) Get() (DictType, error) {
table := orm.Eloquent.Table("sys_dict_type")
if e.DictId != 0 {
table = table.Where("dictId = ?", e.DictId)
table = table.Where("dict_id = ?", e.DictId)
}
if e.DictName != "" {
table = table.Where("dictName = ?", e.DictName)
table = table.Where("dict_name = ?", e.DictName)
}
if e.DictType != "" {
table = table.Where("dictType = ?", e.DictType)
table = table.Where("dict_type = ?", e.DictType)
}
if err := table.Where("is_del = 0").First(&doc).Error; err != nil {
@@ -68,13 +68,13 @@ func (e *DictType) GetList() ([]DictType, error) {
table := orm.Eloquent.Table("sys_dict_type")
if e.DictId != 0 {
table = table.Where("dictId = ?", e.DictId)
table = table.Where("dict_id = ?", e.DictId)
}
if e.DictName != "" {
table = table.Where("dictName = ?", e.DictName)
table = table.Where("dict_name = ?", e.DictName)
}
if e.DictType != "" {
table = table.Where("dictType = ?", e.DictType)
table = table.Where("dict_type = ?", e.DictType)
}
if err := table.Where("is_del = 0").Find(&doc).Error; err != nil {
@@ -88,10 +88,10 @@ func (e *DictType) GetPage(pageSize int, pageIndex int) ([]DictType, int32, erro
table := orm.Eloquent.Select("*").Table("sys_dict_type")
if e.DictId != 0 {
table = table.Where("dictId = ?", e.DictId)
table = table.Where("dict_id = ?", e.DictId)
}
if e.DictName != "" {
table = table.Where("dictName = ?", e.DictName)
table = table.Where("dict_name = ?", e.DictName)
}
// 数据权限控制
@@ -127,7 +127,7 @@ func (e *DictType) Delete(id int64) (success bool, err error) {
mp["is_del"] = "1"
mp["update_time"] = utils.GetCurrntTime()
mp["update_by"] = e.UpdateBy
if err = orm.Eloquent.Table("sys_dict_type").Where("dictId = ?", id).Update(mp).Error; err != nil {
if err = orm.Eloquent.Table("sys_dict_type").Where("dict_id = ?", id).Update(mp).Error; err != nil {
success = false
return
}
+30 -30
View File
@@ -7,23 +7,23 @@ import (
)
type Menu struct {
MenuId int64 `json:"menuId" gorm:"column:menuId;primary_key"`
MenuName string `json:"menuName" gorm:"column:menuName"`
MenuId int64 `json:"menuId" gorm:"column:menu_id;primary_key"`
MenuName string `json:"menuName" gorm:"column:menu_name"`
Title string `json:"title" gorm:"column:title"`
Icon string `json:"icon" gorm:"column:icon"`
Path string `json:"path" gorm:"column:path"`
Paths string `json:"paths" gorm:"column:paths"`
MenuType string `json:"menuType" gorm:"column:menuType"`
MenuType string `json:"menuType" gorm:"column:menu_type"`
Action string `json:"action" gorm:"column:action"`
Permission string `json:"permission" gorm:"column:permission"`
ParentId int64 `json:"parentId" gorm:"column:parentId"`
NoCache bool `json:"noCache" gorm:"column:noCache"`
ParentId int64 `json:"parentId" gorm:"column:parent_id"`
NoCache bool `json:"noCache" gorm:"column:no_cache"`
Breadcrumb string `json:"breadcrumb" gorm:"column:breadcrumb"`
Component string `json:"component" gorm:"column:component"`
Sort int `json:"sort" gorm:"column:sort"`
Visible string `json:"visible" gorm:"column:visible"`
Children []Menu `json:"children"`
Children []Menu `json:"children" gorm:"-"`
IsSelect bool `json:"is_select" gorm:"-"`
RoleId int64 `gorm:"-"`
@@ -33,7 +33,7 @@ type Menu struct {
UpdateTime string `json:"updateTime" gorm:"column:update_time"`
DataScope string `json:"dataScope" gorm:"-"`
Params string `json:"params" gorm:"-"`
IsDel string `json:"isDel" gorm:"column:is_del"`
IsDel int `json:"isDel" gorm:"column:is_del"`
}
type MenuLable struct {
Id int64 `json:"id" gorm:"-"`
@@ -42,22 +42,22 @@ type MenuLable struct {
}
type Menus struct {
MenuId int64 `json:"menuId" gorm:"column:menuId;primary_key"`
MenuName string `json:"menuName" gorm:"column:menuName"`
MenuId int64 `json:"menuId" gorm:"column:menu_id;primary_key"`
MenuName string `json:"menuName" gorm:"column:menu_name"`
Title string `json:"title" gorm:"column:title"`
Icon string `json:"icon" gorm:"column:icon"`
Path string `json:"path" gorm:"column:path"`
MenuType string `json:"menuType" gorm:"column:menuType"`
MenuType string `json:"menuType" gorm:"column:menu_type"`
Action string `json:"action" gorm:"column:action"`
Permission string `json:"permission" gorm:"column:permission"`
ParentId int64 `json:"parentId" gorm:"column:parentId"`
NoCache bool `json:"noCache" gorm:"column:noCache"`
ParentId int64 `json:"parentId" gorm:"column:parent_id"`
NoCache bool `json:"noCache" gorm:"column:no_cache"`
Breadcrumb string `json:"breadcrumb" gorm:"column:breadcrumb"`
Component string `json:"component" gorm:"column:component"`
Sort int `json:"sort" gorm:"column:sort"`
Visible string `json:"visible" gorm:"column:visible"`
Children []Menu `json:"children"`
Children []Menu `json:"children" gorm:"-"`
CreateBy string `json:"createBy" gorm:"column:create_by"`
CreateTime string `json:"createTime" gorm:"column:create_time"`
@@ -65,7 +65,7 @@ type Menus struct {
UpdateTime string `json:"updateTime" gorm:"column:update_time"`
DataScope string `json:"dataScope" gorm:"-"`
Params string `json:"params" gorm:"-"`
IsDel string `json:"isDel" gorm:"column:is_del"`
IsDel int `json:"isDel" gorm:"column:is_del"`
}
type MenuRole struct {
@@ -79,7 +79,7 @@ func (e *Menu) GetByMenuId() (Menu Menu, err error) {
table := orm.Eloquent.Table("sys_menu")
table = table.Where("is_del = ?", 0)
table = table.Where("menuId = ?", e.MenuId)
table = table.Where("menu_id = ?", e.MenuId)
if err = table.Find(&Menu).Error; err != nil {
return
}
@@ -206,18 +206,18 @@ func (menu *MenuRole) Get() (Menus []MenuRole, err error) {
table := orm.Eloquent.Table("sys_menu")
table = table.Where("is_del = ?", 0)
if menu.MenuName != "" {
table = table.Where("menuName = ?", menu.MenuName)
table = table.Where("menu_name = ?", menu.MenuName)
}
if err = table.Find(&Menus).Error; err != nil {
if err = table.Order("sort").Find(&Menus).Error; err != nil {
return
}
return
}
func (e *Menu) GetByRoleName(rolename string) (Menus []Menu, err error) {
table := orm.Eloquent.Table("sys_menu").Select("sys_menu.*").Joins("left join sys_role_menu on sys_role_menu.menu_id=sys_menu.menuId")
table = table.Where("is_del = ? and sys_role_menu.role_name=? and menuType in ('M','C')", 0, rolename)
if err = table.Find(&Menus).Error; err != nil {
table := orm.Eloquent.Table("sys_menu").Select("sys_menu.*").Joins("left join sys_role_menu on sys_role_menu.menu_id=sys_menu.menu_id")
table = table.Where("is_del = ? and sys_role_menu.role_name=? and menu_type in ('M','C')", 0, rolename)
if err = table.Order("sort").Find(&Menus).Error; err != nil {
return
}
return
@@ -227,7 +227,7 @@ func (e *Menu) Get() (Menus []Menu, err error) {
table := orm.Eloquent.Table("sys_menu")
table = table.Where("is_del = ?", 0)
if e.MenuName != "" {
table = table.Where("menuName = ?", e.MenuName)
table = table.Where("menu_name = ?", e.MenuName)
}
if e.Path != "" {
table = table.Where("path = ?", e.Path)
@@ -236,10 +236,10 @@ func (e *Menu) Get() (Menus []Menu, err error) {
table = table.Where("action = ?", e.Action)
}
if e.MenuType != "" {
table = table.Where("menuType = ?", e.MenuType)
table = table.Where("menu_type = ?", e.MenuType)
}
if err = table.Find(&Menus).Error; err != nil {
if err = table.Order("sort").Find(&Menus).Error; err != nil {
return
}
return
@@ -249,10 +249,10 @@ func (e *Menu) GetPage() (Menus []Menu, err error) {
table := orm.Eloquent.Table("sys_menu")
table = table.Where("is_del = ?", 0)
if e.MenuName != "" {
table = table.Where("menuName = ?", e.MenuName)
table = table.Where("menu_name = ?", e.MenuName)
}
if e.MenuType != "" {
table = table.Where("menuType = ?", e.MenuType)
table = table.Where("menu_type = ?", e.MenuType)
}
if e.Visible != "" {
table = table.Where("visible = ?", e.Visible)
@@ -263,7 +263,7 @@ func (e *Menu) GetPage() (Menus []Menu, err error) {
dataPermission.UserId, _ = utils.StringToInt64(e.DataScope)
table = dataPermission.GetDataScope("sys_menu", table)
if err = table.Find(&Menus).Error; err != nil {
if err = table.Order("sort").Find(&Menus).Error; err != nil {
return
}
return
@@ -272,7 +272,7 @@ func (e *Menu) GetPage() (Menus []Menu, err error) {
func (e *Menu) Create() (id int64, err error) {
e.CreateTime = utils.GetCurrntTime()
e.UpdateTime = utils.GetCurrntTime()
e.IsDel = "0"
e.IsDel = 0
result := orm.Eloquent.Table("sys_menu").Create(&e)
if result.Error != nil {
err = result.Error
@@ -289,7 +289,7 @@ func (e *Menu) Create() (id int64, err error) {
func InitPaths(menu *Menu) (err error) {
parentMenu := new(Menu)
if int(menu.ParentId) != 0 {
orm.Eloquent.Table("sys_menu").Where("menuId = ?", menu.ParentId).First(parentMenu)
orm.Eloquent.Table("sys_menu").Where("menu_id = ?", menu.ParentId).First(parentMenu)
if parentMenu.Paths == "" {
err = errors.New("父级paths异常,请尝试对当前节点父级菜单进行更新操作!")
return
@@ -298,7 +298,7 @@ func InitPaths(menu *Menu) (err error) {
} else {
menu.Paths = "/0/" + utils.Int64ToString(menu.MenuId)
}
orm.Eloquent.Table("sys_menu").Where("menuId = ?", menu.MenuId).Update("paths", menu.Paths)
orm.Eloquent.Table("sys_menu").Where("menu_id = ?", menu.MenuId).Update("paths", menu.Paths)
return
}
@@ -325,7 +325,7 @@ func (e *Menu) Delete(id int64) (success bool, err error) {
mp["is_del"] = "1"
mp["update_time"] = utils.GetCurrntTime()
mp["update_by"] = e.UpdateBy
if err = orm.Eloquent.Table("sys_menu").Where("menuId = ?", id).Update(mp).Error; err != nil {
if err = orm.Eloquent.Table("sys_menu").Where("menu_id = ?", id).Update(mp).Error; err != nil {
success = false
return
}
+24 -15
View File
@@ -7,13 +7,13 @@ import (
type Post struct {
//岗位编号
PostId int64 `gorm:"column:postId;primary_key" json:"postId" example:"1" extensions:"x-description=标示"`
PostId int64 `gorm:"column:post_id;primary_key" json:"postId" example:"1" extensions:"x-description=标示"`
//岗位名称
PostName string `gorm:"column:postName" json:"postName"`
PostName string `gorm:"column:post_name" json:"postName"`
//岗位代码
PostCode string `gorm:"column:postCode" json:"postCode"`
PostCode string `gorm:"column:post_code" json:"postCode"`
//岗位排序
Sort int `gorm:"column:sort" json:"sort"`
@@ -31,7 +31,7 @@ type Post struct {
UpdateTime string `gorm:"column:update_time" json:"updateTime"`
//是否删除
IsDel int64 `gorm:"column:is_del" json:"isDel"`
IsDel int `gorm:"column:is_del" json:"isDel"`
CreateBy string `gorm:"column:create_by" json:"createBy"`
@@ -39,7 +39,7 @@ type Post struct {
DataScope string `gorm:"-" json:"dataScope"`
Params string `gorm:"column:params" json:"params"`
Params string `gorm:"-" json:"params"`
}
func (e *Post) Create() (Post, error) {
@@ -60,13 +60,16 @@ func (e *Post) Get() (Post, error) {
table := orm.Eloquent.Table("sys_post")
if e.PostId != 0 {
table = table.Where("postId = ?", e.PostId)
table = table.Where("post_id = ?", e.PostId)
}
if e.PostName != "" {
table = table.Where("postName = ?", e.PostName)
table = table.Where("post_name = ?", e.PostName)
}
if e.PostCode != "" {
table = table.Where("postCode = ?", e.PostCode)
table = table.Where("post_code = ?", e.PostCode)
}
if e.Status != "" {
table = table.Where("status = ?", e.Status)
}
if err := table.Where("is_del = 0").First(&doc).Error; err != nil {
@@ -80,13 +83,16 @@ func (e *Post) GetList() ([]Post, error) {
table := orm.Eloquent.Table("sys_post")
if e.PostId != 0 {
table = table.Where("postId = ?", e.PostId)
table = table.Where("post_id = ?", e.PostId)
}
if e.PostName != "" {
table = table.Where("postName = ?", e.PostName)
table = table.Where("post_name = ?", e.PostName)
}
if e.PostCode != "" {
table = table.Where("postCode = ?", e.PostCode)
table = table.Where("post_code = ?", e.PostCode)
}
if e.Status != "" {
table = table.Where("status = ?", e.Status)
}
if err := table.Where("is_del = 0").Find(&doc).Error; err != nil {
@@ -100,10 +106,13 @@ func (e *Post) GetPage(pageSize int, pageIndex int) ([]Post, int32, error) {
table := orm.Eloquent.Select("*").Table("sys_post")
if e.PostId != 0 {
table = table.Where("postId = ?", e.PostId)
table = table.Where("post_id = ?", e.PostId)
}
if e.PostName != "" {
table = table.Where("postName = ?", e.PostName)
table = table.Where("post_name = ?", e.PostName)
}
if e.Status != "" {
table = table.Where("status = ?", e.Status)
}
// 数据权限控制
@@ -113,7 +122,7 @@ func (e *Post) GetPage(pageSize int, pageIndex int) ([]Post, int32, error) {
var count int32
if err := table.Where("is_del = 0").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
if err := table.Where("is_del = 0").Order("sort").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
return nil, 0, err
}
table.Where("is_del = 0").Count(&count)
@@ -139,7 +148,7 @@ func (e *Post) Delete(id int64) (success bool, err error) {
mp["is_del"] = "1"
mp["update_time"] = utils.GetCurrntTime()
mp["update_by"] = e.UpdateBy
if err = orm.Eloquent.Table("sys_post").Where("postId = ?", id).Update(mp).Error; err != nil {
if err = orm.Eloquent.Table("sys_post").Where("post_id = ?", id).Update(mp).Error; err != nil {
success = false
return
}
+2 -2
View File
@@ -29,7 +29,7 @@ type SysRole struct {
Remark string `gorm:"column:remark" json:"remark"`
Params string `gorm:"column:params" json:"params"`
DataScope string `gorm:"-" json:"dataScope"`
IsDel string `gorm:"column:is_del" json:"isDel"`
IsDel int `gorm:"column:is_del" json:"isDel"`
Admin bool `gorm:"column:admin" json:"admin"`
@@ -119,7 +119,7 @@ func (role *SysRole) Insert() (id int64, err error) {
role.CreateTime = utils.GetCurrntTime()
role.UpdateBy = ""
role.UpdateTime = utils.GetCurrntTime()
role.IsDel = "0"
role.IsDel = 0
result := orm.Eloquent.Table("sys_role").Create(&role)
if result.Error != nil {
err = result.Error
+1 -1
View File
@@ -75,7 +75,7 @@ type SysUserB struct {
Params string `gorm:"column:params" json:"params"`
Status string `gorm:"column:status" json:"status"`
DataScope string `gorm:"-" json:"dataScope"`
IsDel string `gorm:"column:is_del" json:"isDel"`
IsDel int `gorm:"column:is_del" json:"isDel"`
}
type SysUser struct {
+1 -3
View File
@@ -24,7 +24,7 @@ type SysColumns struct {
QueryType string `gorm:"column:query_type" json:"queryType"`
HtmlType string `gorm:"column:html_type" json:"htmlType"`
DictType string `gorm:"column:dict_type" json:"dictType"`
Sort string `gorm:"column:sort" json:"sort"`
Sort int `gorm:"column:sort" json:"sort"`
List string `gorm:"column:list" json:"list"`
Pk bool `gorm:"column:pk" json:"pk"`
Required bool `gorm:"column:required" json:"required"`
@@ -48,7 +48,6 @@ func (e *SysColumns) GetList() ([]SysColumns, error) {
table = table.Where("table_id = ?", e.TableId)
if err := table.Find(&doc).Error; err != nil {
return nil, err
}
@@ -81,4 +80,3 @@ func (e *SysColumns) Update() (update SysColumns, err error) {
return
}