改变路由层级,模块化
This commit is contained in:
parent
bd25f041a2
commit
0f8c1f989b
|
@ -20,7 +20,7 @@ CuteGo是一套全部开源的快速开发平台,毫无保留给个人及企
|
|||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护
|
||||
7. 参数管理:对系统动态配置常用参数
|
||||
8. 定时任务:定时调度执行方法, 方法注册在 core/job/index.go (调度日志 下次再写了)
|
||||
8. 定时任务:定时调度执行方法, 方法注册在 core/job/index.go
|
||||
|
||||
#### cutego前端
|
||||
gitee地址: https://gitee.com/odboy/cutego-ui
|
||||
|
@ -79,6 +79,13 @@ gitee地址: https://gitee.com/odboy/cutego-ui
|
|||
[core] entity -> dao -> service -> api -> xx_router -> router
|
||||
|
||||
eg.
|
||||
cutego
|
||||
school
|
||||
dataobject
|
||||
dao
|
||||
service
|
||||
api
|
||||
router
|
||||
[模块名称] entity -> dao -> service -> api -> router
|
||||
```
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
models2 "cutego/core/entity"
|
||||
"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 models2.SysDept `xorm:"extends" json:"dept"` // 部门实体
|
||||
}
|
||||
|
||||
// UserInfo 用户整体数据
|
||||
type UserInfo struct {
|
||||
User *UserResponse `json:"user,omitempty"` // 用户数据
|
||||
Roles []*models2.SysRole `json:"roles,omitempty"` // 角色集合
|
||||
Posts []*models2.SysPost `json:"posts,omitempty"` // 部门集合
|
||||
PostIds *[]int64 `json:"postIds,omitempty"` // 岗位id集合
|
||||
RoleIds *[]int64 `json:"roleIds,omitempty"` // 觉得id集合
|
||||
}
|
||||
|
||||
// IsAdmin 判断当前用户是否是管理员
|
||||
func (r UserResponse) IsAdmin() bool {
|
||||
return r.UserId == 1
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/pkg/filter"
|
||||
"cutego/pkg/jwt"
|
||||
"cutego/pkg/middleware"
|
||||
"cutego/pkg/middleware/logger"
|
||||
"cutego/pkg/websocket"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Init() *gin.Engine {
|
||||
router := gin.New()
|
||||
router.Use(gin.Logger())
|
||||
router.Use(gin.Recovery())
|
||||
router.Use(logger.LoggerToFile())
|
||||
router.Use(middleware.Recover)
|
||||
router.Use(jwt.JWTAuth())
|
||||
router.Use(filter.DemoHandler())
|
||||
// websocket
|
||||
router.GET("/websocket", websocket.HandleWebSocketMessage)
|
||||
// v1版本api
|
||||
v1Router := router.Group("/api/v1")
|
||||
{
|
||||
// 登录接口
|
||||
initLoginRouter(v1Router)
|
||||
// 用户路由接口
|
||||
initUserRouter(v1Router)
|
||||
// 部门路由注册
|
||||
initDeptRouter(v1Router)
|
||||
// 初始化字典数据路由
|
||||
initDictDataRouter(v1Router)
|
||||
// 注册配置路由
|
||||
initConfigRouter(v1Router)
|
||||
// 注册角色路由
|
||||
initRoleRouter(v1Router)
|
||||
// 注册菜单路由
|
||||
initMenuRouter(v1Router)
|
||||
// 注册岗位路由
|
||||
initPostRouter(v1Router)
|
||||
// 注册字典类型路由
|
||||
initDictTypeRouter(v1Router)
|
||||
// 注册公告路由
|
||||
initNoticeRouter(v1Router)
|
||||
// 注册定时任务路由
|
||||
initCronJobRouter(v1Router)
|
||||
}
|
||||
return router
|
||||
}
|
9
main.go
9
main.go
|
@ -2,9 +2,9 @@ package main
|
|||
|
||||
// init函数执行顺序自上而下, 最后执行main包里面的init函数
|
||||
import (
|
||||
_ "cutego/core/dao"
|
||||
_ "cutego/core/job"
|
||||
"cutego/core/router"
|
||||
"cutego/modules"
|
||||
_ "cutego/modules/core/dao"
|
||||
_ "cutego/modules/core/job"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/config"
|
||||
_ "cutego/pkg/cronjob"
|
||||
|
@ -16,9 +16,8 @@ import (
|
|||
|
||||
func main() {
|
||||
//go testChangeJob()
|
||||
|
||||
gin.SetMode(util.IF(config.AppEnvConfig.Server.RunMode == "", "debug", config.AppEnvConfig.Server.RunMode).(string))
|
||||
r := router.Init()
|
||||
r := modules.Init()
|
||||
r.Use(logger.LoggerToFile())
|
||||
err := r.Run(fmt.Sprintf(":%d", config.AppEnvConfig.Server.Port))
|
||||
if err != nil {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
cache2 "cutego/core/cache"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/entity"
|
||||
service2 "cutego/modules/core/service"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
|
@ -19,8 +19,8 @@ import (
|
|||
)
|
||||
|
||||
type ConfigApi struct {
|
||||
configService service.ConfigService
|
||||
logService service.LogService
|
||||
configService service2.ConfigService
|
||||
logService service2.LogService
|
||||
}
|
||||
|
||||
// GetConfigValue 根据参数键名查询参数值
|
|
@ -1,10 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/cronjob"
|
||||
"cutego/pkg/resp"
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/resp"
|
||||
"cutego/pkg/tree/tree_dept"
|
||||
"cutego/pkg/util"
|
|
@ -1,10 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
"cutego/pkg/page"
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
service2 "cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
|
@ -15,8 +15,8 @@ import (
|
|||
)
|
||||
|
||||
type DictTypeApi struct {
|
||||
dictTypeService service2.DictTypeService
|
||||
dictDataService service2.DictDataService
|
||||
dictTypeService service.DictTypeService
|
||||
dictDataService service.DictDataService
|
||||
}
|
||||
|
||||
// List 获取字典类型数据
|
|
@ -1,10 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
cache2 "cutego/core/cache"
|
||||
"cutego/core/entity"
|
||||
service2 "cutego/core/service"
|
||||
request2 "cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"cutego/pkg/resp"
|
||||
|
@ -17,16 +17,16 @@ import (
|
|||
)
|
||||
|
||||
type LoginApi struct {
|
||||
loginService service2.LoginService
|
||||
roleService service2.RoleService
|
||||
permissionService service2.PermissionService
|
||||
menuService service2.MenuService
|
||||
loginInfoService service2.LoginInfoService
|
||||
loginService service.LoginService
|
||||
roleService service.RoleService
|
||||
permissionService service.PermissionService
|
||||
menuService service.MenuService
|
||||
loginInfoService service.LoginInfoService
|
||||
}
|
||||
|
||||
// Login 登录
|
||||
func (a LoginApi) Login(c *gin.Context) {
|
||||
loginBody := request.LoginBody{}
|
||||
loginBody := request2.LoginBody{}
|
||||
if c.BindJSON(&loginBody) == nil {
|
||||
m := make(map[string]string)
|
||||
loginStatus, token := a.loginService.Login(loginBody.UserName, loginBody.Password)
|
||||
|
@ -45,7 +45,7 @@ func (a LoginApi) Login(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a LoginApi) handleLoginInfo(c *gin.Context, body request.LoginBody, loginStatus bool) {
|
||||
func (a LoginApi) handleLoginInfo(c *gin.Context, body request2.LoginBody, loginStatus bool) {
|
||||
status := common.If(loginStatus, "1", "0")
|
||||
|
||||
clientIp := a.loginInfoService.GetRequestClientIp(c)
|
||||
|
@ -98,7 +98,7 @@ func (a LoginApi) GetLoginHistory(c *gin.Context) {
|
|||
// 获取当前登录用户
|
||||
user := a.loginService.GetCurrentUser(c)
|
||||
// 配置参数
|
||||
query := request.LoginInfoQuery{}
|
||||
query := request2.LoginInfoQuery{}
|
||||
query.UserName = user.UserName
|
||||
// 查询
|
||||
list, i := a.loginInfoService.FindPage(query)
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/resp"
|
||||
"cutego/pkg/tree/tree_menu"
|
||||
"cutego/pkg/util"
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/page"
|
||||
"cutego/pkg/resp"
|
||||
"cutego/pkg/util"
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
service2 "cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/file"
|
||||
"cutego/pkg/page"
|
||||
|
@ -17,8 +17,8 @@ import (
|
|||
)
|
||||
|
||||
type PostApi struct {
|
||||
postService service2.PostService
|
||||
userPostService service2.UserPostService
|
||||
postService service.PostService
|
||||
userPostService service.UserPostService
|
||||
}
|
||||
|
||||
// List 查询刚问分页数据
|
|
@ -0,0 +1,41 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"cutego/modules/core/entity"
|
||||
"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"` // 部门实体
|
||||
}
|
||||
|
||||
// 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集合
|
||||
}
|
||||
|
||||
// IsAdmin 判断当前用户是否是管理员
|
||||
func (r UserResponse) IsAdmin() bool {
|
||||
return r.UserId == 1
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
req2 "cutego/core/api/v1/request"
|
||||
models2 "cutego/core/entity"
|
||||
service2 "cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/page"
|
||||
"cutego/pkg/resp"
|
||||
|
@ -16,13 +16,13 @@ import (
|
|||
)
|
||||
|
||||
type RoleApi struct {
|
||||
roleService service2.RoleService
|
||||
userService service2.UserService
|
||||
roleService service.RoleService
|
||||
userService service.UserService
|
||||
}
|
||||
|
||||
// Find 分页查询角色数据
|
||||
func (a RoleApi) Find(c *gin.Context) {
|
||||
query := req2.RoleQuery{}
|
||||
query := request.RoleQuery{}
|
||||
if c.BindQuery(&query) == nil {
|
||||
list, i := a.roleService.FindPage(query)
|
||||
p := page.Page{
|
||||
|
@ -50,7 +50,7 @@ func (a RoleApi) GetRoleId(c *gin.Context) {
|
|||
|
||||
// Add 添加角色业务操作
|
||||
func (a RoleApi) Add(c *gin.Context) {
|
||||
role := models2.SysRole{}
|
||||
role := entity.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 := models2.SysRole{}
|
||||
role := entity.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 := models2.SysRole{}
|
||||
body := entity.SysRole{}
|
||||
if c.BindJSON(&body) != nil {
|
||||
c.JSON(500, resp.ErrorResp("参数绑定异常"))
|
||||
return
|
||||
|
@ -127,7 +127,7 @@ func (a RoleApi) ChangeStatus(c *gin.Context) {
|
|||
|
||||
// AllocatedList 查询已分配用户角色列表
|
||||
func (a RoleApi) AllocatedList(c *gin.Context) {
|
||||
query := req2.UserQuery{}
|
||||
query := request.UserQuery{}
|
||||
if c.BindQuery(&query) != nil {
|
||||
resp.Error(c)
|
||||
return
|
||||
|
@ -141,7 +141,7 @@ func (a RoleApi) AllocatedList(c *gin.Context) {
|
|||
|
||||
// UnallocatedList 查询未分配用户角色列表
|
||||
func (a RoleApi) UnallocatedList(c *gin.Context) {
|
||||
query := req2.UserQuery{}
|
||||
query := request.UserQuery{}
|
||||
if c.BindQuery(&query) != nil {
|
||||
resp.Error(c)
|
||||
return
|
||||
|
@ -155,7 +155,7 @@ func (a RoleApi) UnallocatedList(c *gin.Context) {
|
|||
|
||||
// CancelAuthUser 取消授权用户
|
||||
func (a RoleApi) CancelAuthUser(c *gin.Context) {
|
||||
roleUser := models2.SysUserRole{}
|
||||
roleUser := entity.SysUserRole{}
|
||||
if c.BindJSON(&roleUser) != nil {
|
||||
resp.Error(c)
|
||||
return
|
||||
|
@ -169,7 +169,7 @@ func (a RoleApi) CancelAuthUser(c *gin.Context) {
|
|||
|
||||
// UpdateAuthUserAll 批量选择用户授权
|
||||
func (a RoleApi) UpdateAuthUserAll(c *gin.Context) {
|
||||
body := req2.UserRoleBody{}
|
||||
body := request.UserRoleBody{}
|
||||
if c.Bind(&body) != nil {
|
||||
resp.Error(c)
|
||||
return
|
||||
|
@ -183,7 +183,7 @@ func (a RoleApi) UpdateAuthUserAll(c *gin.Context) {
|
|||
|
||||
// Export 导出Excel
|
||||
func (a RoleApi) Export(c *gin.Context) {
|
||||
query := req2.RoleQuery{}
|
||||
query := request.RoleQuery{}
|
||||
items := make([]interface{}, 0)
|
||||
if c.BindQuery(&query) == nil {
|
||||
list, _ := a.roleService.FindPage(query)
|
|
@ -1,10 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
models2 "cutego/core/entity"
|
||||
service2 "cutego/core/service"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/excels"
|
||||
"cutego/pkg/page"
|
||||
|
@ -19,9 +19,9 @@ import (
|
|||
|
||||
// UserApi 用户操作api
|
||||
type UserApi struct {
|
||||
userService service2.UserService
|
||||
roleService service2.RoleService
|
||||
postService service2.PostService
|
||||
userService service.UserService
|
||||
roleService service.RoleService
|
||||
postService service.PostService
|
||||
}
|
||||
|
||||
// Find 查询用户列表
|
||||
|
@ -53,11 +53,11 @@ func (a UserApi) GetInfo(c *gin.Context) {
|
|||
parseInt, err := strconv.ParseInt(param, 10, 64)
|
||||
if err == nil {
|
||||
// 判断当前登录用户是否是admin
|
||||
m := new(models2.SysUser)
|
||||
m := new(entity.SysUser)
|
||||
if m.IsAdmin(parseInt) {
|
||||
r.Roles = roleAll
|
||||
} else {
|
||||
roles := make([]*models2.SysRole, 0)
|
||||
roles := make([]*entity.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([]*models2.SysRole, 0)
|
||||
roles := make([]*entity.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 := models2.SysUser{}.IsAdmin(parseInt)
|
||||
flag := entity.SysUser{}.IsAdmin(parseInt)
|
||||
if flag {
|
||||
m["roles"] = roles
|
||||
} else {
|
||||
roleList := make([]models2.SysRole, 0)
|
||||
roleList := make([]entity.SysRole, 0)
|
||||
for _, role := range *roles {
|
||||
if role.RoleId != 1 {
|
||||
roleList = append(roleList, role)
|
|
@ -1,7 +1,7 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
models2 "cutego/core/entity"
|
||||
models2 "cutego/modules/core/entity"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/constant"
|
|
@ -1,7 +1,7 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
models2 "cutego/core/entity"
|
||||
models2 "cutego/modules/core/entity"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/constant"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,7 +1,7 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
models2 "cutego/core/entity"
|
||||
models2 "cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/config"
|
||||
"cutego/pkg/constant"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/go-xorm/xorm"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,7 +1,7 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
models2 "cutego/core/entity"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@ type RoleMenuDao struct {
|
|||
}
|
||||
|
||||
// Insert 添加角色菜单关系
|
||||
func (d RoleMenuDao) Insert(list []models2.SysRoleMenu) int64 {
|
||||
func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 {
|
||||
session := SqlDB.NewSession()
|
||||
session.Begin()
|
||||
insert, err := session.Insert(&list)
|
||||
|
@ -22,8 +22,8 @@ func (d RoleMenuDao) Insert(list []models2.SysRoleMenu) int64 {
|
|||
}
|
||||
|
||||
// Delete 删除角色和菜单关系
|
||||
func (d RoleMenuDao) Delete(role models2.SysRole) {
|
||||
menu := models2.SysRoleMenu{
|
||||
func (d RoleMenuDao) Delete(role entity.SysRole) {
|
||||
menu := entity.SysRoleMenu{
|
||||
RoleId: role.RoleId,
|
||||
}
|
||||
session := SqlDB.NewSession()
|
|
@ -1,9 +1,9 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/page"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,7 +1,7 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
)
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package dao
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/common"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func LoadCoreRouter(v1Router *gin.RouterGroup) {
|
||||
// 登录接口
|
||||
initLoginRouter(v1Router)
|
||||
// 用户路由接口
|
||||
initUserRouter(v1Router)
|
||||
// 部门路由注册
|
||||
initDeptRouter(v1Router)
|
||||
// 初始化字典数据路由
|
||||
initDictDataRouter(v1Router)
|
||||
// 注册配置路由
|
||||
initConfigRouter(v1Router)
|
||||
// 注册角色路由
|
||||
initRoleRouter(v1Router)
|
||||
// 注册菜单路由
|
||||
initMenuRouter(v1Router)
|
||||
// 注册岗位路由
|
||||
initPostRouter(v1Router)
|
||||
// 注册字典类型路由
|
||||
initDictTypeRouter(v1Router)
|
||||
// 注册公告路由
|
||||
initNoticeRouter(v1Router)
|
||||
// 注册定时任务路由
|
||||
initCronJobRouter(v1Router)
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1"
|
||||
"cutego/modules/core/api/v1"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
cache2 "cutego/core/cache"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type ConfigService struct {
|
|
@ -1,9 +1,9 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type CronJobService struct {
|
|
@ -1,14 +1,14 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
dao2 "cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type DeptService struct {
|
||||
deptDao dao2.DeptDao
|
||||
roleDao dao2.RoleDao
|
||||
deptDao dao.DeptDao
|
||||
roleDao dao.RoleDao
|
||||
}
|
||||
|
||||
// TreeSelect 根据条件查询部门树
|
|
@ -1,10 +1,10 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
cache2 "cutego/core/cache"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/constant"
|
||||
)
|
||||
|
|
@ -1,39 +1,39 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
cache2 "cutego/core/cache"
|
||||
dao2 "cutego/core/dao"
|
||||
models2 "cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type DictTypeService struct {
|
||||
dictTypeDao dao2.DictTypeDao
|
||||
dictDataDao dao2.DictDataDao
|
||||
dictTypeDao dao.DictTypeDao
|
||||
dictDataDao dao.DictDataDao
|
||||
}
|
||||
|
||||
// FindPage 分页查询字典类型数据
|
||||
func (s DictTypeService) FindPage(query request.DictTypeQuery) (*[]models2.SysDictType, int64) {
|
||||
func (s DictTypeService) FindPage(query request.DictTypeQuery) (*[]entity.SysDictType, int64) {
|
||||
return s.dictTypeDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// GetById 根据id查询字典类型数据
|
||||
func (s DictTypeService) GetById(id int64) *models2.SysDictType {
|
||||
func (s DictTypeService) GetById(id int64) *entity.SysDictType {
|
||||
return s.dictTypeDao.SelectById(id)
|
||||
}
|
||||
|
||||
// CheckDictTypeUnique 检验字典类型是否存在
|
||||
func (s DictTypeService) CheckDictTypeUnique(dictType models2.SysDictType) bool {
|
||||
func (s DictTypeService) CheckDictTypeUnique(dictType entity.SysDictType) bool {
|
||||
return s.dictTypeDao.CheckDictTypeUnique(dictType) > 0
|
||||
}
|
||||
|
||||
// Edit 修改字典数据
|
||||
func (s DictTypeService) Edit(dictType models2.SysDictType) bool {
|
||||
func (s DictTypeService) Edit(dictType entity.SysDictType) bool {
|
||||
return s.dictTypeDao.Update(dictType)
|
||||
}
|
||||
|
||||
// Save 新增字典类型
|
||||
func (s DictTypeService) Save(dictType models2.SysDictType) bool {
|
||||
func (s DictTypeService) Save(dictType entity.SysDictType) bool {
|
||||
insert := s.dictTypeDao.Insert(dictType)
|
||||
if insert > 0 {
|
||||
cache2.SetRedisDict(dictType.DictType, nil)
|
||||
|
@ -47,7 +47,7 @@ func (s DictTypeService) Remove(ids []int64) bool {
|
|||
}
|
||||
|
||||
// FindAll 查询所有字典类型数据
|
||||
func (s DictTypeService) FindAll() []*models2.SysDictType {
|
||||
func (s DictTypeService) FindAll() []*entity.SysDictType {
|
||||
return s.dictTypeDao.SelectAll()
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (s DictTypeService) LoadDictCache() {
|
|||
}
|
||||
allData := s.dictDataDao.GetDiceDataAll()
|
||||
for _, key := range typeList {
|
||||
list := make([]models2.SysDictData, 0)
|
||||
list := make([]entity.SysDictData, 0)
|
||||
for _, data := range *allData {
|
||||
if key == data.DictType {
|
||||
list = append(list, data)
|
||||
|
@ -87,7 +87,7 @@ func (s DictTypeService) RefreshCache() {
|
|||
typeList := s.RemoveAllCache()
|
||||
allData := s.dictDataDao.GetDiceDataAll()
|
||||
for _, key := range typeList {
|
||||
list := make([]models2.SysDictData, 0)
|
||||
list := make([]entity.SysDictData, 0)
|
||||
for _, data := range *allData {
|
||||
if key == data.DictType {
|
||||
list = append(list, data)
|
|
@ -1,9 +1,9 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-basic/uuid"
|
||||
)
|
|
@ -1,9 +1,9 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/pkg/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/yinheli/qqwry"
|
|
@ -1,7 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/response"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/jwt"
|
||||
"github.com/druidcaesa/gotool"
|
|
@ -1,22 +1,22 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
dao2 "cutego/core/dao"
|
||||
models2 "cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type MenuService struct {
|
||||
menuDao dao2.MenuDao
|
||||
roleDao dao2.RoleDao
|
||||
menuDao dao.MenuDao
|
||||
roleDao dao.RoleDao
|
||||
}
|
||||
|
||||
// GetMenuTreeByUserId 根据用户ID查询菜单
|
||||
func (s MenuService) GetMenuTreeByUserId(user *response.UserResponse) *[]models2.SysMenu {
|
||||
var menuList *[]models2.SysMenu
|
||||
func (s MenuService) GetMenuTreeByUserId(user *response.UserResponse) *[]entity.SysMenu {
|
||||
var menuList *[]entity.SysMenu
|
||||
// 判断是否是管理员
|
||||
flag := models2.SysUser{}.IsAdmin(user.UserId)
|
||||
flag := entity.SysUser{}.IsAdmin(user.UserId)
|
||||
if flag {
|
||||
menuList = s.menuDao.GetMenuAll()
|
||||
} else {
|
||||
|
@ -32,7 +32,7 @@ func (s MenuService) FindMenuListByRoleId(id int64) *[]int64 {
|
|||
}
|
||||
|
||||
// GetMenuList 获取菜单列表
|
||||
func (s MenuService) FindMenuList(query request.MenuQuery, info *response.UserResponse) *[]models2.SysMenu {
|
||||
func (s MenuService) FindMenuList(query request.MenuQuery, info *response.UserResponse) *[]entity.SysMenu {
|
||||
if info.IsAdmin() {
|
||||
return s.menuDao.SelectMenuList(query)
|
||||
} else {
|
||||
|
@ -42,17 +42,17 @@ func (s MenuService) FindMenuList(query request.MenuQuery, info *response.UserRe
|
|||
}
|
||||
|
||||
// GetMenuByMenuId 根据菜单ID查询信息
|
||||
func (s MenuService) GetMenuByMenuId(id int) *models2.SysMenu {
|
||||
func (s MenuService) GetMenuByMenuId(id int) *entity.SysMenu {
|
||||
return s.menuDao.SelectMenuByMenuId(id)
|
||||
}
|
||||
|
||||
// Save 添加菜单数据
|
||||
func (s MenuService) Save(menu models2.SysMenu) int64 {
|
||||
func (s MenuService) Save(menu entity.SysMenu) int64 {
|
||||
return s.menuDao.Insert(menu)
|
||||
}
|
||||
|
||||
// Edit 修改菜单数据
|
||||
func (s MenuService) Edit(menu models2.SysMenu) int64 {
|
||||
func (s MenuService) Edit(menu entity.SysMenu) int64 {
|
||||
return s.menuDao.Update(menu)
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
type NoticeService struct {
|
|
@ -1,15 +1,15 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/response"
|
||||
dao2 "cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
||||
type PermissionService struct {
|
||||
roleDao dao2.RoleDao
|
||||
menuDao dao2.MenuDao
|
||||
roleDao dao.RoleDao
|
||||
menuDao dao.MenuDao
|
||||
}
|
||||
|
||||
// GetRolePermissionByUserId 查询用户角色集合
|
|
@ -2,9 +2,9 @@ package service
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/dao"
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
|
@ -2,20 +2,20 @@ package service
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
req2 "cutego/core/api/v1/request"
|
||||
dao2 "cutego/core/dao"
|
||||
models2 "cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
||||
type RoleService struct {
|
||||
roleDao dao2.RoleDao
|
||||
roleMenuDao dao2.RoleMenuDao
|
||||
userRoleDao dao2.UserRoleDao
|
||||
roleDao dao.RoleDao
|
||||
roleMenuDao dao.RoleMenuDao
|
||||
userRoleDao dao.UserRoleDao
|
||||
}
|
||||
|
||||
// FindAll 查询所有角色
|
||||
func (s RoleService) FindAll(query *req2.RoleQuery) ([]*models2.SysRole, int64) {
|
||||
func (s RoleService) FindAll(query *request.RoleQuery) ([]*entity.SysRole, int64) {
|
||||
if query == nil {
|
||||
all := s.roleDao.SelectAll()
|
||||
return all, 0
|
||||
|
@ -29,42 +29,42 @@ func (s RoleService) FindRoleListByUserId(parseInt int64) *[]int64 {
|
|||
}
|
||||
|
||||
// GetRoleListByUserId 根据用户ID查询角色
|
||||
func (s RoleService) GetRoleListByUserId(id int64) *[]models2.SysRole {
|
||||
func (s RoleService) GetRoleListByUserId(id int64) *[]entity.SysRole {
|
||||
return s.roleDao.GetRoleListByUserId(id)
|
||||
}
|
||||
|
||||
// FindPage 分页查询角色数据
|
||||
func (s RoleService) FindPage(query req2.RoleQuery) ([]*models2.SysRole, int64) {
|
||||
func (s RoleService) FindPage(query request.RoleQuery) ([]*entity.SysRole, int64) {
|
||||
return s.roleDao.SelectPage(&query)
|
||||
}
|
||||
|
||||
// GetRoleByRoleId 根据角色id查询角色数据
|
||||
func (s RoleService) GetRoleByRoleId(id int64) *models2.SysRole {
|
||||
func (s RoleService) GetRoleByRoleId(id int64) *entity.SysRole {
|
||||
return s.roleDao.SelectRoleByRoleId(id)
|
||||
}
|
||||
|
||||
// CheckRoleNameUnique 判断角色名城是否存在
|
||||
func (s RoleService) CheckRoleNameUnique(role models2.SysRole) int64 {
|
||||
func (s RoleService) CheckRoleNameUnique(role entity.SysRole) int64 {
|
||||
return s.roleDao.CheckRoleNameUnique(role)
|
||||
}
|
||||
|
||||
// CheckRoleKeyUnique 校验角色权限是否唯一
|
||||
func (s RoleService) CheckRoleKeyUnique(role models2.SysRole) int64 {
|
||||
func (s RoleService) CheckRoleKeyUnique(role entity.SysRole) int64 {
|
||||
return s.roleDao.CheckRoleKeyUnique(role)
|
||||
|
||||
}
|
||||
|
||||
// Save 添加角色数据
|
||||
func (s RoleService) Save(role models2.SysRole) int64 {
|
||||
func (s RoleService) Save(role entity.SysRole) int64 {
|
||||
role = s.roleDao.Insert(role)
|
||||
return s.BindRoleMenu(role)
|
||||
}
|
||||
|
||||
// 添加角色菜单关系
|
||||
func (s RoleService) BindRoleMenu(role models2.SysRole) int64 {
|
||||
list := make([]models2.SysRoleMenu, 0)
|
||||
func (s RoleService) BindRoleMenu(role entity.SysRole) int64 {
|
||||
list := make([]entity.SysRoleMenu, 0)
|
||||
for _, id := range role.MenuIds {
|
||||
menu := models2.SysRoleMenu{
|
||||
menu := entity.SysRoleMenu{
|
||||
RoleId: role.RoleId,
|
||||
MenuId: id,
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (s RoleService) BindRoleMenu(role models2.SysRole) int64 {
|
|||
}
|
||||
|
||||
// Edit 修改角色数据
|
||||
func (s RoleService) Edit(role models2.SysRole) int64 {
|
||||
func (s RoleService) Edit(role entity.SysRole) int64 {
|
||||
// 删除菜单关联关系
|
||||
s.roleMenuDao.Delete(role)
|
||||
s.BindRoleMenu(role)
|
||||
|
@ -84,7 +84,7 @@ func (s RoleService) Edit(role models2.SysRole) int64 {
|
|||
|
||||
// Remove 删除角色
|
||||
func (s RoleService) Remove(id int64) int64 {
|
||||
role := models2.SysRole{
|
||||
role := entity.SysRole{
|
||||
RoleId: id,
|
||||
}
|
||||
// 删除菜单角色关系
|
||||
|
@ -102,17 +102,17 @@ func (s RoleService) CheckRoleAllowed(id int64) (bool, string) {
|
|||
}
|
||||
|
||||
// EditRoleStatus 角色状态修改
|
||||
func (s RoleService) EditRoleStatus(role *models2.SysRole) int64 {
|
||||
func (s RoleService) EditRoleStatus(role *entity.SysRole) int64 {
|
||||
return s.roleDao.UpdateRoleStatus(role)
|
||||
}
|
||||
|
||||
// DeleteAuthUser 取消授权用户
|
||||
func (s RoleService) DeleteAuthUser(userRole models2.SysUserRole) int64 {
|
||||
func (s RoleService) DeleteAuthUser(userRole entity.SysUserRole) int64 {
|
||||
return s.userRoleDao.DeleteAuthUser(userRole)
|
||||
}
|
||||
|
||||
// InsertAuthUsers 批量选择用户授权
|
||||
func (s RoleService) InsertAuthUsers(body req2.UserRoleBody) int64 {
|
||||
func (s RoleService) InsertAuthUsers(body request.UserRoleBody) int64 {
|
||||
return s.userRoleDao.InsertAuthUsers(body)
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/dao"
|
||||
"cutego/modules/core/dao"
|
||||
)
|
||||
|
||||
type UserPostService struct {
|
|
@ -1,17 +1,17 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/request"
|
||||
"cutego/core/api/v1/response"
|
||||
dao2 "cutego/core/dao"
|
||||
models2 "cutego/core/entity"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
)
|
||||
|
||||
// UserService 用户操作业务逻辑
|
||||
type UserService struct {
|
||||
userDao dao2.UserDao
|
||||
userPostDao dao2.UserPostDao
|
||||
userRoleDao dao2.UserRoleDao
|
||||
userDao dao.UserDao
|
||||
userPostDao dao.UserPostDao
|
||||
userRoleDao dao.UserRoleDao
|
||||
}
|
||||
|
||||
// FindList 查询用户集合业务方法
|
||||
|
@ -25,19 +25,19 @@ func (s UserService) GetUserById(parseInt int64) *response.UserResponse {
|
|||
}
|
||||
|
||||
// GetUserByUserName 根据用户名查询用户
|
||||
func (s UserService) GetUserByUserName(name string) *models2.SysUser {
|
||||
user := models2.SysUser{}
|
||||
func (s UserService) GetUserByUserName(name string) *entity.SysUser {
|
||||
user := entity.SysUser{}
|
||||
user.UserName = name
|
||||
return s.userDao.GetUserByUserName(user)
|
||||
}
|
||||
|
||||
// CheckEmailUnique 校验邮箱是否存在
|
||||
func (s UserService) CheckEmailUnique(user request.UserBody) *models2.SysUser {
|
||||
func (s UserService) CheckEmailUnique(user request.UserBody) *entity.SysUser {
|
||||
return s.userDao.CheckEmailUnique(user)
|
||||
}
|
||||
|
||||
// CheckPhoneNumUnique 校验手机号是否存在
|
||||
func (s UserService) CheckPhoneNumUnique(body request.UserBody) *models2.SysUser {
|
||||
func (s UserService) CheckPhoneNumUnique(body request.UserBody) *entity.SysUser {
|
||||
return s.userDao.CheckPhoneNumUnique(body)
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ func (s UserService) Save(body request.UserBody) bool {
|
|||
func (s UserService) BindUserPost(user *request.UserBody) {
|
||||
postIds := user.PostIds
|
||||
if len(postIds) > 0 {
|
||||
sysUserPosts := make([]models2.SysUserPost, 0)
|
||||
sysUserPosts := make([]entity.SysUserPost, 0)
|
||||
for i := 0; i < len(postIds); i++ {
|
||||
m := models2.SysUserPost{
|
||||
m := entity.SysUserPost{
|
||||
UserId: user.UserId,
|
||||
PostId: postIds[i],
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ func (s UserService) BindUserPost(user *request.UserBody) {
|
|||
func (s UserService) BindUserRole(user *request.UserBody) {
|
||||
roleIds := user.RoleIds
|
||||
if len(roleIds) > 0 {
|
||||
roles := make([]models2.SysUserRole, 0)
|
||||
roles := make([]entity.SysUserRole, 0)
|
||||
for i := 0; i < len(roleIds); i++ {
|
||||
role := models2.SysUserRole{
|
||||
role := entity.SysUserRole{
|
||||
RoleId: roleIds[i],
|
||||
UserId: user.UserId,
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ func (s UserService) Remove(id int64) int64 {
|
|||
|
||||
// CheckUserAllowed 校验是否可以修改用户密码
|
||||
func (s UserService) CheckUserAllowed(body request.UserBody) bool {
|
||||
user := models2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
return user.IsAdmin(body.UserId)
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
router "cutego/modules/core/router"
|
||||
"cutego/pkg/filter"
|
||||
"cutego/pkg/jwt"
|
||||
"cutego/pkg/middleware"
|
||||
"cutego/pkg/middleware/logger"
|
||||
"cutego/pkg/websocket"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Init() *gin.Engine {
|
||||
ginInstance := gin.New()
|
||||
ginInstance.Use(gin.Logger())
|
||||
ginInstance.Use(gin.Recovery())
|
||||
ginInstance.Use(logger.LoggerToFile())
|
||||
ginInstance.Use(middleware.Recover)
|
||||
ginInstance.Use(jwt.JWTAuth())
|
||||
ginInstance.Use(filter.DemoHandler())
|
||||
// websocket
|
||||
ginInstance.GET("/websocket", websocket.HandleWebSocketMessage)
|
||||
// v1版本api
|
||||
v1Router := ginInstance.Group("/api/v1")
|
||||
// 加载: 模块路由
|
||||
router.LoadCoreRouter(v1Router)
|
||||
return ginInstance
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"cutego/core/dao"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/constant"
|
||||
)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package cronjob
|
||||
|
||||
import (
|
||||
"cutego/core/job"
|
||||
"cutego/core/service"
|
||||
"cutego/modules/core/job"
|
||||
"cutego/modules/core/service"
|
||||
"cutego/pkg/common"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package jwt
|
||||
|
||||
import (
|
||||
"cutego/core/api/v1/response"
|
||||
"cutego/core/dao"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/pkg/cache"
|
||||
"cutego/pkg/config"
|
||||
"errors"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package tree_dept
|
||||
|
||||
import (
|
||||
"cutego/core/entity"
|
||||
"cutego/modules/core/entity"
|
||||
"sort"
|
||||
)
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue