调整xorm层级
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type ConfigService struct {
|
||||
@@ -12,7 +12,7 @@ type ConfigService struct {
|
||||
}
|
||||
|
||||
// GetConfigKey 根据键名查询参数配置信息
|
||||
func (s ConfigService) GetConfigKey(param string) *entity.SysConfig {
|
||||
func (s ConfigService) GetConfigKey(param string) *dataobject.SysConfig {
|
||||
// 从缓存中取出数据判断是否存在, 存在直接使用, 不存在就从数据库查询
|
||||
val := cache2.GetRedisConfig(param)
|
||||
if val != nil {
|
||||
@@ -24,27 +24,27 @@ func (s ConfigService) GetConfigKey(param string) *entity.SysConfig {
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s ConfigService) FindPage(query request.ConfigQuery) (*[]entity.SysConfig, int64) {
|
||||
func (s ConfigService) FindPage(query request.ConfigQuery) (*[]dataobject.SysConfig, int64) {
|
||||
return s.configDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// CheckConfigKeyUnique 校验是否存在
|
||||
func (s ConfigService) CheckConfigKeyUnique(config entity.SysConfig) bool {
|
||||
func (s ConfigService) CheckConfigKeyUnique(config dataobject.SysConfig) bool {
|
||||
return s.configDao.CheckConfigKeyUnique(config) > 0
|
||||
}
|
||||
|
||||
// Save 添加数据
|
||||
func (s ConfigService) Save(config entity.SysConfig) int64 {
|
||||
func (s ConfigService) Save(config dataobject.SysConfig) int64 {
|
||||
return s.configDao.Insert(config)
|
||||
}
|
||||
|
||||
// GetInfo 查询数据
|
||||
func (s ConfigService) GetInfo(id int64) *entity.SysConfig {
|
||||
func (s ConfigService) GetInfo(id int64) *dataobject.SysConfig {
|
||||
return s.configDao.SelectById(id)
|
||||
}
|
||||
|
||||
// Edit 修改数据
|
||||
func (s ConfigService) Edit(config entity.SysConfig) int64 {
|
||||
func (s ConfigService) Edit(config dataobject.SysConfig) int64 {
|
||||
return s.configDao.Update(config)
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ func (s ConfigService) Remove(list []int64) bool {
|
||||
}
|
||||
|
||||
// CheckConfigByIds 根据id集合查询
|
||||
func (s ConfigService) CheckConfigByIds(list []int64) *[]entity.SysConfig {
|
||||
func (s ConfigService) CheckConfigByIds(list []int64) *[]dataobject.SysConfig {
|
||||
return s.configDao.CheckConfigByIds(list)
|
||||
}
|
||||
|
||||
// FindAll 查询所有数据
|
||||
func (s ConfigService) FindAll() *[]entity.SysConfig {
|
||||
func (s ConfigService) FindAll() *[]dataobject.SysConfig {
|
||||
return s.configDao.SelectAll()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type CronJobService struct {
|
||||
@@ -11,27 +11,27 @@ type CronJobService struct {
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s CronJobService) FindPage(query request.CronJobQuery) ([]entity.SysCronJob, int64) {
|
||||
func (s CronJobService) FindPage(query request.CronJobQuery) ([]dataobject.SysCronJob, int64) {
|
||||
return s.cronJobDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加数据
|
||||
func (s CronJobService) Save(config entity.SysCronJob) int64 {
|
||||
func (s CronJobService) Save(config dataobject.SysCronJob) int64 {
|
||||
return s.cronJobDao.Insert(config)
|
||||
}
|
||||
|
||||
// GetInfo 查询数据
|
||||
func (s CronJobService) GetInfo(id int64) *entity.SysCronJob {
|
||||
func (s CronJobService) GetInfo(id int64) *dataobject.SysCronJob {
|
||||
return s.cronJobDao.SelectById(id)
|
||||
}
|
||||
|
||||
// GetInfoByAlias 查询数据
|
||||
func (s CronJobService) GetInfoByAlias(funcAlias string) *entity.SysCronJob {
|
||||
func (s CronJobService) GetInfoByAlias(funcAlias string) *dataobject.SysCronJob {
|
||||
return s.cronJobDao.SelectByFuncAlias(funcAlias)
|
||||
}
|
||||
|
||||
// Edit 修改数据
|
||||
func (s CronJobService) Edit(config entity.SysCronJob) int64 {
|
||||
func (s CronJobService) Edit(config dataobject.SysCronJob) int64 {
|
||||
return s.cronJobDao.Update(config)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ func (s CronJobService) Remove(list []int64) bool {
|
||||
}
|
||||
|
||||
// FindAll 查找所有
|
||||
func (s CronJobService) FindAll() ([]entity.SysCronJob, int) {
|
||||
func (s CronJobService) FindAll() ([]dataobject.SysCronJob, int) {
|
||||
return s.cronJobDao.SelectAll()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type DeptService struct {
|
||||
@@ -12,7 +12,7 @@ type DeptService struct {
|
||||
}
|
||||
|
||||
// TreeSelect 根据条件查询部门树
|
||||
func (s DeptService) FindTreeSelect(query request.DeptQuery) *[]entity.SysDept {
|
||||
func (s DeptService) FindTreeSelect(query request.DeptQuery) *[]dataobject.SysDept {
|
||||
treeSelect := s.deptDao.SelectTree(query)
|
||||
return treeSelect
|
||||
}
|
||||
@@ -24,22 +24,22 @@ func (s DeptService) FindDeptListByRoleId(id int64) *[]int64 {
|
||||
}
|
||||
|
||||
// FindDeptList 查询部门列表
|
||||
func (s DeptService) FindDeptList(query request.DeptQuery) *[]entity.SysDept {
|
||||
func (s DeptService) FindDeptList(query request.DeptQuery) *[]dataobject.SysDept {
|
||||
return s.deptDao.GetList(query)
|
||||
}
|
||||
|
||||
// GetDeptById 根据部门编号获取详细信息
|
||||
func (s DeptService) GetDeptById(id int) *entity.SysDept {
|
||||
func (s DeptService) GetDeptById(id int) *dataobject.SysDept {
|
||||
return s.deptDao.SelectDeptById(id)
|
||||
}
|
||||
|
||||
// Save 添加部门数据
|
||||
func (s DeptService) Save(dept entity.SysDept) int64 {
|
||||
func (s DeptService) Save(dept dataobject.SysDept) int64 {
|
||||
return s.deptDao.Insert(dept)
|
||||
}
|
||||
|
||||
// CheckDeptNameUnique 校验部门名称是否唯一
|
||||
func (s DeptService) CheckDeptNameUnique(dept entity.SysDept) bool {
|
||||
func (s DeptService) CheckDeptNameUnique(dept dataobject.SysDept) bool {
|
||||
if s.deptDao.CheckDeptNameUnique(dept) > 0 {
|
||||
return true
|
||||
}
|
||||
@@ -62,6 +62,6 @@ func (s DeptService) CheckDeptExistUser(id int) int64 {
|
||||
}
|
||||
|
||||
// 修改部门
|
||||
func (s DeptService) Edit(dept entity.SysDept) bool {
|
||||
func (s DeptService) Edit(dept dataobject.SysDept) bool {
|
||||
return s.deptDao.Update(dept) > 0
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/pkg/constant"
|
||||
)
|
||||
|
||||
@@ -13,11 +13,11 @@ type DictDataService struct {
|
||||
}
|
||||
|
||||
// FindByDictType 根据字典类型查询字典数据
|
||||
func (s DictDataService) FindByDictType(dictType string) []entity.SysDictData {
|
||||
func (s DictDataService) FindByDictType(dictType string) []dataobject.SysDictData {
|
||||
// 先从缓存中拉数据
|
||||
key := cache2.GetRedisDict(dictType)
|
||||
if key != nil {
|
||||
return key.([]entity.SysDictData)
|
||||
return key.([]dataobject.SysDictData)
|
||||
} else {
|
||||
// 缓存中为空, 从数据库中取数据
|
||||
return s.dictDataDao.SelectByDictType(dictType)
|
||||
@@ -25,21 +25,21 @@ func (s DictDataService) FindByDictType(dictType string) []entity.SysDictData {
|
||||
}
|
||||
|
||||
// FindPage 查询字段数据集合
|
||||
func (s DictDataService) FindPage(query request.DiceDataQuery) (*[]entity.SysDictData, int64) {
|
||||
func (s DictDataService) FindPage(query request.DiceDataQuery) (*[]dataobject.SysDictData, int64) {
|
||||
return s.dictDataDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// GetByCode 根据code查询字典数据
|
||||
// @Param code int64
|
||||
// @Return *entity.SysDictData
|
||||
func (s DictDataService) GetByCode(code int64) *entity.SysDictData {
|
||||
// @Return *dataobject.SysDictData
|
||||
func (s DictDataService) GetByCode(code int64) *dataobject.SysDictData {
|
||||
return s.dictDataDao.SelectByDictCode(code)
|
||||
}
|
||||
|
||||
// Save 新增字典数据
|
||||
// @Param data entity.SysDictData
|
||||
// @Param data dataobject.SysDictData
|
||||
// @Return bool
|
||||
func (s DictDataService) Save(data entity.SysDictData) bool {
|
||||
func (s DictDataService) Save(data dataobject.SysDictData) bool {
|
||||
insert := s.dictDataDao.Insert(data)
|
||||
if insert > 0 {
|
||||
// 刷新缓存数据
|
||||
@@ -65,12 +65,12 @@ func (s DictDataService) Remove(codes []int64) bool {
|
||||
|
||||
// GetNoCacheByType 根据字典类型查询字典数据
|
||||
// @Param dictType 字典类型
|
||||
// @Return []entity.SysDictData
|
||||
func (s DictDataService) GetNoCacheByType(dictType string) []entity.SysDictData {
|
||||
// @Return []dataobject.SysDictData
|
||||
func (s DictDataService) GetNoCacheByType(dictType string) []dataobject.SysDictData {
|
||||
return s.dictDataDao.SelectByDictType(constant.RedisConst{}.GetRedisDictKey() + dictType)
|
||||
}
|
||||
|
||||
// 修改字典数据
|
||||
func (s DictDataService) Edit(data entity.SysDictData) bool {
|
||||
func (s DictDataService) Edit(data dataobject.SysDictData) bool {
|
||||
return s.dictDataDao.Update(data)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
cache2 "cutego/modules/core/cache"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type DictTypeService struct {
|
||||
@@ -13,27 +13,27 @@ type DictTypeService struct {
|
||||
}
|
||||
|
||||
// FindPage 分页查询字典类型数据
|
||||
func (s DictTypeService) FindPage(query request.DictTypeQuery) (*[]entity.SysDictType, int64) {
|
||||
func (s DictTypeService) FindPage(query request.DictTypeQuery) (*[]dataobject.SysDictType, int64) {
|
||||
return s.dictTypeDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// GetById 根据id查询字典类型数据
|
||||
func (s DictTypeService) GetById(id int64) *entity.SysDictType {
|
||||
func (s DictTypeService) GetById(id int64) *dataobject.SysDictType {
|
||||
return s.dictTypeDao.SelectById(id)
|
||||
}
|
||||
|
||||
// CheckDictTypeUnique 检验字典类型是否存在
|
||||
func (s DictTypeService) CheckDictTypeUnique(dictType entity.SysDictType) bool {
|
||||
func (s DictTypeService) CheckDictTypeUnique(dictType dataobject.SysDictType) bool {
|
||||
return s.dictTypeDao.CheckDictTypeUnique(dictType) > 0
|
||||
}
|
||||
|
||||
// Edit 修改字典数据
|
||||
func (s DictTypeService) Edit(dictType entity.SysDictType) bool {
|
||||
func (s DictTypeService) Edit(dictType dataobject.SysDictType) bool {
|
||||
return s.dictTypeDao.Update(dictType)
|
||||
}
|
||||
|
||||
// Save 新增字典类型
|
||||
func (s DictTypeService) Save(dictType entity.SysDictType) bool {
|
||||
func (s DictTypeService) Save(dictType dataobject.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() []*entity.SysDictType {
|
||||
func (s DictTypeService) FindAll() []*dataobject.SysDictType {
|
||||
return s.dictTypeDao.SelectAll()
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (s DictTypeService) LoadDictCache() {
|
||||
}
|
||||
allData := s.dictDataDao.GetDiceDataAll()
|
||||
for _, key := range typeList {
|
||||
list := make([]entity.SysDictData, 0)
|
||||
list := make([]dataobject.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([]entity.SysDictData, 0)
|
||||
list := make([]dataobject.SysDictData, 0)
|
||||
for _, data := range *allData {
|
||||
if key == data.DictType {
|
||||
list = append(list, data)
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-basic/uuid"
|
||||
)
|
||||
@@ -16,12 +16,12 @@ type LogService struct {
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s LogService) FindPage(query request.LogQuery) ([]entity.SysLog, int64) {
|
||||
func (s LogService) FindPage(query request.LogQuery) ([]dataobject.SysLog, int64) {
|
||||
return s.logDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加数据
|
||||
func (s LogService) save(config entity.SysLog) int64 {
|
||||
func (s LogService) save(config dataobject.SysLog) int64 {
|
||||
return s.logDao.Insert(config)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (s LogService) LogToDB(c *gin.Context, content string) {
|
||||
uid = DEFAULT_UID_KEY
|
||||
}
|
||||
uidStr := uid.(string)
|
||||
s.save(entity.SysLog{Uid: uidStr, Content: content})
|
||||
s.save(dataobject.SysLog{Uid: uidStr, Content: content})
|
||||
}
|
||||
|
||||
// 开始记录日志前调用(只调用一次)
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"cutego/pkg/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/yinheli/qqwry"
|
||||
@@ -16,12 +16,12 @@ type LoginInfoService struct {
|
||||
}
|
||||
|
||||
// FindPage 分页查询数据
|
||||
func (s LoginInfoService) FindPage(query request.LoginInfoQuery) (*[]entity.SysLoginInfo, int64) {
|
||||
func (s LoginInfoService) FindPage(query request.LoginInfoQuery) (*[]dataobject.SysLoginInfo, int64) {
|
||||
return s.loginInfoDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加登录记录业务逻辑
|
||||
func (s LoginInfoService) Save(body entity.SysLoginInfo) bool {
|
||||
func (s LoginInfoService) Save(body dataobject.SysLoginInfo) bool {
|
||||
// 添加登录记录数据库操作
|
||||
user := s.loginInfoDao.Insert(body)
|
||||
if user != nil {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type MenuService struct {
|
||||
@@ -13,10 +13,10 @@ type MenuService struct {
|
||||
}
|
||||
|
||||
// GetMenuTreeByUserId 根据用户ID查询菜单
|
||||
func (s MenuService) GetMenuTreeByUserId(user *response.UserResponse) *[]entity.SysMenu {
|
||||
var menuList *[]entity.SysMenu
|
||||
func (s MenuService) GetMenuTreeByUserId(user *response.UserResponse) *[]dataobject.SysMenu {
|
||||
var menuList *[]dataobject.SysMenu
|
||||
// 判断是否是管理员
|
||||
flag := entity.SysUser{}.IsAdmin(user.UserId)
|
||||
flag := dataobject.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) *[]entity.SysMenu {
|
||||
func (s MenuService) FindMenuList(query request.MenuQuery, info *response.UserResponse) *[]dataobject.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) *entity.SysMenu {
|
||||
func (s MenuService) GetMenuByMenuId(id int) *dataobject.SysMenu {
|
||||
return s.menuDao.SelectMenuByMenuId(id)
|
||||
}
|
||||
|
||||
// Save 添加菜单数据
|
||||
func (s MenuService) Save(menu entity.SysMenu) int64 {
|
||||
func (s MenuService) Save(menu dataobject.SysMenu) int64 {
|
||||
return s.menuDao.Insert(menu)
|
||||
}
|
||||
|
||||
// Edit 修改菜单数据
|
||||
func (s MenuService) Edit(menu entity.SysMenu) int64 {
|
||||
func (s MenuService) Edit(menu dataobject.SysMenu) int64 {
|
||||
return s.menuDao.Update(menu)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
type NoticeService struct {
|
||||
@@ -11,12 +11,12 @@ type NoticeService struct {
|
||||
}
|
||||
|
||||
// FindPage 查询集合数据
|
||||
func (s NoticeService) FindPage(query request.NoticeQuery) (*[]entity.SysNotice, int64) {
|
||||
func (s NoticeService) FindPage(query request.NoticeQuery) (*[]dataobject.SysNotice, int64) {
|
||||
return s.noticeDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// Save 添加公告
|
||||
func (s NoticeService) Save(notice entity.SysNotice) bool {
|
||||
func (s NoticeService) Save(notice dataobject.SysNotice) bool {
|
||||
return s.noticeDao.Insert(notice) > 0
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ func (s NoticeService) Remove(list []int64) bool {
|
||||
}
|
||||
|
||||
// GetById 查询
|
||||
func (s NoticeService) GetById(id int64) *entity.SysNotice {
|
||||
func (s NoticeService) GetById(id int64) *dataobject.SysNotice {
|
||||
return s.noticeDao.SelectById(id)
|
||||
}
|
||||
|
||||
// Edit 修改
|
||||
func (s NoticeService) Edit(notice entity.SysNotice) bool {
|
||||
func (s NoticeService) Edit(notice dataobject.SysNotice) bool {
|
||||
return s.noticeDao.Update(notice) > 0
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ type PermissionService struct {
|
||||
|
||||
// GetRolePermissionByUserId 查询用户角色集合
|
||||
func (s PermissionService) GetRolePermissionByUserId(user *response.UserResponse) *[]string {
|
||||
admin := entity.SysUser{}.IsAdmin(user.UserId)
|
||||
admin := dataobject.SysUser{}.IsAdmin(user.UserId)
|
||||
roleKeys := s.roleDao.SelectRolePermissionByUserId(user.UserId)
|
||||
if admin && roleKeys != nil {
|
||||
*roleKeys = append(*roleKeys, "admin")
|
||||
@@ -25,7 +25,7 @@ func (s PermissionService) GetRolePermissionByUserId(user *response.UserResponse
|
||||
|
||||
// GetMenuPermission 获取菜单数据权限
|
||||
func (s PermissionService) GetMenuPermission(user *response.UserResponse) *[]string {
|
||||
flag := entity.SysUser{}.IsAdmin(user.UserId)
|
||||
flag := dataobject.SysUser{}.IsAdmin(user.UserId)
|
||||
// 查询菜单数据权限
|
||||
permission := s.menuDao.GetMenuPermission(user.UserId)
|
||||
if flag && permission != nil {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ type PostService struct {
|
||||
}
|
||||
|
||||
// FindAll 查询所有岗位业务方法
|
||||
func (s PostService) FindAll() []*entity.SysPost {
|
||||
func (s PostService) FindAll() []*dataobject.SysPost {
|
||||
return s.postDao.SelectAll()
|
||||
}
|
||||
|
||||
@@ -23,28 +23,28 @@ func (s PostService) FindPostListByUserId(userId int64) *[]int64 {
|
||||
}
|
||||
|
||||
// FindList 查询岗位分页列表
|
||||
func (s PostService) FindPage(query request.PostQuery) (*[]entity.SysPost, int64) {
|
||||
func (s PostService) FindPage(query request.PostQuery) (*[]dataobject.SysPost, int64) {
|
||||
return s.postDao.SelectPage(query)
|
||||
}
|
||||
|
||||
// CheckPostNameUnique 校验岗位名称是否存在
|
||||
func (s PostService) CheckPostNameUnique(post entity.SysPost) bool {
|
||||
func (s PostService) CheckPostNameUnique(post dataobject.SysPost) bool {
|
||||
return s.postDao.CheckPostNameUnique(post) > 0
|
||||
}
|
||||
|
||||
// CheckPostCodeUnique 校验岗位编码是否存在
|
||||
func (s PostService) CheckPostCodeUnique(post entity.SysPost) bool {
|
||||
func (s PostService) CheckPostCodeUnique(post dataobject.SysPost) bool {
|
||||
return s.postDao.CheckPostCodeUnique(post) > 0
|
||||
}
|
||||
|
||||
// Save 添加岗位数据
|
||||
func (s PostService) Save(post entity.SysPost) bool {
|
||||
func (s PostService) Save(post dataobject.SysPost) bool {
|
||||
return s.postDao.Insert(post) > 0
|
||||
}
|
||||
|
||||
// GetPostById 根据id查询岗位数据
|
||||
func (s PostService) GetPostById(id int64) *entity.SysPost {
|
||||
post := entity.SysPost{
|
||||
func (s PostService) GetPostById(id int64) *dataobject.SysPost {
|
||||
post := dataobject.SysPost{
|
||||
PostId: id,
|
||||
}
|
||||
return s.postDao.GetPostById(post)
|
||||
@@ -56,7 +56,7 @@ func (s PostService) Remove(ids []int64) bool {
|
||||
}
|
||||
|
||||
// Edit 修改岗位数据
|
||||
func (s PostService) Edit(post entity.SysPost) bool {
|
||||
func (s PostService) Edit(post dataobject.SysPost) bool {
|
||||
return s.postDao.Update(post)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
"github.com/druidcaesa/gotool"
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ type RoleService struct {
|
||||
}
|
||||
|
||||
// FindAll 查询所有角色
|
||||
func (s RoleService) FindAll(query *request.RoleQuery) ([]*entity.SysRole, int64) {
|
||||
func (s RoleService) FindAll(query *request.RoleQuery) ([]*dataobject.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) *[]entity.SysRole {
|
||||
func (s RoleService) GetRoleListByUserId(id int64) *[]dataobject.SysRole {
|
||||
return s.roleDao.GetRoleListByUserId(id)
|
||||
}
|
||||
|
||||
// FindPage 分页查询角色数据
|
||||
func (s RoleService) FindPage(query request.RoleQuery) ([]*entity.SysRole, int64) {
|
||||
func (s RoleService) FindPage(query request.RoleQuery) ([]*dataobject.SysRole, int64) {
|
||||
return s.roleDao.SelectPage(&query)
|
||||
}
|
||||
|
||||
// GetRoleByRoleId 根据角色id查询角色数据
|
||||
func (s RoleService) GetRoleByRoleId(id int64) *entity.SysRole {
|
||||
func (s RoleService) GetRoleByRoleId(id int64) *dataobject.SysRole {
|
||||
return s.roleDao.SelectRoleByRoleId(id)
|
||||
}
|
||||
|
||||
// CheckRoleNameUnique 判断角色名城是否存在
|
||||
func (s RoleService) CheckRoleNameUnique(role entity.SysRole) int64 {
|
||||
func (s RoleService) CheckRoleNameUnique(role dataobject.SysRole) int64 {
|
||||
return s.roleDao.CheckRoleNameUnique(role)
|
||||
}
|
||||
|
||||
// CheckRoleKeyUnique 校验角色权限是否唯一
|
||||
func (s RoleService) CheckRoleKeyUnique(role entity.SysRole) int64 {
|
||||
func (s RoleService) CheckRoleKeyUnique(role dataobject.SysRole) int64 {
|
||||
return s.roleDao.CheckRoleKeyUnique(role)
|
||||
|
||||
}
|
||||
|
||||
// Save 添加角色数据
|
||||
func (s RoleService) Save(role entity.SysRole) int64 {
|
||||
func (s RoleService) Save(role dataobject.SysRole) int64 {
|
||||
role = s.roleDao.Insert(role)
|
||||
return s.BindRoleMenu(role)
|
||||
}
|
||||
|
||||
// 添加角色菜单关系
|
||||
func (s RoleService) BindRoleMenu(role entity.SysRole) int64 {
|
||||
list := make([]entity.SysRoleMenu, 0)
|
||||
func (s RoleService) BindRoleMenu(role dataobject.SysRole) int64 {
|
||||
list := make([]dataobject.SysRoleMenu, 0)
|
||||
for _, id := range role.MenuIds {
|
||||
menu := entity.SysRoleMenu{
|
||||
menu := dataobject.SysRoleMenu{
|
||||
RoleId: role.RoleId,
|
||||
MenuId: id,
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func (s RoleService) BindRoleMenu(role entity.SysRole) int64 {
|
||||
}
|
||||
|
||||
// Edit 修改角色数据
|
||||
func (s RoleService) Edit(role entity.SysRole) int64 {
|
||||
func (s RoleService) Edit(role dataobject.SysRole) int64 {
|
||||
// 删除菜单关联关系
|
||||
s.roleMenuDao.Delete(role)
|
||||
s.BindRoleMenu(role)
|
||||
@@ -84,7 +84,7 @@ func (s RoleService) Edit(role entity.SysRole) int64 {
|
||||
|
||||
// Remove 删除角色
|
||||
func (s RoleService) Remove(id int64) int64 {
|
||||
role := entity.SysRole{
|
||||
role := dataobject.SysRole{
|
||||
RoleId: id,
|
||||
}
|
||||
// 删除菜单角色关系
|
||||
@@ -102,12 +102,12 @@ func (s RoleService) CheckRoleAllowed(id int64) (bool, string) {
|
||||
}
|
||||
|
||||
// EditRoleStatus 角色状态修改
|
||||
func (s RoleService) EditRoleStatus(role *entity.SysRole) int64 {
|
||||
func (s RoleService) EditRoleStatus(role *dataobject.SysRole) int64 {
|
||||
return s.roleDao.UpdateRoleStatus(role)
|
||||
}
|
||||
|
||||
// DeleteAuthUser 取消授权用户
|
||||
func (s RoleService) DeleteAuthUser(userRole entity.SysUserRole) int64 {
|
||||
func (s RoleService) DeleteAuthUser(userRole dataobject.SysUserRole) int64 {
|
||||
return s.userRoleDao.DeleteAuthUser(userRole)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"cutego/modules/core/api/v1/request"
|
||||
"cutego/modules/core/api/v1/response"
|
||||
"cutego/modules/core/dao"
|
||||
"cutego/modules/core/entity"
|
||||
"cutego/modules/core/dataobject"
|
||||
)
|
||||
|
||||
// UserService 用户操作业务逻辑
|
||||
@@ -25,19 +25,19 @@ func (s UserService) GetUserById(parseInt int64) *response.UserResponse {
|
||||
}
|
||||
|
||||
// GetUserByUserName 根据用户名查询用户
|
||||
func (s UserService) GetUserByUserName(name string) *entity.SysUser {
|
||||
user := entity.SysUser{}
|
||||
func (s UserService) GetUserByUserName(name string) *dataobject.SysUser {
|
||||
user := dataobject.SysUser{}
|
||||
user.UserName = name
|
||||
return s.userDao.GetUserByUserName(user)
|
||||
}
|
||||
|
||||
// CheckEmailUnique 校验邮箱是否存在
|
||||
func (s UserService) CheckEmailUnique(user request.UserBody) *entity.SysUser {
|
||||
func (s UserService) CheckEmailUnique(user request.UserBody) *dataobject.SysUser {
|
||||
return s.userDao.CheckEmailUnique(user)
|
||||
}
|
||||
|
||||
// CheckPhoneNumUnique 校验手机号是否存在
|
||||
func (s UserService) CheckPhoneNumUnique(body request.UserBody) *entity.SysUser {
|
||||
func (s UserService) CheckPhoneNumUnique(body request.UserBody) *dataobject.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([]entity.SysUserPost, 0)
|
||||
sysUserPosts := make([]dataobject.SysUserPost, 0)
|
||||
for i := 0; i < len(postIds); i++ {
|
||||
m := entity.SysUserPost{
|
||||
m := dataobject.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([]entity.SysUserRole, 0)
|
||||
roles := make([]dataobject.SysUserRole, 0)
|
||||
for i := 0; i < len(roleIds); i++ {
|
||||
role := entity.SysUserRole{
|
||||
role := dataobject.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 := entity.SysUser{}
|
||||
user := dataobject.SysUser{}
|
||||
return user.IsAdmin(body.UserId)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user