提交了数据修改方法。
This commit is contained in:
parent
a270dcc366
commit
ad4391639e
@ -27,6 +27,7 @@
|
||||
综合考虑技术生态、团队能力和平台功能需求,初步考虑以下的技术组合:
|
||||
|
||||
- 前端:Vue + ElementUI + Mapbox GL(可结合已有GIS资源选择) + ECharts/AntV
|
||||
-- 前端库安装 yarn install
|
||||
- 后端:Spring Boot3.0 + PostgreSQL + PostGIS
|
||||
- 低代码支持:DataEase 开源二次开发
|
||||
- DevOps:Docker + Kubernetes
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.gisbi.application.baseinfo.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.assist.ISqlRunner;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.gisbi.application.baseinfo.domain.Application;
|
||||
@ -79,8 +80,8 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Appli
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean removeById(String id) {
|
||||
if (id == null || id.trim().isEmpty()) {
|
||||
this.removeById(id);
|
||||
if (StrUtil.isNotBlank(id)) {
|
||||
applicationMapper.deleteById(id);
|
||||
moduleService.deleteModulesByAppID(id);
|
||||
}
|
||||
return true;
|
||||
|
@ -1,10 +1,13 @@
|
||||
package io.gisbi.application.system.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.gisbi.application.system.domain.User;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.config.ResponseResult;
|
||||
import io.gisbi.utils.RsaUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -157,4 +160,23 @@ public class UserController {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public ResponseResult login(String username, String password) {
|
||||
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
|
||||
return ResponseResult.error("用户名称或者密码不能为空!");
|
||||
}
|
||||
// 根据用户名查询用户
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
User user = userService.getOne(queryWrapper.eq("username", username));
|
||||
if (ObjUtil.isEmpty( user)) {
|
||||
return ResponseResult.error(String.format("%s您输入的用户账号不存在!", username));
|
||||
}
|
||||
String encryptpass = RsaUtils.encryptStr( password);
|
||||
if(encryptpass.equals(user.getPassword())){
|
||||
return ResponseResult.successData(user);
|
||||
}else{
|
||||
return ResponseResult.error("您输入的密码错误!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import io.gisbi.application.system.mapper.RoleMapper;
|
||||
import io.gisbi.application.system.mapper.UserMapper;
|
||||
import io.gisbi.application.system.service.IUserService;
|
||||
import io.gisbi.utils.AuthUtils;
|
||||
import io.gisbi.utils.RsaUtils;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -63,10 +64,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
//返回信息
|
||||
Map<String, String> result = new HashMap<>();
|
||||
//普通用户
|
||||
// BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
// //设置缺省密码
|
||||
// String cryptPassword = passwordEncoder.encode("123456");
|
||||
user.setPassword(PASSWORD_VALID);
|
||||
//设置缺省密码
|
||||
String cryptPassword = RsaUtils.encryptStr(PASSWORD_VALID);
|
||||
user.setPassword(cryptPassword);
|
||||
//最近修改日期
|
||||
user.setLastmodifydate(LocalDateTime.now());
|
||||
//最近修改者
|
||||
@ -347,4 +347,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
"@codemirror/lang-sql": "^6.4.0",
|
||||
"@form-create/designer": "^3.2.11",
|
||||
"@form-create/element-ui": "^3.2.22",
|
||||
"@form-create/vant": "^3.2.25",
|
||||
"@monaco-editor/loader": "^1.5.0",
|
||||
"@npkg/tinymce-plugins": "^0.0.7",
|
||||
"@tinymce/tinymce-vue": "^5.1.0",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,9 +23,16 @@ import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* RSA加密工具类
|
||||
* 提供RSA密钥生成、加密、解密功能,以及AES对称加密相关功能
|
||||
*/
|
||||
@Component
|
||||
public class RsaUtils {
|
||||
|
||||
/**
|
||||
* 静态初始化块:添加Bouncy Castle安全提供者
|
||||
*/
|
||||
static {
|
||||
if (ObjectUtils.isNotEmpty(Security.getProvider("BC"))) {
|
||||
Security.removeProvider("BC");
|
||||
@ -47,6 +54,10 @@ public class RsaUtils {
|
||||
RsaUtils.rsaManage = rsaManage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成RSA密钥对
|
||||
* @return KeyPair对象,包含公钥和私钥
|
||||
*/
|
||||
private static KeyPair getKeyPair() {
|
||||
KeyPairGenerator generator = null;
|
||||
try {
|
||||
@ -85,6 +96,13 @@ public class RsaUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用公钥进行RSA加密
|
||||
* @param data 待加密数据
|
||||
* @param publicKey 公钥
|
||||
* @return 加密后的Base64编码字符串
|
||||
* @throws Exception 加密异常
|
||||
*/
|
||||
private static String encrypt(String data, PublicKey publicKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
@ -108,6 +126,13 @@ public class RsaUtils {
|
||||
return Base64.getEncoder().encodeToString(encryptedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用私钥进行RSA解密
|
||||
* @param data 待解密的Base64编码字符串
|
||||
* @param privateKey 私钥
|
||||
* @return 解密后的原始数据
|
||||
* @throws Exception 解密异常
|
||||
*/
|
||||
private static String decrypt(String data, PrivateKey privateKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
@ -131,6 +156,10 @@ public class RsaUtils {
|
||||
return out.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成RSA密钥对和AES密钥
|
||||
* @return RSAModel对象,包含公钥、私钥和AES密钥
|
||||
*/
|
||||
public static RSAModel generate() {
|
||||
KeyPair keyPair = getKeyPair();
|
||||
String privateKey = new String(Base64.getEncoder().encode(keyPair.getPrivate().getEncoded()));
|
||||
@ -164,6 +193,10 @@ public class RsaUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统存储的私钥
|
||||
* @return CoreRsa对象中的私钥字符串
|
||||
*/
|
||||
public static String privateKey() {
|
||||
CoreRsa coreRsa = rsaManage.query();
|
||||
return coreRsa.getPrivateKey();
|
||||
@ -204,11 +237,17 @@ public class RsaUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES对称加密算法参数
|
||||
*/
|
||||
private static final String ALGORITHM = "AES";
|
||||
public static String symmetricKey = null;
|
||||
private static final int KEY_SIZE = 128;
|
||||
|
||||
|
||||
/**
|
||||
* 生成AES对称加密密钥
|
||||
* @return Base64编码的密钥字符串
|
||||
*/
|
||||
public static String generateSymmetricKey() {
|
||||
try {
|
||||
if (StringUtils.isEmpty(symmetricKey)) {
|
||||
@ -223,6 +262,11 @@ public class RsaUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用AES对称密钥进行加密
|
||||
* @param data 待加密的数据
|
||||
* @return 加密后的Base64编码字符串
|
||||
*/
|
||||
public static String symmetricEncrypt(String data) {
|
||||
try {
|
||||
byte[] iv = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
@ -237,6 +281,11 @@ public class RsaUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用AES对称密钥进行解密
|
||||
* @param data 待解密的Base64编码字符串
|
||||
* @return 解密后的原始数据
|
||||
*/
|
||||
public static String symmetricDecrypt(String data) {
|
||||
try {
|
||||
byte[] iv = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
|
Loading…
Reference in New Issue
Block a user