初始化
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysAccountPosition;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 用户-职位表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysAccountPositionService extends IService<SysAccountPosition> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysAccountRole;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 用户-角色表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysAccountRoleService extends IService<SysAccountRole> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysAccount;
|
||||
|
||||
/**
|
||||
* 用户表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysAccountService extends IService<SysAccount> {
|
||||
|
||||
void syncRelations(SysAccount entity);
|
||||
|
||||
SysAccount getByUsername(String userKey);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysApiKey;
|
||||
import tech.easyflow.system.entity.SysApiKeyResourceMapping;
|
||||
|
||||
/**
|
||||
* apikey-请求接口表 服务层。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-01
|
||||
*/
|
||||
public interface SysApiKeyResourceMappingService extends IService<SysApiKeyResourceMapping> {
|
||||
|
||||
void authInterface(SysApiKey entity);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysApiKeyResource;
|
||||
|
||||
/**
|
||||
* 请求接口表 服务层。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-01
|
||||
*/
|
||||
public interface SysApiKeyResourceService extends IService<SysApiKeyResource> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysApiKey;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-04-18
|
||||
*/
|
||||
public interface SysApiKeyService extends IService<SysApiKey> {
|
||||
|
||||
void checkApikeyPermission(String apiKey, String requestURI);
|
||||
|
||||
SysApiKey getSysApiKey(String apiKey);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysDept;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 部门表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysDeptService extends IService<SysDept> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysDictItem;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 数据字典内容 服务层。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-03
|
||||
*/
|
||||
public interface SysDictItemService extends IService<SysDictItem> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysDict;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 系统配置表 服务层。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-03
|
||||
*/
|
||||
public interface SysDictService extends IService<SysDict> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysLog;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 操作日志表 服务层。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-01-28
|
||||
*/
|
||||
public interface SysLogService extends IService<SysLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysMenu;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysMenuService extends IService<SysMenu> {
|
||||
|
||||
List<SysMenu> getMenusByAccountId(SysMenu entity, BigInteger accountId);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysOption;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 系统配置信息表。 服务层。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-13
|
||||
*/
|
||||
public interface SysOptionService extends IService<SysOption> {
|
||||
|
||||
SysOption getByOptionKey(String key);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysPosition;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 职位表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysPositionService extends IService<SysPosition> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysRoleDept;
|
||||
|
||||
/**
|
||||
* 角色-部门表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-11-19
|
||||
*/
|
||||
public interface SysRoleDeptService extends IService<SysRoleDept> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysRoleMenu;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 角色-菜单表 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysRoleMenuService extends IService<SysRoleMenu> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import tech.easyflow.system.entity.SysRole;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色 服务层。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
public interface SysRoleService extends IService<SysRole> {
|
||||
|
||||
void saveRoleMenu(BigInteger roleId, List<String> keys);
|
||||
|
||||
List<SysRole> getRolesByAccountId(BigInteger accountId);
|
||||
|
||||
void saveRole(SysRole sysRole);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tech.easyflow.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import tech.easyflow.system.entity.SysUserFeedback;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
public interface SysUserFeedbackService extends IService<SysUserFeedback> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysAccountPosition;
|
||||
import tech.easyflow.system.mapper.SysAccountPositionMapper;
|
||||
import tech.easyflow.system.service.SysAccountPositionService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 用户-职位表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysAccountPositionServiceImpl extends ServiceImpl<SysAccountPositionMapper, SysAccountPosition> implements SysAccountPositionService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysAccountRole;
|
||||
import tech.easyflow.system.mapper.SysAccountRoleMapper;
|
||||
import tech.easyflow.system.service.SysAccountRoleService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 用户-角色表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysAccountRoleServiceImpl extends ServiceImpl<SysAccountRoleMapper, SysAccountRole> implements SysAccountRoleService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.system.entity.SysAccount;
|
||||
import tech.easyflow.system.entity.SysAccountPosition;
|
||||
import tech.easyflow.system.entity.SysAccountRole;
|
||||
import tech.easyflow.system.mapper.SysAccountMapper;
|
||||
import tech.easyflow.system.mapper.SysAccountPositionMapper;
|
||||
import tech.easyflow.system.mapper.SysAccountRoleMapper;
|
||||
import tech.easyflow.system.mapper.SysRoleMapper;
|
||||
import tech.easyflow.system.service.SysAccountService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysAccountServiceImpl extends ServiceImpl<SysAccountMapper, SysAccount> implements SysAccountService {
|
||||
|
||||
@Resource
|
||||
private SysAccountRoleMapper sysAccountRoleMapper;
|
||||
@Resource
|
||||
private SysAccountPositionMapper sysAccountPositionMapper;
|
||||
@Resource
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Override
|
||||
public void syncRelations(SysAccount entity) {
|
||||
if (entity == null || entity.getId() == null) {
|
||||
return;
|
||||
}
|
||||
//sync roleIds
|
||||
List<BigInteger> roleIds = entity.getRoleIds();
|
||||
if (roleIds != null) {
|
||||
QueryWrapper delW = QueryWrapper.create();
|
||||
delW.eq(SysAccountRole::getAccountId, entity.getId());
|
||||
sysAccountRoleMapper.deleteByQuery(delW);
|
||||
if (!roleIds.isEmpty()) {
|
||||
List<SysAccountRole> rows = new ArrayList<>(roleIds.size());
|
||||
roleIds.forEach(roleId -> {
|
||||
SysAccountRole row = new SysAccountRole();
|
||||
row.setAccountId(entity.getId());
|
||||
row.setRoleId(roleId);
|
||||
rows.add(row);
|
||||
});
|
||||
sysAccountRoleMapper.insertBatch(rows);
|
||||
}
|
||||
}
|
||||
|
||||
//sync positionIds
|
||||
List<BigInteger> positionIds = entity.getPositionIds();
|
||||
if (positionIds != null) {
|
||||
QueryWrapper delW = QueryWrapper.create();
|
||||
delW.eq(SysAccountPosition::getAccountId, entity.getId());
|
||||
sysAccountPositionMapper.deleteByQuery(delW);
|
||||
if (!positionIds.isEmpty()) {
|
||||
List<SysAccountPosition> rows = new ArrayList<>(positionIds.size());
|
||||
positionIds.forEach(positionId -> {
|
||||
SysAccountPosition row = new SysAccountPosition();
|
||||
row.setAccountId(entity.getId());
|
||||
row.setPositionId(positionId);
|
||||
rows.add(row);
|
||||
});
|
||||
sysAccountPositionMapper.insertBatch(rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysAccount getByUsername(String userKey) {
|
||||
QueryWrapper w = QueryWrapper.create();
|
||||
w.eq(SysAccount::getLoginName, userKey);
|
||||
return getOne(w);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.system.entity.SysApiKey;
|
||||
import tech.easyflow.system.entity.SysApiKeyResourceMapping;
|
||||
import tech.easyflow.system.mapper.SysApiKeyResourceMappingMapper;
|
||||
import tech.easyflow.system.service.SysApiKeyResourceMappingService;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* apikey-请求接口表 服务层实现。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-01
|
||||
*/
|
||||
@Service
|
||||
public class SysApiKeyResourceMappingServiceImpl extends ServiceImpl<SysApiKeyResourceMappingMapper, SysApiKeyResourceMapping> implements SysApiKeyResourceMappingService {
|
||||
|
||||
/**
|
||||
* 批量授权apiKey接口
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void authInterface(SysApiKey entity) {
|
||||
this.remove(QueryWrapper.create().eq(SysApiKeyResourceMapping::getApiKeyId, entity.getId()));
|
||||
List<SysApiKeyResourceMapping> rows = new ArrayList<>(entity.getPermissionIds().size());
|
||||
BigInteger apiKeyId = entity.getId();
|
||||
for (BigInteger resourceId : entity.getPermissionIds()) {
|
||||
SysApiKeyResourceMapping sysApiKeyResourcePermissionRelationship = new SysApiKeyResourceMapping();
|
||||
sysApiKeyResourcePermissionRelationship.setApiKeyId(apiKeyId);
|
||||
sysApiKeyResourcePermissionRelationship.setApiKeyResourceId(resourceId);
|
||||
rows.add(sysApiKeyResourcePermissionRelationship);
|
||||
}
|
||||
this.saveBatch(rows);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.system.entity.SysApiKeyResource;
|
||||
import tech.easyflow.system.mapper.SysApiKeyResourceMapper;
|
||||
import tech.easyflow.system.service.SysApiKeyResourceService;
|
||||
|
||||
/**
|
||||
* 请求接口表 服务层实现。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-01
|
||||
*/
|
||||
@Service
|
||||
public class SysApiKeyResourceServiceImpl extends ServiceImpl<SysApiKeyResourceMapper, SysApiKeyResource> implements SysApiKeyResourceService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||
import tech.easyflow.system.entity.SysApiKey;
|
||||
import tech.easyflow.system.entity.SysApiKeyResource;
|
||||
import tech.easyflow.system.entity.SysApiKeyResourceMapping;
|
||||
import tech.easyflow.system.mapper.SysApiKeyMapper;
|
||||
import tech.easyflow.system.service.SysApiKeyResourceMappingService;
|
||||
import tech.easyflow.system.service.SysApiKeyResourceService;
|
||||
import tech.easyflow.system.service.SysApiKeyService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-04-18
|
||||
*/
|
||||
@Service
|
||||
public class SysApiKeyServiceImpl extends ServiceImpl<SysApiKeyMapper, SysApiKey> implements SysApiKeyService {
|
||||
|
||||
@Resource
|
||||
private SysApiKeyResourceMappingService mappingService;
|
||||
@Resource
|
||||
private SysApiKeyResourceService resourceService;
|
||||
|
||||
@Override
|
||||
public void checkApikeyPermission(String apiKey, String requestURI) {
|
||||
SysApiKey sysApiKey = getSysApiKey(apiKey);
|
||||
QueryWrapper w = QueryWrapper.create();
|
||||
w.eq(SysApiKeyResource::getRequestInterface, requestURI);
|
||||
SysApiKeyResource resource = resourceService.getOne(w);
|
||||
if (resource == null) {
|
||||
throw new BusinessException("该接口不存在");
|
||||
}
|
||||
QueryWrapper wm = QueryWrapper.create();
|
||||
wm.eq(SysApiKeyResourceMapping::getApiKeyId, sysApiKey.getId());
|
||||
wm.eq(SysApiKeyResourceMapping::getApiKeyResourceId, resource.getId());
|
||||
long count = mappingService.count(wm);
|
||||
if (count == 0) {
|
||||
throw new BusinessException("该apiKey无权限访问该接口");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysApiKey getSysApiKey(String apiKey) {
|
||||
QueryWrapper w = QueryWrapper.create();
|
||||
w.eq(SysApiKey::getApiKey, apiKey);
|
||||
SysApiKey one = getOne(w);
|
||||
if (one == null || one.getStatus() == 0) {
|
||||
throw new BusinessException("apiKey 不存在或已禁用");
|
||||
}
|
||||
if (one.getExpiredAt() != null && one.getExpiredAt().getTime() < new Date().getTime()) {
|
||||
throw new BusinessException("apiKey 已过期");
|
||||
}
|
||||
return one;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysDept;
|
||||
import tech.easyflow.system.mapper.SysDeptMapper;
|
||||
import tech.easyflow.system.service.SysDeptService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 部门表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysDictItem;
|
||||
import tech.easyflow.system.mapper.SysDictItemMapper;
|
||||
import tech.easyflow.system.service.SysDictItemService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据字典内容 服务层实现。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-03
|
||||
*/
|
||||
@Service
|
||||
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysDict;
|
||||
import tech.easyflow.system.mapper.SysDictMapper;
|
||||
import tech.easyflow.system.service.SysDictService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统配置表 服务层实现。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-03
|
||||
*/
|
||||
@Service
|
||||
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysLog;
|
||||
import tech.easyflow.system.mapper.SysLogMapper;
|
||||
import tech.easyflow.system.service.SysLogService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 操作日志表 服务层实现。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-01-28
|
||||
*/
|
||||
@Service
|
||||
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.common.util.SqlOperatorsUtil;
|
||||
import tech.easyflow.system.entity.*;
|
||||
import tech.easyflow.system.mapper.SysMenuMapper;
|
||||
import tech.easyflow.system.service.SysAccountRoleService;
|
||||
import tech.easyflow.system.service.SysMenuService;
|
||||
import tech.easyflow.system.service.SysRoleMenuService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.query.SqlOperators;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
|
||||
@Resource
|
||||
private SysRoleMenuService sysRoleMenuService;
|
||||
@Resource
|
||||
private SysAccountRoleService sysAccountRoleService;
|
||||
|
||||
@Override
|
||||
public List<SysMenu> getMenusByAccountId(SysMenu entity, BigInteger accountId) {
|
||||
// 查询用户对应角色id集合
|
||||
QueryWrapper am = QueryWrapper.create();
|
||||
am.eq(SysAccountRole::getAccountId, accountId);
|
||||
List<BigInteger> roleIds = sysAccountRoleService.list(am).stream().map(SysAccountRole::getRoleId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(roleIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 查询角色对应的菜单id集合
|
||||
QueryWrapper rm = QueryWrapper.create();
|
||||
rm.in(SysRoleMenu::getRoleId, roleIds);
|
||||
List<BigInteger> menuIds = sysRoleMenuService.list(rm).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(menuIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 查询当前用户拥有的菜单
|
||||
SqlOperators ops = SqlOperatorsUtil.build(SysMenu.class);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(entity, ops);
|
||||
queryWrapper.in(SysMenu::getId, menuIds);
|
||||
queryWrapper.orderBy("sort_no asc");
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import tech.easyflow.system.entity.SysOption;
|
||||
import tech.easyflow.system.mapper.SysOptionMapper;
|
||||
import tech.easyflow.system.service.SysOptionService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统配置信息表。 服务层实现。
|
||||
*
|
||||
* @author michael
|
||||
* @since 2024-03-13
|
||||
*/
|
||||
@Service
|
||||
public class SysOptionServiceImpl extends ServiceImpl<SysOptionMapper, SysOption> implements SysOptionService {
|
||||
|
||||
@Override
|
||||
public SysOption getByOptionKey(String key) {
|
||||
QueryWrapper w = QueryWrapper.create();
|
||||
w.eq(SysOption::getKey, key);
|
||||
return getOne(w);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysPosition;
|
||||
import tech.easyflow.system.mapper.SysPositionMapper;
|
||||
import tech.easyflow.system.service.SysPositionService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 职位表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPosition> implements SysPositionService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tech.easyflow.system.entity.SysRoleDept;
|
||||
import tech.easyflow.system.mapper.SysRoleDeptMapper;
|
||||
import tech.easyflow.system.service.SysRoleDeptService;
|
||||
|
||||
/**
|
||||
* 角色-部门表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-11-19
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleDeptServiceImpl extends ServiceImpl<SysRoleDeptMapper, SysRoleDept> implements SysRoleDeptService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import tech.easyflow.system.entity.SysRoleMenu;
|
||||
import tech.easyflow.system.mapper.SysRoleMenuMapper;
|
||||
import tech.easyflow.system.service.SysRoleMenuService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 角色-菜单表 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tech.easyflow.common.constant.enums.EnumDataScope;
|
||||
import tech.easyflow.system.entity.SysAccountRole;
|
||||
import tech.easyflow.system.entity.SysRole;
|
||||
import tech.easyflow.system.entity.SysRoleDept;
|
||||
import tech.easyflow.system.entity.SysRoleMenu;
|
||||
import tech.easyflow.system.mapper.SysRoleDeptMapper;
|
||||
import tech.easyflow.system.mapper.SysRoleMapper;
|
||||
import tech.easyflow.system.mapper.SysRoleMenuMapper;
|
||||
import tech.easyflow.system.service.SysAccountRoleService;
|
||||
import tech.easyflow.system.service.SysRoleService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统角色 服务层实现。
|
||||
*
|
||||
* @author ArkLight
|
||||
* @since 2025-03-14
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||
|
||||
@Resource
|
||||
private SysAccountRoleService sysAccountRoleService;
|
||||
@Resource
|
||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
||||
@Resource
|
||||
private SysRoleDeptMapper sysRoleDeptMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveRoleMenu(BigInteger roleId, List<String> keys) {
|
||||
|
||||
QueryWrapper delW = QueryWrapper.create();
|
||||
delW.eq(SysRoleMenu::getRoleId, roleId);
|
||||
sysRoleMenuMapper.deleteByQuery(delW);
|
||||
|
||||
List<SysRoleMenu> rows = new ArrayList<>(keys.size());
|
||||
keys.forEach(string -> {
|
||||
SysRoleMenu row = new SysRoleMenu();
|
||||
row.setRoleId(roleId);
|
||||
row.setMenuId(new BigInteger(string));
|
||||
rows.add(row);
|
||||
});
|
||||
sysRoleMenuMapper.insertBatch(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> getRolesByAccountId(BigInteger accountId) {
|
||||
// 查询用户对应角色id集合
|
||||
QueryWrapper am = QueryWrapper.create();
|
||||
am.eq(SysAccountRole::getAccountId, accountId);
|
||||
List<BigInteger> roleIds = sysAccountRoleService.list(am).stream().map(SysAccountRole::getRoleId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(roleIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return listByIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveRole(SysRole sysRole) {
|
||||
|
||||
saveOrUpdate(sysRole);
|
||||
|
||||
// 非自定义数据权限,则部门id集合为空
|
||||
if (!EnumDataScope.CUSTOM.getCode().equals(sysRole.getDataScope())) {
|
||||
sysRole.setDeptIds(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<BigInteger> menuIds = sysRole.getMenuIds();
|
||||
List<BigInteger> deptIds = sysRole.getDeptIds();
|
||||
|
||||
QueryWrapper wrm = QueryWrapper.create();
|
||||
wrm.eq(SysRoleMenu::getRoleId, sysRole.getId());
|
||||
sysRoleMenuMapper.deleteByQuery(wrm);
|
||||
QueryWrapper wrd = QueryWrapper.create();
|
||||
wrd.eq(SysRoleDept::getRoleId, sysRole.getId());
|
||||
sysRoleDeptMapper.deleteByQuery(wrd);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(menuIds)) {
|
||||
for (BigInteger menuId : menuIds) {
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(sysRole.getId());
|
||||
roleMenu.setMenuId(menuId);
|
||||
sysRoleMenuMapper.insert(roleMenu);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(deptIds)) {
|
||||
for (BigInteger deptId : deptIds) {
|
||||
SysRoleDept roleDept = new SysRoleDept();
|
||||
roleDept.setRoleId(sysRole.getId());
|
||||
roleDept.setDeptId(deptId);
|
||||
sysRoleDeptMapper.insert(roleDept);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tech.easyflow.system.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import tech.easyflow.system.entity.SysUserFeedback;
|
||||
import tech.easyflow.system.mapper.SysUserFeedbackMapper;
|
||||
import tech.easyflow.system.service.SysUserFeedbackService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author 12076
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
@Service
|
||||
public class SysUserFeedbackServiceImpl extends ServiceImpl<SysUserFeedbackMapper, SysUserFeedback> implements SysUserFeedbackService{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user