调整xorm层级
This commit is contained in:
@@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
service2 "cutego/modules/core/service"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/excels"
|
||||
@@ -55,7 +55,7 @@ func (a ConfigApi) List(c *gin.Context) {
|
||||
|
||||
// Add 添加数据
|
||||
func (a ConfigApi) Add(c *gin.Context) {
|
||||
config := entity.SysConfig{}
|
||||
config := dataobject.SysConfig{}
|
||||
if c.Bind(&config) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -83,7 +83,7 @@ func (a ConfigApi) Get(c *gin.Context) {
|
||||
|
||||
// Edit 修改数据
|
||||
func (a ConfigApi) Edit(c *gin.Context) {
|
||||
config := entity.SysConfig{}
|
||||
config := dataobject.SysConfig{}
|
||||
if c.Bind(&config) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/cronjob"
|
||||
@@ -42,7 +42,7 @@ func (a CronJobApi) GetById(c *gin.Context) {
|
||||
|
||||
// Edit 修改定时任务
|
||||
func (a CronJobApi) Edit(c *gin.Context) {
|
||||
record := entity.SysCronJob{}
|
||||
record := dataobject.SysCronJob{}
|
||||
if c.Bind(&record) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -56,7 +56,7 @@ func (a CronJobApi) Edit(c *gin.Context) {
|
||||
|
||||
// Add 新增定时任务
|
||||
func (a CronJobApi) Add(c *gin.Context) {
|
||||
dto := entity.SysCronJob{}
|
||||
dto := dataobject.SysCronJob{}
|
||||
if c.Bind(&dto) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -88,7 +88,7 @@ func (a CronJobApi) Remove(c *gin.Context) {
|
||||
|
||||
// ChangeStatus 改变任务状态
|
||||
func (a CronJobApi) ChangeStatus(c *gin.Context) {
|
||||
record := entity.SysCronJob{}
|
||||
record := dataobject.SysCronJob{}
|
||||
if c.Bind(&record) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/resp"
|
||||
"cutego/pkg/tree/tree_dept"
|
||||
@@ -64,7 +64,7 @@ func (a DeptApi) ExcludeChild(c *gin.Context) {
|
||||
}
|
||||
list := a.deptService.FindDeptList(request.DeptQuery{})
|
||||
var depts = *list
|
||||
deptList := make([]entity.SysDept, 0)
|
||||
deptList := make([]dataobject.SysDept, 0)
|
||||
for _, dept := range depts {
|
||||
if dept.DeptId == deptId || strings.Contains(dept.Ancestors, strconv.Itoa(deptId)) {
|
||||
continue
|
||||
@@ -87,7 +87,7 @@ func (a DeptApi) GetInfo(c *gin.Context) {
|
||||
|
||||
// Add 添加部门
|
||||
func (a DeptApi) Add(c *gin.Context) {
|
||||
dept := entity.SysDept{}
|
||||
dept := dataobject.SysDept{}
|
||||
if c.Bind(&dept) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -134,7 +134,7 @@ func (a DeptApi) Delete(c *gin.Context) {
|
||||
|
||||
// Edit 修改部门数据接口
|
||||
func (a DeptApi) Edit(c *gin.Context) {
|
||||
dept := entity.SysDept{}
|
||||
dept := dataobject.SysDept{}
|
||||
if c.Bind(&dept) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
@@ -66,7 +66,7 @@ func (a DictDataApi) Get(c *gin.Context) {
|
||||
|
||||
// Add 添加字典数据
|
||||
func (a DictDataApi) Add(c *gin.Context) {
|
||||
data := entity.SysDictData{}
|
||||
data := dataobject.SysDictData{}
|
||||
if c.Bind(&data) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -81,7 +81,7 @@ func (a DictDataApi) Add(c *gin.Context) {
|
||||
|
||||
// Edit 编辑字典数据
|
||||
func (a DictDataApi) Edit(c *gin.Context) {
|
||||
data := entity.SysDictData{}
|
||||
data := dataobject.SysDictData{}
|
||||
if c.Bind(&data) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/excels"
|
||||
@@ -43,7 +43,7 @@ func (a DictTypeApi) Get(c *gin.Context) {
|
||||
|
||||
// Edit 修改字典类型
|
||||
func (a DictTypeApi) Edit(c *gin.Context) {
|
||||
dictType := entity.SysDictType{}
|
||||
dictType := dataobject.SysDictType{}
|
||||
if c.Bind(&dictType) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -63,7 +63,7 @@ func (a DictTypeApi) Edit(c *gin.Context) {
|
||||
|
||||
// Add 新增字典类型
|
||||
func (a DictTypeApi) Add(c *gin.Context) {
|
||||
dictType := entity.SysDictType{}
|
||||
dictType := dataobject.SysDictType{}
|
||||
if c.Bind(&dictType) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
request2 "cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
@@ -56,7 +56,7 @@ func (a LoginApi) handleLoginInfo(c *gin.Context, body request2.LoginBody, login
|
||||
location = a.loginInfoService.GetLocationByIp(clientIp).Country
|
||||
}
|
||||
|
||||
a.loginInfoService.Save(entity.SysLoginInfo{
|
||||
a.loginInfoService.Save(dataobject.SysLoginInfo{
|
||||
UserName: body.UserName,
|
||||
IpAddr: clientIp,
|
||||
LoginLocation: location,
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/resp"
|
||||
"cutego/pkg/tree/tree_menu"
|
||||
@@ -68,7 +68,7 @@ func (a MenuApi) TreeSelect(c *gin.Context) {
|
||||
|
||||
// Add 添加菜单数据
|
||||
func (a MenuApi) Add(c *gin.Context) {
|
||||
menu := entity.SysMenu{}
|
||||
menu := dataobject.SysMenu{}
|
||||
if c.Bind(&menu) != nil {
|
||||
resp.ParamError(c, "参数绑定异常")
|
||||
return
|
||||
@@ -82,7 +82,7 @@ func (a MenuApi) Add(c *gin.Context) {
|
||||
|
||||
// Edit 修改菜单数据
|
||||
func (a MenuApi) Edit(c *gin.Context) {
|
||||
menu := entity.SysMenu{}
|
||||
menu := dataobject.SysMenu{}
|
||||
if c.Bind(&menu) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/page"
|
||||
"cutego/pkg/resp"
|
||||
@@ -34,7 +34,7 @@ func (a NoticeApi) List(c *gin.Context) {
|
||||
|
||||
// Add 添加公告
|
||||
func (a NoticeApi) Add(c *gin.Context) {
|
||||
notice := entity.SysNotice{}
|
||||
notice := dataobject.SysNotice{}
|
||||
if c.Bind(¬ice) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -71,7 +71,7 @@ func (a NoticeApi) Get(c *gin.Context) {
|
||||
|
||||
// Edit 修改
|
||||
func (a NoticeApi) Edit(c *gin.Context) {
|
||||
notice := entity.SysNotice{}
|
||||
notice := dataobject.SysNotice{}
|
||||
if c.Bind(¬ice) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
@@ -38,7 +38,7 @@ func (a PostApi) List(c *gin.Context) {
|
||||
|
||||
// Add 新增岗位
|
||||
func (a PostApi) Add(c *gin.Context) {
|
||||
post := entity.SysPost{}
|
||||
post := dataobject.SysPost{}
|
||||
if c.Bind(&post) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
@@ -96,7 +96,7 @@ func (a PostApi) Delete(c *gin.Context) {
|
||||
|
||||
// Edit 修改岗位数据接口
|
||||
func (a PostApi) Edit(c *gin.Context) {
|
||||
post := entity.SysPost{}
|
||||
post := dataobject.SysPost{}
|
||||
if c.Bind(&post) != nil {
|
||||
resp.ParamError(c)
|
||||
return
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserResponse 用户实体返回结构体
|
||||
type UserResponse struct {
|
||||
UserId int64 `json:"userId"` // 用户ID
|
||||
DeptId int64 `excel:"name=部门" json:"deptId"` // 部门ID
|
||||
UserName string `excel:"name=用户登录名" json:"userName"` // 登录用户名
|
||||
NickName string `excel:"name=用户昵称" json:"nickName"` // 用户昵称
|
||||
Email string `excel:"name=用户邮箱" json:"email"` // 邮箱
|
||||
PhoneNumber string `excel:"name=手机号" json:"phoneNumber"` // 手机号
|
||||
Sex string `excel:"name=性别,format=0=男,1=女,2=未知" json:"sex"` // 性别0男1女
|
||||
Avatar string `json:"avatar"` // 头像路径
|
||||
Status string `json:"status"` // 状态 0正常1停用
|
||||
DelFlag string `json:"delFlag"` // 0正常1删除
|
||||
LoginIp string `json:"loginIp"` // 登录ip
|
||||
LoginDate time.Time `json:"loginDate"` // 登录时间
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
SysDept entity.SysDept `xorm:"extends" json:"dept"` // 部门实体
|
||||
UserId int64 `json:"userId"` // 用户ID
|
||||
DeptId int64 `excel:"name=部门" json:"deptId"` // 部门ID
|
||||
UserName string `excel:"name=用户登录名" json:"userName"` // 登录用户名
|
||||
NickName string `excel:"name=用户昵称" json:"nickName"` // 用户昵称
|
||||
Email string `excel:"name=用户邮箱" json:"email"` // 邮箱
|
||||
PhoneNumber string `excel:"name=手机号" json:"phoneNumber"` // 手机号
|
||||
Sex string `excel:"name=性别,format=0=男,1=女,2=未知" json:"sex"` // 性别0男1女
|
||||
Avatar string `json:"avatar"` // 头像路径
|
||||
Status string `json:"status"` // 状态 0正常1停用
|
||||
DelFlag string `json:"delFlag"` // 0正常1删除
|
||||
LoginIp string `json:"loginIp"` // 登录ip
|
||||
LoginDate time.Time `json:"loginDate"` // 登录时间
|
||||
CreateTime time.Time `xorm:"created" json:"createTime"` // 创建时间
|
||||
CreateBy string `json:"createBy"` // 创建人
|
||||
UpdateTime time.Time `json:"updateTime"` // 更新时间
|
||||
UpdateBy string `json:"updateBy"` // 更新人
|
||||
SysDept dataobject.SysDept `xorm:"extends" json:"dept"` // 部门实体
|
||||
}
|
||||
|
||||
// UserInfo 用户整体数据
|
||||
type UserInfo struct {
|
||||
User *UserResponse `json:"user,omitempty"` // 用户数据
|
||||
Roles []*entity.SysRole `json:"roles,omitempty"` // 角色集合
|
||||
Posts []*entity.SysPost `json:"posts,omitempty"` // 部门集合
|
||||
PostIds *[]int64 `json:"postIds,omitempty"` // 岗位id集合
|
||||
RoleIds *[]int64 `json:"roleIds,omitempty"` // 觉得id集合
|
||||
User *UserResponse `json:"user,omitempty"` // 用户数据
|
||||
Roles []*dataobject.SysRole `json:"roles,omitempty"` // 角色集合
|
||||
Posts []*dataobject.SysPost `json:"posts,omitempty"` // 部门集合
|
||||
PostIds *[]int64 `json:"postIds,omitempty"` // 岗位id集合
|
||||
RoleIds *[]int64 `json:"roleIds,omitempty"` // 觉得id集合
|
||||
}
|
||||
|
||||
// IsAdmin 判断当前用户是否是管理员
|
||||
|
||||
@@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/page"
|
||||
@@ -50,7 +50,7 @@ func (a RoleApi) GetRoleId(c *gin.Context) {
|
||||
|
||||
// Add 添加角色业务操作
|
||||
func (a RoleApi) Add(c *gin.Context) {
|
||||
role := entity.SysRole{}
|
||||
role := dataobject.SysRole{}
|
||||
if c.BindJSON(&role) == nil {
|
||||
if a.roleService.CheckRoleNameUnique(role) > 0 {
|
||||
c.JSON(500, resp.ErrorResp(500, "新增角色'"+role.RoleName+"'失败, 角色名称已存在"))
|
||||
@@ -70,7 +70,7 @@ func (a RoleApi) Add(c *gin.Context) {
|
||||
|
||||
// Edit 修改角色
|
||||
func (a RoleApi) Edit(c *gin.Context) {
|
||||
role := entity.SysRole{}
|
||||
role := dataobject.SysRole{}
|
||||
if c.BindJSON(&role) == nil {
|
||||
if a.roleService.CheckRoleNameUnique(role) > 0 {
|
||||
c.JSON(500, resp.ErrorResp(500, "修改角色'"+role.RoleName+"'失败, 角色名称已存在"))
|
||||
@@ -106,7 +106,7 @@ func (a RoleApi) Delete(c *gin.Context) {
|
||||
|
||||
// ChangeStatus 状态修改
|
||||
func (a RoleApi) ChangeStatus(c *gin.Context) {
|
||||
body := entity.SysRole{}
|
||||
body := dataobject.SysRole{}
|
||||
if c.BindJSON(&body) != nil {
|
||||
c.JSON(500, resp.ErrorResp("参数绑定异常"))
|
||||
return
|
||||
@@ -155,7 +155,7 @@ func (a RoleApi) UnallocatedList(c *gin.Context) {
|
||||
|
||||
// CancelAuthUser 取消授权用户
|
||||
func (a RoleApi) CancelAuthUser(c *gin.Context) {
|
||||
roleUser := entity.SysUserRole{}
|
||||
roleUser := dataobject.SysUserRole{}
|
||||
if c.BindJSON(&roleUser) != nil {
|
||||
resp.Error(c)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ package v1
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/excels"
|
||||
@@ -53,11 +53,11 @@ func (a UserApi) GetInfo(c *gin.Context) {
|
||||
parseInt, err := strconv.ParseInt(param, 10, 64)
|
||||
if err == nil {
|
||||
// 判断当前登录用户是否是admin
|
||||
m := new(entity.SysUser)
|
||||
m := new(dataobject.SysUser)
|
||||
if m.IsAdmin(parseInt) {
|
||||
r.Roles = roleAll
|
||||
} else {
|
||||
roles := make([]*entity.SysRole, 0)
|
||||
roles := make([]*dataobject.SysRole, 0)
|
||||
for _, role := range roleAll {
|
||||
if role.RoleId != 1 {
|
||||
roles = append(roles, role)
|
||||
@@ -74,7 +74,7 @@ func (a UserApi) GetInfo(c *gin.Context) {
|
||||
}
|
||||
} else {
|
||||
//id为空不取管理员角色
|
||||
roles := make([]*entity.SysRole, 0)
|
||||
roles := make([]*dataobject.SysRole, 0)
|
||||
for _, role := range roleAll {
|
||||
if role.RoleId != 1 {
|
||||
roles = append(roles, role)
|
||||
@@ -98,11 +98,11 @@ func (a UserApi) AuthRole(c *gin.Context) {
|
||||
user := a.userService.GetUserById(parseInt)
|
||||
// 查询角色
|
||||
roles := a.roleService.GetRoleListByUserId(parseInt)
|
||||
flag := entity.SysUser{}.IsAdmin(parseInt)
|
||||
flag := dataobject.SysUser{}.IsAdmin(parseInt)
|
||||
if flag {
|
||||
m["roles"] = roles
|
||||
} else {
|
||||
roleList := make([]entity.SysRole, 0)
|
||||
roleList := make([]dataobject.SysRole, 0)
|
||||
for _, role := range *roles {
|
||||
if role.RoleId != 1 {
|
||||
roleList = append(roleList, role)
|
||||
|
||||
Reference in New Issue
Block a user