From 0f8c1f989bcd52ac0656b2b6ebcd16fed3cb64c9 Mon Sep 17 00:00:00 2001 From: tianjun Date: Wed, 18 Jan 2023 15:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=8F=98=E8=B7=AF=E7=94=B1=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=EF=BC=8C=E6=A8=A1=E5=9D=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++- core/api/v1/response/user_response.go | 41 ---------------- core/router/router.go | 49 ------------------- main.go | 9 ++-- {core => modules/core}/api/v1/config_api.go | 12 ++--- {core => modules/core}/api/v1/cron_job_api.go | 8 +-- {core => modules/core}/api/v1/dept_api.go | 6 +-- .../core}/api/v1/dict_data_api.go | 8 +-- .../core}/api/v1/dict_type_api.go | 10 ++-- {core => modules/core}/api/v1/login_api.go | 24 ++++----- {core => modules/core}/api/v1/menu_api.go | 6 +-- {core => modules/core}/api/v1/notice_api.go | 6 +-- {core => modules/core}/api/v1/post_api.go | 10 ++-- .../core}/api/v1/request/config_request.go | 0 .../core}/api/v1/request/cron_job_request.go | 0 .../core}/api/v1/request/dept_request.go | 0 .../core}/api/v1/request/dict_data_reqest.go | 0 .../core}/api/v1/request/dict_type_request.go | 0 .../core}/api/v1/request/log_request.go | 0 .../api/v1/request/login_info_request.go | 0 .../core}/api/v1/request/login_request.go | 0 .../core}/api/v1/request/menu_request.go | 0 .../core}/api/v1/request/notice_reqest.go | 0 .../core}/api/v1/request/post_request.go | 0 .../core}/api/v1/request/role_request.go | 0 .../core}/api/v1/request/user_request.go | 0 .../core}/api/v1/request/user_role_request.go | 0 .../api/v1/response/cron_job_response.go | 0 .../api/v1/response/dict_data_response.go | 0 modules/core/api/v1/response/user_response.go | 41 ++++++++++++++++ {core => modules/core}/api/v1/role_api.go | 28 +++++------ {core => modules/core}/api/v1/user_api.go | 24 ++++----- {core => modules/core}/cache/config_cache.go | 2 +- {core => modules/core}/cache/dict_cache.go | 2 +- {core => modules/core}/cache/online_cache.go | 0 {core => modules/core}/dao/config_dao.go | 4 +- {core => modules/core}/dao/cron_job_dao.go | 4 +- {core => modules/core}/dao/dept_dao.go | 4 +- {core => modules/core}/dao/dict_data_dao.go | 4 +- {core => modules/core}/dao/dict_type_dao.go | 4 +- {core => modules/core}/dao/index.go | 2 +- {core => modules/core}/dao/log_dao.go | 4 +- {core => modules/core}/dao/login_info_dao.go | 4 +- {core => modules/core}/dao/menu_dao.go | 4 +- {core => modules/core}/dao/notice_dao.go | 4 +- {core => modules/core}/dao/post_dao.go | 4 +- {core => modules/core}/dao/role_dao.go | 4 +- {core => modules/core}/dao/role_menu_dao.go | 8 +-- {core => modules/core}/dao/user_dao.go | 6 +-- {core => modules/core}/dao/user_post_dao.go | 2 +- {core => modules/core}/dao/user_role_dao.go | 4 +- {core => modules/core}/entity/sys_config.go | 0 {core => modules/core}/entity/sys_cron_job.go | 0 {core => modules/core}/entity/sys_dept.go | 0 .../core}/entity/sys_dict_data.go | 0 .../core}/entity/sys_dict_type.go | 0 {core => modules/core}/entity/sys_log.go | 0 .../core}/entity/sys_login_info.go | 0 {core => modules/core}/entity/sys_menu.go | 0 {core => modules/core}/entity/sys_notice.go | 0 {core => modules/core}/entity/sys_post.go | 0 {core => modules/core}/entity/sys_role.go | 0 .../core}/entity/sys_role_menu.go | 0 {core => modules/core}/entity/sys_user.go | 0 .../core}/entity/sys_user_post.go | 0 .../core}/entity/sys_user_role.go | 0 {core => modules/core}/job/index.go | 0 {core => modules/core}/job/test_job.go | 0 .../core}/router/config_router.go | 2 +- .../core}/router/cron_job_router.go | 2 +- {core => modules/core}/router/dept_router.go | 2 +- .../core}/router/dict_data_router.go | 2 +- .../core}/router/dict_type_router.go | 2 +- modules/core/router/index.go | 28 +++++++++++ {core => modules/core}/router/login_router.go | 2 +- {core => modules/core}/router/menu_router.go | 2 +- .../core}/router/notice_router.go | 2 +- {core => modules/core}/router/post_router.go | 2 +- {core => modules/core}/router/role_router.go | 2 +- {core => modules/core}/router/user_router.go | 2 +- .../core}/service/config_service.go | 8 +-- .../core}/service/cron_job_service.go | 6 +-- .../core}/service/dept_service.go | 10 ++-- .../core}/service/dict_data_service.go | 8 +-- .../core}/service/dict_type_service.go | 28 +++++------ {core => modules/core}/service/log_service.go | 6 +-- .../core}/service/login_info_service.go | 6 +-- .../core}/service/login_service.go | 2 +- .../core}/service/menu_service.go | 26 +++++----- .../core}/service/notice_service.go | 6 +-- .../core}/service/permission_service.go | 10 ++-- .../core}/service/post_service.go | 6 +-- .../core}/service/role_service.go | 42 ++++++++-------- .../core}/service/user_post_service.go | 2 +- .../core}/service/user_service.go | 32 ++++++------ modules/gin.go | 28 +++++++++++ pkg/cache/index.go | 2 +- pkg/cronjob/index.go | 4 +- pkg/jwt/jwt_handler.go | 4 +- pkg/tree/tree_dept/tree_dept.go | 2 +- pkg/tree/tree_menu/tree_menu.go | 2 +- pkg/util/token_util.go | 6 +-- 102 files changed, 335 insertions(+), 322 deletions(-) delete mode 100644 core/api/v1/response/user_response.go delete mode 100644 core/router/router.go rename {core => modules/core}/api/v1/config_api.go (94%) rename {core => modules/core}/api/v1/cron_job_api.go (94%) rename {core => modules/core}/api/v1/dept_api.go (97%) rename {core => modules/core}/api/v1/dict_data_api.go (95%) rename {core => modules/core}/api/v1/dict_type_api.go (94%) rename {core => modules/core}/api/v1/login_api.go (84%) rename {core => modules/core}/api/v1/menu_api.go (96%) rename {core => modules/core}/api/v1/notice_api.go (93%) rename {core => modules/core}/api/v1/post_api.go (94%) rename {core => modules/core}/api/v1/request/config_request.go (100%) rename {core => modules/core}/api/v1/request/cron_job_request.go (100%) rename {core => modules/core}/api/v1/request/dept_request.go (100%) rename {core => modules/core}/api/v1/request/dict_data_reqest.go (100%) rename {core => modules/core}/api/v1/request/dict_type_request.go (100%) rename {core => modules/core}/api/v1/request/log_request.go (100%) rename {core => modules/core}/api/v1/request/login_info_request.go (100%) rename {core => modules/core}/api/v1/request/login_request.go (100%) rename {core => modules/core}/api/v1/request/menu_request.go (100%) rename {core => modules/core}/api/v1/request/notice_reqest.go (100%) rename {core => modules/core}/api/v1/request/post_request.go (100%) rename {core => modules/core}/api/v1/request/role_request.go (100%) rename {core => modules/core}/api/v1/request/user_request.go (100%) rename {core => modules/core}/api/v1/request/user_role_request.go (100%) rename {core => modules/core}/api/v1/response/cron_job_response.go (100%) rename {core => modules/core}/api/v1/response/dict_data_response.go (100%) create mode 100644 modules/core/api/v1/response/user_response.go rename {core => modules/core}/api/v1/role_api.go (91%) rename {core => modules/core}/api/v1/user_api.go (95%) rename {core => modules/core}/cache/config_cache.go (95%) rename {core => modules/core}/cache/dict_cache.go (96%) rename {core => modules/core}/cache/online_cache.go (100%) rename {core => modules/core}/dao/config_dao.go (98%) rename {core => modules/core}/dao/cron_job_dao.go (97%) rename {core => modules/core}/dao/dept_dao.go (98%) rename {core => modules/core}/dao/dict_data_dao.go (98%) rename {core => modules/core}/dao/dict_type_dao.go (97%) rename {core => modules/core}/dao/index.go (98%) rename {core => modules/core}/dao/log_dao.go (94%) rename {core => modules/core}/dao/login_info_dao.go (93%) rename {core => modules/core}/dao/menu_dao.go (98%) rename {core => modules/core}/dao/notice_dao.go (96%) rename {core => modules/core}/dao/post_dao.go (98%) rename {core => modules/core}/dao/role_dao.go (98%) rename {core => modules/core}/dao/role_menu_dao.go (74%) rename {core => modules/core}/dao/user_dao.go (98%) rename {core => modules/core}/dao/user_post_dao.go (96%) rename {core => modules/core}/dao/user_role_dao.go (95%) rename {core => modules/core}/entity/sys_config.go (100%) rename {core => modules/core}/entity/sys_cron_job.go (100%) rename {core => modules/core}/entity/sys_dept.go (100%) rename {core => modules/core}/entity/sys_dict_data.go (100%) rename {core => modules/core}/entity/sys_dict_type.go (100%) rename {core => modules/core}/entity/sys_log.go (100%) rename {core => modules/core}/entity/sys_login_info.go (100%) rename {core => modules/core}/entity/sys_menu.go (100%) rename {core => modules/core}/entity/sys_notice.go (100%) rename {core => modules/core}/entity/sys_post.go (100%) rename {core => modules/core}/entity/sys_role.go (100%) rename {core => modules/core}/entity/sys_role_menu.go (100%) rename {core => modules/core}/entity/sys_user.go (100%) rename {core => modules/core}/entity/sys_user_post.go (100%) rename {core => modules/core}/entity/sys_user_role.go (100%) rename {core => modules/core}/job/index.go (100%) rename {core => modules/core}/job/test_job.go (100%) rename {core => modules/core}/router/config_router.go (95%) rename {core => modules/core}/router/cron_job_router.go (95%) rename {core => modules/core}/router/dept_router.go (96%) rename {core => modules/core}/router/dict_data_router.go (95%) rename {core => modules/core}/router/dict_type_router.go (95%) create mode 100644 modules/core/router/index.go rename {core => modules/core}/router/login_router.go (94%) rename {core => modules/core}/router/menu_router.go (95%) rename {core => modules/core}/router/notice_router.go (92%) rename {core => modules/core}/router/post_router.go (94%) rename {core => modules/core}/router/role_router.go (97%) rename {core => modules/core}/router/user_router.go (97%) rename {core => modules/core}/service/config_service.go (92%) rename {core => modules/core}/service/cron_job_service.go (91%) rename {core => modules/core}/service/dept_service.go (92%) rename {core => modules/core}/service/dict_data_service.go (93%) rename {core => modules/core}/service/dict_type_service.go (75%) rename {core => modules/core}/service/log_service.go (90%) rename {core => modules/core}/service/login_info_service.go (93%) rename {core => modules/core}/service/login_service.go (96%) rename {core => modules/core}/service/menu_service.go (69%) rename {core => modules/core}/service/notice_service.go (88%) rename {core => modules/core}/service/permission_service.go (89%) rename {core => modules/core}/service/post_service.go (95%) rename {core => modules/core}/service/role_service.go (68%) rename {core => modules/core}/service/user_post_service.go (91%) rename {core => modules/core}/service/user_service.go (85%) create mode 100644 modules/gin.go diff --git a/README.md b/README.md index 7e27880..59862e9 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/core/api/v1/response/user_response.go b/core/api/v1/response/user_response.go deleted file mode 100644 index a1a9563..0000000 --- a/core/api/v1/response/user_response.go +++ /dev/null @@ -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 -} diff --git a/core/router/router.go b/core/router/router.go deleted file mode 100644 index ba80e22..0000000 --- a/core/router/router.go +++ /dev/null @@ -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 -} diff --git a/main.go b/main.go index dc5679c..a3a16de 100644 --- a/main.go +++ b/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 { diff --git a/core/api/v1/config_api.go b/modules/core/api/v1/config_api.go similarity index 94% rename from core/api/v1/config_api.go rename to modules/core/api/v1/config_api.go index 2758b66..15b58cd 100644 --- a/core/api/v1/config_api.go +++ b/modules/core/api/v1/config_api.go @@ -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 根据参数键名查询参数值 diff --git a/core/api/v1/cron_job_api.go b/modules/core/api/v1/cron_job_api.go similarity index 94% rename from core/api/v1/cron_job_api.go rename to modules/core/api/v1/cron_job_api.go index 9089478..11823ec 100644 --- a/core/api/v1/cron_job_api.go +++ b/modules/core/api/v1/cron_job_api.go @@ -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" diff --git a/core/api/v1/dept_api.go b/modules/core/api/v1/dept_api.go similarity index 97% rename from core/api/v1/dept_api.go rename to modules/core/api/v1/dept_api.go index 22aec25..7e99c37 100644 --- a/core/api/v1/dept_api.go +++ b/modules/core/api/v1/dept_api.go @@ -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" diff --git a/core/api/v1/dict_data_api.go b/modules/core/api/v1/dict_data_api.go similarity index 95% rename from core/api/v1/dict_data_api.go rename to modules/core/api/v1/dict_data_api.go index e67b7cb..fea8aea 100644 --- a/core/api/v1/dict_data_api.go +++ b/modules/core/api/v1/dict_data_api.go @@ -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" diff --git a/core/api/v1/dict_type_api.go b/modules/core/api/v1/dict_type_api.go similarity index 94% rename from core/api/v1/dict_type_api.go rename to modules/core/api/v1/dict_type_api.go index 33ee8bb..ebdfe4b 100644 --- a/core/api/v1/dict_type_api.go +++ b/modules/core/api/v1/dict_type_api.go @@ -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 获取字典类型数据 diff --git a/core/api/v1/login_api.go b/modules/core/api/v1/login_api.go similarity index 84% rename from core/api/v1/login_api.go rename to modules/core/api/v1/login_api.go index 557dc3e..88a6c6d 100644 --- a/core/api/v1/login_api.go +++ b/modules/core/api/v1/login_api.go @@ -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) diff --git a/core/api/v1/menu_api.go b/modules/core/api/v1/menu_api.go similarity index 96% rename from core/api/v1/menu_api.go rename to modules/core/api/v1/menu_api.go index ce3c05f..b088d5e 100644 --- a/core/api/v1/menu_api.go +++ b/modules/core/api/v1/menu_api.go @@ -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" diff --git a/core/api/v1/notice_api.go b/modules/core/api/v1/notice_api.go similarity index 93% rename from core/api/v1/notice_api.go rename to modules/core/api/v1/notice_api.go index f0109b8..842fbd4 100644 --- a/core/api/v1/notice_api.go +++ b/modules/core/api/v1/notice_api.go @@ -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" diff --git a/core/api/v1/post_api.go b/modules/core/api/v1/post_api.go similarity index 94% rename from core/api/v1/post_api.go rename to modules/core/api/v1/post_api.go index bc598d9..15ec9ac 100644 --- a/core/api/v1/post_api.go +++ b/modules/core/api/v1/post_api.go @@ -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 查询刚问分页数据 diff --git a/core/api/v1/request/config_request.go b/modules/core/api/v1/request/config_request.go similarity index 100% rename from core/api/v1/request/config_request.go rename to modules/core/api/v1/request/config_request.go diff --git a/core/api/v1/request/cron_job_request.go b/modules/core/api/v1/request/cron_job_request.go similarity index 100% rename from core/api/v1/request/cron_job_request.go rename to modules/core/api/v1/request/cron_job_request.go diff --git a/core/api/v1/request/dept_request.go b/modules/core/api/v1/request/dept_request.go similarity index 100% rename from core/api/v1/request/dept_request.go rename to modules/core/api/v1/request/dept_request.go diff --git a/core/api/v1/request/dict_data_reqest.go b/modules/core/api/v1/request/dict_data_reqest.go similarity index 100% rename from core/api/v1/request/dict_data_reqest.go rename to modules/core/api/v1/request/dict_data_reqest.go diff --git a/core/api/v1/request/dict_type_request.go b/modules/core/api/v1/request/dict_type_request.go similarity index 100% rename from core/api/v1/request/dict_type_request.go rename to modules/core/api/v1/request/dict_type_request.go diff --git a/core/api/v1/request/log_request.go b/modules/core/api/v1/request/log_request.go similarity index 100% rename from core/api/v1/request/log_request.go rename to modules/core/api/v1/request/log_request.go diff --git a/core/api/v1/request/login_info_request.go b/modules/core/api/v1/request/login_info_request.go similarity index 100% rename from core/api/v1/request/login_info_request.go rename to modules/core/api/v1/request/login_info_request.go diff --git a/core/api/v1/request/login_request.go b/modules/core/api/v1/request/login_request.go similarity index 100% rename from core/api/v1/request/login_request.go rename to modules/core/api/v1/request/login_request.go diff --git a/core/api/v1/request/menu_request.go b/modules/core/api/v1/request/menu_request.go similarity index 100% rename from core/api/v1/request/menu_request.go rename to modules/core/api/v1/request/menu_request.go diff --git a/core/api/v1/request/notice_reqest.go b/modules/core/api/v1/request/notice_reqest.go similarity index 100% rename from core/api/v1/request/notice_reqest.go rename to modules/core/api/v1/request/notice_reqest.go diff --git a/core/api/v1/request/post_request.go b/modules/core/api/v1/request/post_request.go similarity index 100% rename from core/api/v1/request/post_request.go rename to modules/core/api/v1/request/post_request.go diff --git a/core/api/v1/request/role_request.go b/modules/core/api/v1/request/role_request.go similarity index 100% rename from core/api/v1/request/role_request.go rename to modules/core/api/v1/request/role_request.go diff --git a/core/api/v1/request/user_request.go b/modules/core/api/v1/request/user_request.go similarity index 100% rename from core/api/v1/request/user_request.go rename to modules/core/api/v1/request/user_request.go diff --git a/core/api/v1/request/user_role_request.go b/modules/core/api/v1/request/user_role_request.go similarity index 100% rename from core/api/v1/request/user_role_request.go rename to modules/core/api/v1/request/user_role_request.go diff --git a/core/api/v1/response/cron_job_response.go b/modules/core/api/v1/response/cron_job_response.go similarity index 100% rename from core/api/v1/response/cron_job_response.go rename to modules/core/api/v1/response/cron_job_response.go diff --git a/core/api/v1/response/dict_data_response.go b/modules/core/api/v1/response/dict_data_response.go similarity index 100% rename from core/api/v1/response/dict_data_response.go rename to modules/core/api/v1/response/dict_data_response.go diff --git a/modules/core/api/v1/response/user_response.go b/modules/core/api/v1/response/user_response.go new file mode 100644 index 0000000..d143387 --- /dev/null +++ b/modules/core/api/v1/response/user_response.go @@ -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 +} diff --git a/core/api/v1/role_api.go b/modules/core/api/v1/role_api.go similarity index 91% rename from core/api/v1/role_api.go rename to modules/core/api/v1/role_api.go index 3f54b5c..4fdff5e 100644 --- a/core/api/v1/role_api.go +++ b/modules/core/api/v1/role_api.go @@ -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) diff --git a/core/api/v1/user_api.go b/modules/core/api/v1/user_api.go similarity index 95% rename from core/api/v1/user_api.go rename to modules/core/api/v1/user_api.go index ab9fb43..1344e70 100644 --- a/core/api/v1/user_api.go +++ b/modules/core/api/v1/user_api.go @@ -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) diff --git a/core/cache/config_cache.go b/modules/core/cache/config_cache.go similarity index 95% rename from core/cache/config_cache.go rename to modules/core/cache/config_cache.go index c58f64e..ab85eeb 100644 --- a/core/cache/config_cache.go +++ b/modules/core/cache/config_cache.go @@ -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" diff --git a/core/cache/dict_cache.go b/modules/core/cache/dict_cache.go similarity index 96% rename from core/cache/dict_cache.go rename to modules/core/cache/dict_cache.go index 2fe0665..d30eaf9 100644 --- a/core/cache/dict_cache.go +++ b/modules/core/cache/dict_cache.go @@ -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" diff --git a/core/cache/online_cache.go b/modules/core/cache/online_cache.go similarity index 100% rename from core/cache/online_cache.go rename to modules/core/cache/online_cache.go diff --git a/core/dao/config_dao.go b/modules/core/dao/config_dao.go similarity index 98% rename from core/dao/config_dao.go rename to modules/core/dao/config_dao.go index 1972b65..4b4f7b8 100644 --- a/core/dao/config_dao.go +++ b/modules/core/dao/config_dao.go @@ -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" diff --git a/core/dao/cron_job_dao.go b/modules/core/dao/cron_job_dao.go similarity index 97% rename from core/dao/cron_job_dao.go rename to modules/core/dao/cron_job_dao.go index 774a4fa..3879363 100644 --- a/core/dao/cron_job_dao.go +++ b/modules/core/dao/cron_job_dao.go @@ -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" diff --git a/core/dao/dept_dao.go b/modules/core/dao/dept_dao.go similarity index 98% rename from core/dao/dept_dao.go rename to modules/core/dao/dept_dao.go index 367b23e..2905214 100644 --- a/core/dao/dept_dao.go +++ b/modules/core/dao/dept_dao.go @@ -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" ) diff --git a/core/dao/dict_data_dao.go b/modules/core/dao/dict_data_dao.go similarity index 98% rename from core/dao/dict_data_dao.go rename to modules/core/dao/dict_data_dao.go index ae1a568..a7e0a60 100644 --- a/core/dao/dict_data_dao.go +++ b/modules/core/dao/dict_data_dao.go @@ -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" diff --git a/core/dao/dict_type_dao.go b/modules/core/dao/dict_type_dao.go similarity index 97% rename from core/dao/dict_type_dao.go rename to modules/core/dao/dict_type_dao.go index 96c713b..5299042 100644 --- a/core/dao/dict_type_dao.go +++ b/modules/core/dao/dict_type_dao.go @@ -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" diff --git a/core/dao/index.go b/modules/core/dao/index.go similarity index 98% rename from core/dao/index.go rename to modules/core/dao/index.go index a66f082..b07a744 100644 --- a/core/dao/index.go +++ b/modules/core/dao/index.go @@ -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" diff --git a/core/dao/log_dao.go b/modules/core/dao/log_dao.go similarity index 94% rename from core/dao/log_dao.go rename to modules/core/dao/log_dao.go index 4c04cc5..7f44a76 100644 --- a/core/dao/log_dao.go +++ b/modules/core/dao/log_dao.go @@ -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" diff --git a/core/dao/login_info_dao.go b/modules/core/dao/login_info_dao.go similarity index 93% rename from core/dao/login_info_dao.go rename to modules/core/dao/login_info_dao.go index c63e1cd..f29f923 100644 --- a/core/dao/login_info_dao.go +++ b/modules/core/dao/login_info_dao.go @@ -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" diff --git a/core/dao/menu_dao.go b/modules/core/dao/menu_dao.go similarity index 98% rename from core/dao/menu_dao.go rename to modules/core/dao/menu_dao.go index 01a2b9f..74dd040 100644 --- a/core/dao/menu_dao.go +++ b/modules/core/dao/menu_dao.go @@ -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" ) diff --git a/core/dao/notice_dao.go b/modules/core/dao/notice_dao.go similarity index 96% rename from core/dao/notice_dao.go rename to modules/core/dao/notice_dao.go index 3aef1ac..b2b9916 100644 --- a/core/dao/notice_dao.go +++ b/modules/core/dao/notice_dao.go @@ -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" diff --git a/core/dao/post_dao.go b/modules/core/dao/post_dao.go similarity index 98% rename from core/dao/post_dao.go rename to modules/core/dao/post_dao.go index af5ed36..7e94792 100644 --- a/core/dao/post_dao.go +++ b/modules/core/dao/post_dao.go @@ -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" diff --git a/core/dao/role_dao.go b/modules/core/dao/role_dao.go similarity index 98% rename from core/dao/role_dao.go rename to modules/core/dao/role_dao.go index 94fdc99..6a1d1b9 100644 --- a/core/dao/role_dao.go +++ b/modules/core/dao/role_dao.go @@ -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" diff --git a/core/dao/role_menu_dao.go b/modules/core/dao/role_menu_dao.go similarity index 74% rename from core/dao/role_menu_dao.go rename to modules/core/dao/role_menu_dao.go index fe799b5..d9e75eb 100644 --- a/core/dao/role_menu_dao.go +++ b/modules/core/dao/role_menu_dao.go @@ -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() diff --git a/core/dao/user_dao.go b/modules/core/dao/user_dao.go similarity index 98% rename from core/dao/user_dao.go rename to modules/core/dao/user_dao.go index 0ddae74..67d1c69 100644 --- a/core/dao/user_dao.go +++ b/modules/core/dao/user_dao.go @@ -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" diff --git a/core/dao/user_post_dao.go b/modules/core/dao/user_post_dao.go similarity index 96% rename from core/dao/user_post_dao.go rename to modules/core/dao/user_post_dao.go index 570935d..afff016 100644 --- a/core/dao/user_post_dao.go +++ b/modules/core/dao/user_post_dao.go @@ -1,7 +1,7 @@ package dao import ( - "cutego/core/entity" + "cutego/modules/core/entity" "cutego/pkg/common" ) diff --git a/core/dao/user_role_dao.go b/modules/core/dao/user_role_dao.go similarity index 95% rename from core/dao/user_role_dao.go rename to modules/core/dao/user_role_dao.go index dcd016f..cf5fc49 100644 --- a/core/dao/user_role_dao.go +++ b/modules/core/dao/user_role_dao.go @@ -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" ) diff --git a/core/entity/sys_config.go b/modules/core/entity/sys_config.go similarity index 100% rename from core/entity/sys_config.go rename to modules/core/entity/sys_config.go diff --git a/core/entity/sys_cron_job.go b/modules/core/entity/sys_cron_job.go similarity index 100% rename from core/entity/sys_cron_job.go rename to modules/core/entity/sys_cron_job.go diff --git a/core/entity/sys_dept.go b/modules/core/entity/sys_dept.go similarity index 100% rename from core/entity/sys_dept.go rename to modules/core/entity/sys_dept.go diff --git a/core/entity/sys_dict_data.go b/modules/core/entity/sys_dict_data.go similarity index 100% rename from core/entity/sys_dict_data.go rename to modules/core/entity/sys_dict_data.go diff --git a/core/entity/sys_dict_type.go b/modules/core/entity/sys_dict_type.go similarity index 100% rename from core/entity/sys_dict_type.go rename to modules/core/entity/sys_dict_type.go diff --git a/core/entity/sys_log.go b/modules/core/entity/sys_log.go similarity index 100% rename from core/entity/sys_log.go rename to modules/core/entity/sys_log.go diff --git a/core/entity/sys_login_info.go b/modules/core/entity/sys_login_info.go similarity index 100% rename from core/entity/sys_login_info.go rename to modules/core/entity/sys_login_info.go diff --git a/core/entity/sys_menu.go b/modules/core/entity/sys_menu.go similarity index 100% rename from core/entity/sys_menu.go rename to modules/core/entity/sys_menu.go diff --git a/core/entity/sys_notice.go b/modules/core/entity/sys_notice.go similarity index 100% rename from core/entity/sys_notice.go rename to modules/core/entity/sys_notice.go diff --git a/core/entity/sys_post.go b/modules/core/entity/sys_post.go similarity index 100% rename from core/entity/sys_post.go rename to modules/core/entity/sys_post.go diff --git a/core/entity/sys_role.go b/modules/core/entity/sys_role.go similarity index 100% rename from core/entity/sys_role.go rename to modules/core/entity/sys_role.go diff --git a/core/entity/sys_role_menu.go b/modules/core/entity/sys_role_menu.go similarity index 100% rename from core/entity/sys_role_menu.go rename to modules/core/entity/sys_role_menu.go diff --git a/core/entity/sys_user.go b/modules/core/entity/sys_user.go similarity index 100% rename from core/entity/sys_user.go rename to modules/core/entity/sys_user.go diff --git a/core/entity/sys_user_post.go b/modules/core/entity/sys_user_post.go similarity index 100% rename from core/entity/sys_user_post.go rename to modules/core/entity/sys_user_post.go diff --git a/core/entity/sys_user_role.go b/modules/core/entity/sys_user_role.go similarity index 100% rename from core/entity/sys_user_role.go rename to modules/core/entity/sys_user_role.go diff --git a/core/job/index.go b/modules/core/job/index.go similarity index 100% rename from core/job/index.go rename to modules/core/job/index.go diff --git a/core/job/test_job.go b/modules/core/job/test_job.go similarity index 100% rename from core/job/test_job.go rename to modules/core/job/test_job.go diff --git a/core/router/config_router.go b/modules/core/router/config_router.go similarity index 95% rename from core/router/config_router.go rename to modules/core/router/config_router.go index 0c953bb..a27a1ac 100644 --- a/core/router/config_router.go +++ b/modules/core/router/config_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/cron_job_router.go b/modules/core/router/cron_job_router.go similarity index 95% rename from core/router/cron_job_router.go rename to modules/core/router/cron_job_router.go index 652ed99..7cd9ee0 100644 --- a/core/router/cron_job_router.go +++ b/modules/core/router/cron_job_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/dept_router.go b/modules/core/router/dept_router.go similarity index 96% rename from core/router/dept_router.go rename to modules/core/router/dept_router.go index e80eee4..c79d5a0 100644 --- a/core/router/dept_router.go +++ b/modules/core/router/dept_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/dict_data_router.go b/modules/core/router/dict_data_router.go similarity index 95% rename from core/router/dict_data_router.go rename to modules/core/router/dict_data_router.go index d15af3d..d199f89 100644 --- a/core/router/dict_data_router.go +++ b/modules/core/router/dict_data_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/dict_type_router.go b/modules/core/router/dict_type_router.go similarity index 95% rename from core/router/dict_type_router.go rename to modules/core/router/dict_type_router.go index 925a85e..d11f015 100644 --- a/core/router/dict_type_router.go +++ b/modules/core/router/dict_type_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/modules/core/router/index.go b/modules/core/router/index.go new file mode 100644 index 0000000..d88fc33 --- /dev/null +++ b/modules/core/router/index.go @@ -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) +} diff --git a/core/router/login_router.go b/modules/core/router/login_router.go similarity index 94% rename from core/router/login_router.go rename to modules/core/router/login_router.go index 526fff8..1eb4b13 100644 --- a/core/router/login_router.go +++ b/modules/core/router/login_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/menu_router.go b/modules/core/router/menu_router.go similarity index 95% rename from core/router/menu_router.go rename to modules/core/router/menu_router.go index c3d1e2b..ad68f15 100644 --- a/core/router/menu_router.go +++ b/modules/core/router/menu_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/notice_router.go b/modules/core/router/notice_router.go similarity index 92% rename from core/router/notice_router.go rename to modules/core/router/notice_router.go index 9aeeb9d..b02e4d2 100644 --- a/core/router/notice_router.go +++ b/modules/core/router/notice_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/post_router.go b/modules/core/router/post_router.go similarity index 94% rename from core/router/post_router.go rename to modules/core/router/post_router.go index 937856b..70c17ff 100644 --- a/core/router/post_router.go +++ b/modules/core/router/post_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/role_router.go b/modules/core/router/role_router.go similarity index 97% rename from core/router/role_router.go rename to modules/core/router/role_router.go index 09cee43..2b5ab26 100644 --- a/core/router/role_router.go +++ b/modules/core/router/role_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/router/user_router.go b/modules/core/router/user_router.go similarity index 97% rename from core/router/user_router.go rename to modules/core/router/user_router.go index 9e587b2..28594f7 100644 --- a/core/router/user_router.go +++ b/modules/core/router/user_router.go @@ -1,7 +1,7 @@ package router import ( - "cutego/core/api/v1" + "cutego/modules/core/api/v1" "github.com/gin-gonic/gin" ) diff --git a/core/service/config_service.go b/modules/core/service/config_service.go similarity index 92% rename from core/service/config_service.go rename to modules/core/service/config_service.go index cbc2092..b713ec9 100644 --- a/core/service/config_service.go +++ b/modules/core/service/config_service.go @@ -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 { diff --git a/core/service/cron_job_service.go b/modules/core/service/cron_job_service.go similarity index 91% rename from core/service/cron_job_service.go rename to modules/core/service/cron_job_service.go index 0d12766..aa75303 100644 --- a/core/service/cron_job_service.go +++ b/modules/core/service/cron_job_service.go @@ -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 { diff --git a/core/service/dept_service.go b/modules/core/service/dept_service.go similarity index 92% rename from core/service/dept_service.go rename to modules/core/service/dept_service.go index 2c004c8..7edc392 100644 --- a/core/service/dept_service.go +++ b/modules/core/service/dept_service.go @@ -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 根据条件查询部门树 diff --git a/core/service/dict_data_service.go b/modules/core/service/dict_data_service.go similarity index 93% rename from core/service/dict_data_service.go rename to modules/core/service/dict_data_service.go index 6384759..eeeae00 100644 --- a/core/service/dict_data_service.go +++ b/modules/core/service/dict_data_service.go @@ -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" ) diff --git a/core/service/dict_type_service.go b/modules/core/service/dict_type_service.go similarity index 75% rename from core/service/dict_type_service.go rename to modules/core/service/dict_type_service.go index 4765944..f242da2 100644 --- a/core/service/dict_type_service.go +++ b/modules/core/service/dict_type_service.go @@ -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) diff --git a/core/service/log_service.go b/modules/core/service/log_service.go similarity index 90% rename from core/service/log_service.go rename to modules/core/service/log_service.go index 5bd5027..8a431d0 100644 --- a/core/service/log_service.go +++ b/modules/core/service/log_service.go @@ -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" ) diff --git a/core/service/login_info_service.go b/modules/core/service/login_info_service.go similarity index 93% rename from core/service/login_info_service.go rename to modules/core/service/login_info_service.go index 917466b..58bbf47 100644 --- a/core/service/login_info_service.go +++ b/modules/core/service/login_info_service.go @@ -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" diff --git a/core/service/login_service.go b/modules/core/service/login_service.go similarity index 96% rename from core/service/login_service.go rename to modules/core/service/login_service.go index 5be2c21..ce19c21 100644 --- a/core/service/login_service.go +++ b/modules/core/service/login_service.go @@ -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" diff --git a/core/service/menu_service.go b/modules/core/service/menu_service.go similarity index 69% rename from core/service/menu_service.go rename to modules/core/service/menu_service.go index 3be5224..301dafa 100644 --- a/core/service/menu_service.go +++ b/modules/core/service/menu_service.go @@ -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) } diff --git a/core/service/notice_service.go b/modules/core/service/notice_service.go similarity index 88% rename from core/service/notice_service.go rename to modules/core/service/notice_service.go index 0296dc9..becc900 100644 --- a/core/service/notice_service.go +++ b/modules/core/service/notice_service.go @@ -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 { diff --git a/core/service/permission_service.go b/modules/core/service/permission_service.go similarity index 89% rename from core/service/permission_service.go rename to modules/core/service/permission_service.go index afd4196..145c68e 100644 --- a/core/service/permission_service.go +++ b/modules/core/service/permission_service.go @@ -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 查询用户角色集合 diff --git a/core/service/post_service.go b/modules/core/service/post_service.go similarity index 95% rename from core/service/post_service.go rename to modules/core/service/post_service.go index 7be1560..4a1bcf9 100644 --- a/core/service/post_service.go +++ b/modules/core/service/post_service.go @@ -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" ) diff --git a/core/service/role_service.go b/modules/core/service/role_service.go similarity index 68% rename from core/service/role_service.go rename to modules/core/service/role_service.go index ecbb090..8bb9c87 100644 --- a/core/service/role_service.go +++ b/modules/core/service/role_service.go @@ -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) } diff --git a/core/service/user_post_service.go b/modules/core/service/user_post_service.go similarity index 91% rename from core/service/user_post_service.go rename to modules/core/service/user_post_service.go index f108343..e318a89 100644 --- a/core/service/user_post_service.go +++ b/modules/core/service/user_post_service.go @@ -1,7 +1,7 @@ package service import ( - "cutego/core/dao" + "cutego/modules/core/dao" ) type UserPostService struct { diff --git a/core/service/user_service.go b/modules/core/service/user_service.go similarity index 85% rename from core/service/user_service.go rename to modules/core/service/user_service.go index ec25c17..ecdbbaa 100644 --- a/core/service/user_service.go +++ b/modules/core/service/user_service.go @@ -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) } diff --git a/modules/gin.go b/modules/gin.go new file mode 100644 index 0000000..53db775 --- /dev/null +++ b/modules/gin.go @@ -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 +} diff --git a/pkg/cache/index.go b/pkg/cache/index.go index 0b5bdb0..9fab338 100644 --- a/pkg/cache/index.go +++ b/pkg/cache/index.go @@ -1,7 +1,7 @@ package cache import ( - "cutego/core/dao" + "cutego/modules/core/dao" "cutego/pkg/common" "cutego/pkg/constant" ) diff --git a/pkg/cronjob/index.go b/pkg/cronjob/index.go index dd00a0a..d4f1b27 100644 --- a/pkg/cronjob/index.go +++ b/pkg/cronjob/index.go @@ -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" ) diff --git a/pkg/jwt/jwt_handler.go b/pkg/jwt/jwt_handler.go index 3fa6a81..39d16a0 100644 --- a/pkg/jwt/jwt_handler.go +++ b/pkg/jwt/jwt_handler.go @@ -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" diff --git a/pkg/tree/tree_dept/tree_dept.go b/pkg/tree/tree_dept/tree_dept.go index 5779904..47d8289 100644 --- a/pkg/tree/tree_dept/tree_dept.go +++ b/pkg/tree/tree_dept/tree_dept.go @@ -1,7 +1,7 @@ package tree_dept import ( - "cutego/core/entity" + "cutego/modules/core/entity" "sort" ) diff --git a/pkg/tree/tree_menu/tree_menu.go b/pkg/tree/tree_menu/tree_menu.go index 68c12c8..3176d24 100644 --- a/pkg/tree/tree_menu/tree_menu.go +++ b/pkg/tree/tree_menu/tree_menu.go @@ -1,7 +1,7 @@ package tree_menu import ( - "cutego/core/entity" + "cutego/modules/core/entity" "github.com/druidcaesa/gotool" "sort" ) diff --git a/pkg/util/token_util.go b/pkg/util/token_util.go index 5f72dec..9964b75 100644 --- a/pkg/util/token_util.go +++ b/pkg/util/token_util.go @@ -1,9 +1,9 @@ package util import ( - "cutego/core/api/v1/response" - "cutego/core/dao" - "cutego/core/entity" + "cutego/modules/core/api/v1/response" + "cutego/modules/core/dao" + "cutego/modules/core/entity" "cutego/pkg/common" "cutego/pkg/config" "cutego/pkg/jwt"