改变路由层级,模块化
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysConfig struct {
|
||||
ConfigId int `excel:"name=参数主键" xorm:"pk autoincr" json:"configId"` // 主键id
|
||||
ConfigName string `excel:"name=参数名称" xorm:"varchar(100)" json:"configName"` // 参数名称
|
||||
ConfigKey string `excel:"name=参数键名" xorm:"varchar(100)" json:"configKey"` // 参数建名
|
||||
ConfigValue string `excel:"name=参数键值" xorm:"varchar(1)" json:"configValue"` // 参数键值
|
||||
ConfigType string `excel:"name=系统内置,format=Y=是,N=否" xorm:"char(1)" json:"configType"` // 系统内置(Y是 N否)
|
||||
CreateBy string `xorm:"varchar(64)" json:"createBy"` // 创建人
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
UpdateBy string `xorm:"varchar(64)" json:"updateBy"` // 更新人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
Remark string `xorm:"varchar(500)" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func (c SysConfig) TableName() string {
|
||||
return "sys_config"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysCronJob struct {
|
||||
JobId int64 `xorm:"pk autoincr" json:"jobId"` // 任务主键
|
||||
JobName string `xorm:"varchar(100)" json:"jobName"` // 任务名称
|
||||
JobCron string `xorm:"varchar(255)" json:"jobCron"` // cron表达式
|
||||
FuncAlias string `xorm:"varchar(100)" json:"funcAlias"` // 方法别名(程序内注册的别名)
|
||||
Status string `xorm:"char(1)" json:"status"` // 状态(1、Running 0、Stop)
|
||||
Level int `xorm:"int(1)" json:"level"` // 任务级别(0、普通 1、一般 2、重要 3、强保)
|
||||
CreateBy string `xorm:"varchar(64)"` // 创建人
|
||||
CreateTime time.Time `xorm:"created"` // 创建时间
|
||||
UpdateBy string `xorm:"varchar(64)"` // 更新人
|
||||
UpdateTime time.Time `xorm:"updated"` // 更新时间
|
||||
Remark string `xorm:"varchar(500)" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func (c SysCronJob) TableName() string {
|
||||
return "sys_cron_job"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
// SysDept 部门结构体
|
||||
type SysDept struct {
|
||||
DeptId int `xorm:"pk autoincr" json:"deptId"`
|
||||
Ancestors string `xorm:"varchar(50)" json:"ancestors"`
|
||||
DeptName string `xorm:"varchar(128)" json:"deptName"`
|
||||
OrderNum int `json:"orderNum"`
|
||||
Leader string `xorm:"varchar(20)" json:"leader"`
|
||||
ParentId int `json:"parentId"`
|
||||
Phone string `xorm:"varchar(11)" json:"phone"`
|
||||
Status string `xorm:"char(1)" json:"status"`
|
||||
Email string `json:"email"`
|
||||
DelFlag string `xorm:"char(1) default('0')" json:"delFlag"`
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
}
|
||||
|
||||
func (d SysDept) GetLabel() string {
|
||||
return d.DeptName
|
||||
}
|
||||
|
||||
func (d SysDept) GetId() int {
|
||||
return d.DeptId
|
||||
}
|
||||
|
||||
func (d SysDept) GetParentId() int {
|
||||
return d.ParentId
|
||||
}
|
||||
|
||||
func (d SysDept) GetData() interface{} {
|
||||
return d
|
||||
}
|
||||
|
||||
func (d SysDept) IsRoot() bool {
|
||||
return d.ParentId == 0 || d.ParentId == d.DeptId
|
||||
}
|
||||
|
||||
func (SysDept) TableName() string {
|
||||
return "sys_dept"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SysDictData 字典数据
|
||||
type SysDictData struct {
|
||||
DictCode int64 `excel:"name=字典编码" xorm:"pk autoincr" json:"dictCode"` // 字典ID
|
||||
DictSort int `excel:"name=字典排序" xorm:"int" json:"dictSort"` // 字典排序
|
||||
DictLabel string `excel:"name=字典标签" xorm:"varchar(128)" json:"dictLabel"` // 字典标签
|
||||
DictValue string `excel:"name=字典键值" xorm:"varchar(128)" json:"dictValue"` // 字典键值
|
||||
DictType string `excel:"name=字典类型" xorm:"varchar(128)" json:"dictType"` // 字典类型
|
||||
IsDefault string `excel:"name=是否默认,format=Y=是,N=否" json:"isDefault"` // 是否默认
|
||||
Status string `excel:"name=状态,format=0=正常,1=停用" xorm:"char(1)" json:"status"` // 状态 0正常1停用
|
||||
Remark string `xorm:"varchar(512)" json:"remark"` // 备注
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
}
|
||||
|
||||
func (SysDictData) TableName() string {
|
||||
return "sys_dict_data"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SysDictType 字典类型表
|
||||
type SysDictType struct {
|
||||
DictId int64 `excel:"name=字典主键" xorm:"pk autoincr" json:"dictId"` // 字典ID
|
||||
DictName string `excel:"name=字典名称" xorm:"varchar(128)" json:"dictName"` // 字典名称
|
||||
DictType string `excel:"name=字典类型" xorm:"varchar(128)" json:"dictType"` // 字典类型
|
||||
Status string `excel:"name=字典状态,format=0=正常,1=停用" xorm:"char(1)" json:"status"` // 状态 0正常1停用
|
||||
Remark string `xorm:"varchar(512)" json:"remark"` // 备注
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
}
|
||||
|
||||
func (SysDictType) TableName() string {
|
||||
return "sys_dict_type"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysLog struct {
|
||||
Id int64 `xorm:"pk autoincr" json:"id"` // 主键
|
||||
Uid string `xorm:"uid" json:"uid"` // 唯一主键
|
||||
Content string `xorm:"varchar(255)" json:"content"` // 记录内容
|
||||
CreateTime time.Time `xorm:"created"` // 创建时间
|
||||
}
|
||||
|
||||
func (c SysLog) TableName() string {
|
||||
return "sys_log"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysLoginInfo struct {
|
||||
Id int `excel:"name=主键id" xorm:"pk autoincr" json:"id"` // 主键id
|
||||
UserName string `excel:"name=用户账号" xorm:"varchar(50)" json:"userName"` // 用户账号
|
||||
IpAddr string `excel:"name=登录IP地址" xorm:"varchar(128)" json:"ipAddr"` // 登录IP地址
|
||||
LoginLocation string `excel:"name=登录地点" xorm:"varchar(255)" json:"loginLocation"` // 登录地点
|
||||
Browser string `excel:"name=浏览器类型" xorm:"varchar(255)" json:"browser"` // 浏览器类型
|
||||
OS string `excel:"name=操作系统" xorm:"os varchar(50)" json:"os"` // 操作系统
|
||||
Status string `excel:"name=登录状态,format=1=成功,0=失败" xorm:"char(1)" json:"status"` // 登录状态(1成功 0失败)
|
||||
Msg string `excel:"name=提示消息" xorm:"varchar(255)" json:"msg"` // 提示消息
|
||||
LoginTime time.Time `excel:"name=登录时间" xorm:"login_time" json:"loginTime"` // 登录时间
|
||||
}
|
||||
|
||||
func (c SysLoginInfo) TableName() string {
|
||||
return "sys_login_info"
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SysMenu 菜单结构体
|
||||
type SysMenu struct {
|
||||
MenuId int `xorm:"pk autoincr" json:"menuId"` // 主键Id
|
||||
ParentId int `json:"parentId"` // 父Id
|
||||
MenuName string `xorm:"varchar(128)" json:"menuName"` // 菜单名称
|
||||
OrderNum int `xorm:"int" json:"orderNum"` // 显示顺序
|
||||
Path string `xorm:"varchar(200)" json:"path"` // 请求路径
|
||||
MenuType string `xorm:"char(1)" json:"menuType"` // 菜单类型 (M目录 C菜单 F按钮)
|
||||
Visible string `xorm:"char(1)" json:"visible"` // 菜单状态 (0显示 1隐藏)
|
||||
IsFrame int `json:"isFrame"` // 是否为外链(0是 1否)
|
||||
IsCache int `json:"isCache"` // 是否缓存(0缓存 1不缓存)
|
||||
Perms string `xorm:"varchar(100)" json:"perms"` // 权限标识
|
||||
Icon string `xorm:"varchar(100)" json:"icon"` // 图标
|
||||
Remark string `xorm:"varchar(512)" json:"remark"` // 备注
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
Status string `xorm:"char(1)" json:"status"` // 菜单状态(0正常 1停用)
|
||||
Component string `xorm:"varchar(255)" json:"component"` // 组件路径
|
||||
}
|
||||
|
||||
func (SysMenu) TableName() string {
|
||||
return "sys_menu"
|
||||
}
|
||||
func (s SysMenu) GetPath() string {
|
||||
return s.Path
|
||||
}
|
||||
func (s SysMenu) GetName() string {
|
||||
return strings.Title(s.Path)
|
||||
}
|
||||
func (s SysMenu) GetMenuId() int {
|
||||
return s.MenuId
|
||||
}
|
||||
func (s SysMenu) GetParentId() int {
|
||||
return s.ParentId
|
||||
}
|
||||
func (s SysMenu) GetData() interface{} {
|
||||
return s
|
||||
}
|
||||
func (s SysMenu) IsRoot() bool {
|
||||
// 这里通过FatherId等于0 或者 FatherId等于自身Id表示顶层根节点
|
||||
return s.ParentId == 0 || s.ParentId == s.MenuId
|
||||
}
|
||||
|
||||
func (s SysMenu) GetId() int {
|
||||
return s.MenuId
|
||||
}
|
||||
|
||||
func (s SysMenu) GetLabel() string {
|
||||
return s.MenuName
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
type SysNotice struct {
|
||||
NoticeId int64 `xorm:"pk autoincr" json:"noticeId"` // 公告id
|
||||
NoticeTitle string `xorm:"notice_title" json:"noticeTitle"` // 公告标题
|
||||
NoticeType string `xorm:"notice_type" json:"noticeType"` // 公告类型(1通知 2公告)
|
||||
NoticeContent string `json:"noticeContent"` // 公告内容
|
||||
Status string `json:"status"` // 公告状态(0正常 1关闭)
|
||||
CreateBy string `xorm:"varchar(64)" json:"createBy"` // 创建人
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
UpdateBy string `xorm:"varchar(64)" json:"updateBy"` // 更新人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
Remark string `xorm:"varchar(500)" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func (SysNotice) TableName() string {
|
||||
return "sys_notice"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
// SysPost 岗位表对应结构体
|
||||
type SysPost struct {
|
||||
PostId int64 `excel:"name=岗位编号" xorm:"pk autoincr" json:"postId"` // 岗位ID
|
||||
PostCode string `excel:"name=岗位编码" xorm:"varchar(64)" json:"postCode"` // 岗位编码
|
||||
PostName string `excel:"name=岗位名称" xorm:"varchar(64)" json:"postName"` // 岗位名称
|
||||
PostSort int `excel:"name=岗位排序" json:"postSort"` // 显示顺序
|
||||
Status string `excel:"name=状态,format=0=正常,1=停用" xorm:"char(1)" json:"status"` // 状态 0正常 1停用
|
||||
Remark string `xorm:"varchar(512)" json:"remark"` // 备注
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
}
|
||||
|
||||
func (SysPost) TableName() string {
|
||||
return "sys_post"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
type SysRole struct {
|
||||
RoleId int64 `excel:"name=角色序号" xorm:"pk autoincr" json:"roleId"` // 角色id
|
||||
RoleName string `excel:"name=角色名称" xorm:"varchar(64)" json:"roleName"` // 角色名称
|
||||
RoleKey string `excel:"name=角色权限" xorm:"varchar(64)" json:"roleKey"` // 角色权限标识
|
||||
RoleSort int `excel:"name=角色排序" xorm:"int" json:"roleSort"` // 角色顺序
|
||||
DataScope string `excel:"-" json:"dataScope"` // 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)
|
||||
MenuCheckStrictly bool `excel:"-" json:"menuCheckStrictly"` // 菜单树选择项是否关联显示
|
||||
DeptCheckStrictly bool `excel:"-" json:"deptCheckStrictly"` // 部门树选择项是否关联显示
|
||||
Status string `excel:"name=角色状态,format=0=正常,1=停用" xorm:"char(1)" json:"status"` // 角色状态 0正常1停用
|
||||
DelFlag string `excel:"" xorm:"char(1)" json:"delFlag"` // 删除标记0正常1删除
|
||||
CreateTime time.Time `excel:"" xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `excel:"" json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `excel:"" xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `excel:"" json:"updateBy"` // 更新人
|
||||
Remark string `excel:"" json:"remark"` // 备注
|
||||
MenuIds []int64 `xorm:"-" json:"menuIds"` // 菜单组
|
||||
DeptIds []int64 `xorm:"-" json:"deptIds"` // 部门组
|
||||
}
|
||||
|
||||
func (r SysRole) TableName() string {
|
||||
return "sys_role"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package entity
|
||||
|
||||
// SysRoleMenu 角色菜单数据结构
|
||||
type SysRoleMenu struct {
|
||||
RoleId int64 `xorm:"pk" json:"roleId"` // 角色id
|
||||
MenuId int64 `xorm:"pk" json:"menuId"` // 菜单id
|
||||
}
|
||||
|
||||
func (SysRoleMenu) TableName() string {
|
||||
return "sys_role_menu"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SysUser 用户表数据结构体
|
||||
type SysUser struct {
|
||||
UserId int64 `xorm:"pk autoincr" json:"userId"` // 用户ID
|
||||
DeptId int64 `json:"deptId"` // 部门ID
|
||||
UserName string `xorm:"varchar(128)" json:"userName"` // 登录用户名
|
||||
NickName string `xorm:"varchar(128)" json:"nickName"` // 用户昵称
|
||||
Email string `xorm:"varchar(1024)" json:"email"` // 邮箱
|
||||
PhoneNumber string `xorm:"varchar(11)" json:"phoneNumber"` // 手机号
|
||||
Sex string `xorm:"char(1)" json:"sex"` // 性别0男1女
|
||||
Avatar string `xorm:"varchar(128)" json:"avatar"` // 头像路径
|
||||
Password string `xorm:"varchar(128)" json:"-"` // 密码
|
||||
Status string `xorm:"char(1)" json:"status"` // 状态 0正常1停用
|
||||
DelFlag string `xorm:"char(1)" json:"delFlag"` // 0正常1删除
|
||||
LoginIp string `xorm:"varchar(128)" json:"loginIp"` // 登录ip
|
||||
LoginDate time.Time `json:"loginDate"` // 登录时间
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `xorm:"updated" json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
}
|
||||
|
||||
func (receiver SysUser) TableName() string {
|
||||
return "sys_user"
|
||||
}
|
||||
|
||||
// IsAdmin 判断用户是不是管理员
|
||||
func (u SysUser) IsAdmin(userId int64) bool {
|
||||
return userId > 0 && 1 == userId
|
||||
}
|
||||
|
||||
func (a SysUser) IsEmpty() bool {
|
||||
return reflect.DeepEqual(a, SysUser{})
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package entity
|
||||
|
||||
type SysUserPost struct {
|
||||
UserId int64 `json:"userId"` // 用户id
|
||||
PostId int64 `json:"postId"` // 部门id
|
||||
}
|
||||
|
||||
func (SysUserPost) TableName() string {
|
||||
return "sys_user_post"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package entity
|
||||
|
||||
type SysUserRole struct {
|
||||
UserId int64 `xorm:"pk" json:"userId"` // 用户id
|
||||
RoleId int64 `xorm:"pk" json:"roleId"` // 角色id
|
||||
}
|
||||
|
||||
func (SysUserRole) TableName() string {
|
||||
return "sys_user_role"
|
||||
}
|
||||
Reference in New Issue
Block a user