feat:更新引用包
parent
15b560a5f2
commit
252ced4d5f
|
@ -26,6 +26,11 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.common.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.security.Security;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 微信小程序工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class WeChatUtil {
|
||||
|
||||
public static String httpRequest(String requestUrl, String requestMethod, String output) {
|
||||
try {
|
||||
URL url = new URL(requestUrl);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod(requestMethod);
|
||||
if (null != output) {
|
||||
OutputStream outputStream = connection.getOutputStream();
|
||||
outputStream.write(output.getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.close();
|
||||
}
|
||||
// 从输入流读取返回内容
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||
String str;
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
buffer.append(str);
|
||||
}
|
||||
bufferedReader.close();
|
||||
inputStreamReader.close();
|
||||
inputStream.close();
|
||||
connection.disconnect();
|
||||
return buffer.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String decryptData(String encryptDataB64, String sessionKeyB64, String ivB64) {
|
||||
return new String(
|
||||
decryptOfDiyIv(
|
||||
Base64.decode(encryptDataB64),
|
||||
Base64.decode(sessionKeyB64),
|
||||
Base64.decode(ivB64)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static final String KEY_ALGORITHM = "AES";
|
||||
private static final String ALGORITHM_STR = "AES/CBC/PKCS7Padding";
|
||||
private static Key key;
|
||||
private static Cipher cipher;
|
||||
|
||||
private static void init(byte[] keyBytes) {
|
||||
// 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
|
||||
int base = 16;
|
||||
if (keyBytes.length % base != 0) {
|
||||
int groups = keyBytes.length / base + 1;
|
||||
byte[] temp = new byte[groups * base];
|
||||
Arrays.fill(temp, (byte) 0);
|
||||
System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
|
||||
keyBytes = temp;
|
||||
}
|
||||
// 初始化
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
// 转化成JAVA的密钥格式
|
||||
key = new SecretKeySpec(keyBytes, KEY_ALGORITHM);
|
||||
try {
|
||||
// 初始化cipher
|
||||
cipher = Cipher.getInstance(ALGORITHM_STR, "BC");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密方法
|
||||
*
|
||||
* @param encryptedData 要解密的字符串
|
||||
* @param keyBytes 解密密钥
|
||||
* @param ivs 自定义对称解密算法初始向量 iv
|
||||
* @return 解密后的字节数组
|
||||
*/
|
||||
private static byte[] decryptOfDiyIv(byte[] encryptedData, byte[] keyBytes, byte[] ivs) {
|
||||
byte[] encryptedText = null;
|
||||
init(keyBytes);
|
||||
try {
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(ivs));
|
||||
encryptedText = cipher.doFinal(encryptedData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return encryptedText;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.system.SysConfig;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import static cc.iotkit.data.model.QTbSysConfig.tbSysConfig;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
|
@ -20,8 +19,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
@ -30,10 +29,10 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
@Primary
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysConfigDataImpl implements ISysConfigData {
|
||||
|
||||
@Autowired
|
||||
private SysConfigRepository alertConfigRepository;
|
||||
private final SysConfigRepository alertConfigRepository;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: xw2sy@163.com
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
package cc.iotkit.common.satoken.utils;
|
||||
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.utils.CodecUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AuthUtil {
|
||||
|
||||
public static String getUserId() {
|
||||
return StpUtil.getLoginId().toString();
|
||||
}
|
||||
|
||||
public static List<String> getUserRoles() {
|
||||
return StpUtil.getRoleList();
|
||||
}
|
||||
|
||||
public static boolean isAdmin() {
|
||||
return AuthUtil.getUserRoles().contains(Constants.ROLE_ADMIN);
|
||||
}
|
||||
|
||||
public static boolean isClientUser() {
|
||||
return AuthUtil.getUserRoles().contains(Constants.ROLE_CLIENT);
|
||||
}
|
||||
|
||||
public static boolean hasWriteRole() {
|
||||
return AuthUtil.getUserRoles().contains(Constants.ROLE_WRITE);
|
||||
}
|
||||
|
||||
public static String enCryptPwd(String pwd) throws Exception {
|
||||
return CodecUtil.aesEncrypt(CodecUtil.md5Str(pwd) + ":"
|
||||
+ RandomUtils.nextInt(1000, 9999), Constants.ACCOUNT_SECRET);
|
||||
}
|
||||
|
||||
public static boolean checkPwd(String pwd, String secret) throws Exception {
|
||||
String code = CodecUtil.aesDecrypt(secret, Constants.ACCOUNT_SECRET);
|
||||
String[] arr = code.split(":");
|
||||
return arr.length > 0 && CodecUtil.md5Str(pwd).equals(arr[0]);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,11 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
|
@ -98,6 +103,10 @@
|
|||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-doc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-satoken</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -9,13 +9,21 @@
|
|||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.DeviceUtil;
|
||||
import cc.iotkit.common.utils.ReflectUtil;
|
||||
import cc.iotkit.common.utils.UniqueIdUtil;
|
||||
import cc.iotkit.comps.service.DeviceBehaviourService;
|
||||
import cc.iotkit.data.manager.IDeviceConfigData;
|
||||
import cc.iotkit.data.manager.IDeviceGroupData;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
import cc.iotkit.manager.model.query.DeviceQuery;
|
||||
import cc.iotkit.manager.service.DataOwnerService;
|
||||
import cc.iotkit.manager.service.DeferredDataConsumer;
|
||||
import cc.iotkit.manager.service.DeviceService;
|
||||
import cc.iotkit.model.InvokeResult;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
|
@ -37,6 +45,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -11,6 +11,7 @@ package cc.iotkit.manager.controller;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.JsonUtils;
|
||||
import cc.iotkit.data.manager.ICategoryData;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
|
@ -24,7 +25,6 @@ import cc.iotkit.model.product.Product;
|
|||
import cc.iotkit.model.product.ProductModel;
|
||||
import cc.iotkit.model.product.ThingModel;
|
||||
import cc.iotkit.temporal.IDbStructureData;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
|
@ -34,6 +34,7 @@ import lombok.SneakyThrows;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
|
@ -11,6 +11,7 @@ package cc.iotkit.manager.controller;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.ReflectUtil;
|
||||
import cc.iotkit.comps.ComponentManager;
|
||||
import cc.iotkit.comps.config.ComponentConfig;
|
||||
|
@ -21,12 +22,12 @@ import cc.iotkit.manager.service.DataOwnerService;
|
|||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.model.protocol.ProtocolComponent;
|
||||
import cc.iotkit.model.protocol.ProtocolConverter;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -11,6 +11,7 @@ package cc.iotkit.manager.controller;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.ReflectUtil;
|
||||
import cc.iotkit.data.manager.IRuleInfoData;
|
||||
import cc.iotkit.data.manager.ITaskInfoData;
|
||||
|
@ -24,12 +25,12 @@ import cc.iotkit.ruleengine.rule.RuleManager;
|
|||
import cc.iotkit.ruleengine.task.TaskManager;
|
||||
import cc.iotkit.temporal.IRuleLogData;
|
||||
import cc.iotkit.temporal.ITaskLogData;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -11,15 +11,16 @@ package cc.iotkit.manager.controller;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.data.manager.IHomeData;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
import cc.iotkit.manager.service.DataOwnerService;
|
||||
import cc.iotkit.model.space.Home;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.Constants;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.data.manager.*;
|
||||
import cc.iotkit.manager.model.vo.FindDeviceVo;
|
||||
import cc.iotkit.manager.model.vo.SpaceDeviceVo;
|
||||
import cc.iotkit.manager.service.DataOwnerService;
|
||||
|
@ -22,11 +24,11 @@ import cc.iotkit.model.product.Product;
|
|||
import cc.iotkit.model.space.Home;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import cc.iotkit.model.space.SpaceDevice;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.data.manager.ICategoryData;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
import cc.iotkit.manager.model.stats.MainStats;
|
||||
import cc.iotkit.temporal.IThingModelMessageData;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.Constants;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.ReflectUtil;
|
||||
import cc.iotkit.data.manager.IHomeData;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
|
@ -20,10 +21,10 @@ import cc.iotkit.manager.service.DataOwnerService;
|
|||
import cc.iotkit.model.UserInfo;
|
||||
import cc.iotkit.model.space.Home;
|
||||
import cc.iotkit.model.space.Space;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
|
@ -11,6 +11,7 @@ package cc.iotkit.manager.controller;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.common.utils.ReflectUtil;
|
||||
import cc.iotkit.data.manager.IVirtualDeviceData;
|
||||
import cc.iotkit.manager.service.DataOwnerService;
|
||||
|
@ -18,11 +19,11 @@ import cc.iotkit.common.api.Paging;
|
|||
import cc.iotkit.model.device.VirtualDevice;
|
||||
import cc.iotkit.model.device.VirtualDeviceLog;
|
||||
import cc.iotkit.temporal.IVirtualDeviceLogData;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import cc.iotkit.virtualdevice.VirtualManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ package cc.iotkit.manager.service;
|
|||
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.AuthUtil;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.Owned;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.utils.AuthUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
package cc.iotkit.manager.service;
|
||||
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.utils.JsonUtils;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.mq.ConsumerHandler;
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
*/
|
||||
package cc.iotkit.manager.service;
|
||||
|
||||
import cc.iotkit.common.Constants;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.CodecUtil;
|
||||
import cc.iotkit.common.utils.JsonUtils;
|
||||
import cc.iotkit.common.utils.WeChatUtil;
|
||||
import cc.iotkit.data.manager.IUserInfoData;
|
||||
import cc.iotkit.manager.utils.WeChatUtil;
|
||||
import cc.iotkit.model.UserInfo;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package cc.iotkit.system.mapper;
|
||||
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.model.system.SysMenu;
|
||||
import cc.iotkit.system.dto.vo.SysMenuVo;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public interface ISysMenuService {
|
|||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteMenuById(Long menuId);
|
||||
void deleteMenuById(Long menuId);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface ISysNoticeService {
|
|||
* @param bo 公告信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertNotice(SysNoticeBo bo);
|
||||
Long insertNotice(SysNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
|
|
|
@ -5,15 +5,17 @@ import cc.iotkit.common.satoken.utils.LoginHelper;
|
|||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.common.utils.TreeBuildUtils;
|
||||
import cc.iotkit.data.system.ISysLogininforData;
|
||||
import cc.iotkit.data.system.ISysMenuData;
|
||||
import cc.iotkit.model.system.SysMenu;
|
||||
import cc.iotkit.model.system.SysRole;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
import cc.iotkit.system.dto.SysRoleMenu;
|
||||
import cc.iotkit.system.dto.bo.SysMenuBo;
|
||||
import cc.iotkit.system.dto.vo.MetaVo;
|
||||
import cc.iotkit.system.dto.vo.RouterVo;
|
||||
import cc.iotkit.system.dto.vo.SysMenuVo;
|
||||
import cc.iotkit.system.mapper.SysMenuMapper;
|
||||
import cc.iotkit.system.mapper.SysRoleMapper;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
|
@ -33,6 +35,8 @@ import java.util.*;
|
|||
@Service
|
||||
public class SysMenuServiceImpl implements ISysMenuService {
|
||||
|
||||
private final ISysMenuData iSysMenuData;
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
|
@ -56,19 +60,19 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
// 管理员显示所有菜单信息
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
} else {
|
||||
QueryWrapper<SysMenu> wrapper = Wrappers.query();
|
||||
wrapper.eq("sur.user_id", userId)
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
|
||||
.orderByAsc("m.parent_id")
|
||||
.orderByAsc("m.order_num");
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
|
||||
.orderByAsc("m.parent_id")
|
||||
.orderByAsc("m.order_num");
|
||||
List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper);
|
||||
menuList = MapstructUtils.convert(list, SysMenuVo.class);
|
||||
}
|
||||
|
@ -156,12 +160,12 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
List<Long> parentIds = null;
|
||||
if (tenantPackage.getMenuCheckStrictly()) {
|
||||
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getParentId)
|
||||
.in(SysMenu::getMenuId, menuIds), Convert::toLong);
|
||||
.select(SysMenu::getParentId)
|
||||
.in(SysMenu::getMenuId, menuIds), Convert::toLong);
|
||||
}
|
||||
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.in(SysMenu::getMenuId, menuIds)
|
||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), Convert::toLong);
|
||||
.in(SysMenu::getMenuId, menuIds)
|
||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), Convert::toLong);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,10 +231,10 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
return CollUtil.newArrayList();
|
||||
}
|
||||
return TreeBuildUtils.build(menus, (menu, tree) ->
|
||||
tree.setId(menu.getMenuId())
|
||||
.setParentId(menu.getParentId())
|
||||
.setName(menu.getMenuName())
|
||||
.setWeight(menu.getOrderNum()));
|
||||
tree.setId(menu.getMenuId())
|
||||
.setParentId(menu.getParentId())
|
||||
.setName(menu.getMenuName())
|
||||
.setWeight(menu.getOrderNum()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,8 +301,8 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMenuById(Long menuId) {
|
||||
return baseMapper.deleteById(menuId);
|
||||
public void deleteMenuById(Long menuId) {
|
||||
iSysMenuData.deleteById(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,9 +314,9 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
@Override
|
||||
public boolean checkMenuNameUnique(SysMenuBo menu) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
|
||||
return !exist;
|
||||
}
|
||||
|
||||
|
@ -340,11 +344,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
private void recursionFn(List<SysMenu> list, SysMenu t) {
|
||||
// 得到子节点列表
|
||||
List<SysMenu> childList = StreamUtils.filter(list, n -> n.getParentId().equals(t.getMenuId()));
|
||||
List<SysMenu> childList = StreamUtils.filter(list, n -> n.getParentId().equals(t.getId()));
|
||||
t.setChildren(childList);
|
||||
for (SysMenu tChild : childList) {
|
||||
// 判断是否有子节点
|
||||
if (list.stream().anyMatch(n -> n.getParentId().equals(tChild.getMenuId()))) {
|
||||
if (list.stream().anyMatch(n -> n.getParentId().equals(tChild.getId()))) {
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ package cc.iotkit.system.service.impl;
|
|||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.system.ISysNoticeData;
|
||||
import cc.iotkit.model.system.SysNotice;
|
||||
import cc.iotkit.system.dto.bo.SysNoticeBo;
|
||||
import cc.iotkit.system.dto.vo.SysNoticeVo;
|
||||
import cc.iotkit.system.dto.vo.SysUserVo;
|
||||
import cc.iotkit.system.mapper.SysUserMapper;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cc.iotkit.system.service.ISysNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -25,6 +25,8 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
|
||||
private ISysNoticeData iSysNoticeData;
|
||||
|
||||
@Override
|
||||
public Paging<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice);
|
||||
|
@ -73,9 +75,10 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertNotice(SysNoticeBo bo) {
|
||||
public Long insertNotice(SysNoticeBo bo) {
|
||||
SysNotice notice = MapstructUtils.convert(bo, SysNotice.class);
|
||||
return baseMapper.insert(notice);
|
||||
iSysNoticeData.save(notice);
|
||||
return notice.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue