From 689dd5088bc11cd8b2da58fb5ddad44e25281b32 Mon Sep 17 00:00:00 2001 From: zhouyuan <1069065057@qq.com> Date: Mon, 9 Aug 2021 16:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=AF=86=E5=AD=97=E6=AE=B5=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ApiUserController.java | 7 ++ .../com/ydool/boot/api/util/CodecUtils.java | 28 ++++---- .../boot/modules/rddb/mapper/TestMapper.java | 14 ++++ .../modules/rddb/service/TestService.java | 66 +++++++++++++++++++ .../rddb/web/ActivityAuditUserController.java | 5 +- .../modules/rddb/web/AuditUserController.java | 5 +- .../rddb/web/ConferenceUserController.java | 5 +- .../boot/modules/rddb/web/DbController.java | 10 +-- .../modules/rddb/web/OfficeController.java | 4 +- .../rddb/web/ReadFileUserController.java | 5 +- .../web/SuperviseThingUserController.java | 5 +- .../modules/rddb/web/VoterController.java | 7 +- .../rddb/web/VoterSuggestSolveController.java | 5 +- .../modules/rddb/web/WelcomeController.java | 12 ++++ src/main/resources/application.properties | 16 ++--- 15 files changed, 152 insertions(+), 42 deletions(-) create mode 100644 src/main/java/com/ydool/boot/modules/rddb/mapper/TestMapper.java create mode 100644 src/main/java/com/ydool/boot/modules/rddb/service/TestService.java diff --git a/src/main/java/com/ydool/boot/api/controller/ApiUserController.java b/src/main/java/com/ydool/boot/api/controller/ApiUserController.java index b778bb1..a113f98 100644 --- a/src/main/java/com/ydool/boot/api/controller/ApiUserController.java +++ b/src/main/java/com/ydool/boot/api/controller/ApiUserController.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.DynamicParameter; import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.api.util.Kv; import com.ydool.boot.common.Ydool; import com.ydool.boot.common.cache.ConfigUtils; @@ -200,4 +201,10 @@ public class ApiUserController extends ApiBaseController { renderJson(Ret.fail("该用户没有此身份")); } + public static void main(String[] args) throws Exception{ + String secretStr = CodecUtils.encrypt("admin"); + System.out.println(secretStr); + System.out.println(CodecUtils.decrypt(secretStr)); + } + } diff --git a/src/main/java/com/ydool/boot/api/util/CodecUtils.java b/src/main/java/com/ydool/boot/api/util/CodecUtils.java index 40814dc..a3a4b2e 100644 --- a/src/main/java/com/ydool/boot/api/util/CodecUtils.java +++ b/src/main/java/com/ydool/boot/api/util/CodecUtils.java @@ -1,8 +1,8 @@ package com.ydool.boot.api.util; import cn.hutool.core.util.StrUtil; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; +import sun.misc.BASE64Decoder; +import sun.misc.BASE64Encoder; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -22,13 +22,14 @@ public class CodecUtils { private static Cipher encryptCipher; // 加密cipher private static Cipher decryptChipher; // 解密chipher private static final String ENCODING = "UTF-8"; + public static final String KEY = "ydool123ydool123"; static { try { encryptCipher = Cipher.getInstance("AES"); decryptChipher = Cipher.getInstance("AES"); - encryptCipher.init(Cipher.ENCRYPT_MODE, generateAESKey("ydool", ENCODING)); - decryptChipher.init(Cipher.DECRYPT_MODE, generateAESKey("ydool", ENCODING)); + encryptCipher.init(Cipher.ENCRYPT_MODE, generateAESKey(KEY, ENCODING)); + decryptChipher.init(Cipher.DECRYPT_MODE, generateAESKey(KEY, ENCODING)); } catch (Exception e) { e.printStackTrace(); } @@ -36,11 +37,8 @@ public class CodecUtils { public static SecretKeySpec generateAESKey(final String key, final String encoding) { try { - final byte[] finalKey = new byte[16]; - int i = 0; - for (byte b : key.getBytes(encoding)) - finalKey[i++ % 16] ^= b; - return new SecretKeySpec(finalKey, "AES"); + byte[] raw = key.getBytes(encoding); + return new SecretKeySpec(raw, "AES"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } @@ -55,7 +53,7 @@ public class CodecUtils { public static String encrypt(String encryptString) { try { if (StrUtil.isBlank(encryptString)) return ""; - return new String(Hex.encodeHex(encryptCipher.doFinal(encryptString.getBytes(ENCODING)))).toUpperCase(); + return new BASE64Encoder().encode(encryptCipher.doFinal(encryptString.getBytes(ENCODING))); } catch (BadPaddingException e) { throw new RuntimeException(e); } catch (UnsupportedEncodingException e) { @@ -75,12 +73,10 @@ public class CodecUtils { if (StrUtil.isBlank(decryptString)) return ""; try { - return new String(decryptChipher.doFinal(Hex.decodeHex(decryptString.toCharArray()))); - } catch (DecoderException nspe) { - return decryptString; - } catch (BadPaddingException nsae) { - return decryptString; - } catch (IllegalBlockSizeException ike) { + byte[] encryptedByte = new BASE64Decoder().decodeBuffer(decryptString); + return new String(decryptChipher.doFinal(encryptedByte)); + } catch (Exception e) { + e.printStackTrace(); return decryptString; } } diff --git a/src/main/java/com/ydool/boot/modules/rddb/mapper/TestMapper.java b/src/main/java/com/ydool/boot/modules/rddb/mapper/TestMapper.java new file mode 100644 index 0000000..8a7ab73 --- /dev/null +++ b/src/main/java/com/ydool/boot/modules/rddb/mapper/TestMapper.java @@ -0,0 +1,14 @@ +package com.ydool.boot.modules.rddb.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ydool.boot.modules.sys.entity.User; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author zhujingang + * @date 2020/5/19 4:25 PM + */ +@Mapper +public interface TestMapper extends BaseMapper { + +} diff --git a/src/main/java/com/ydool/boot/modules/rddb/service/TestService.java b/src/main/java/com/ydool/boot/modules/rddb/service/TestService.java new file mode 100644 index 0000000..bc386fd --- /dev/null +++ b/src/main/java/com/ydool/boot/modules/rddb/service/TestService.java @@ -0,0 +1,66 @@ +package com.ydool.boot.modules.rddb.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ydool.boot.api.util.CodecUtils; +import com.ydool.boot.core.service.BaseService; +import com.ydool.boot.modules.rddb.entity.Db; +import com.ydool.boot.modules.rddb.entity.Office; +import com.ydool.boot.modules.rddb.mapper.TestMapper; +import com.ydool.boot.modules.sys.entity.User; +import com.ydool.boot.modules.sys.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + *

+ * 临时service + *

+ * + * @author zhouyuan + * @since 2021年08月09日10:07:42 + */ +@Service +public class TestService extends BaseService { + + @Autowired + private UserService userService; + @Autowired + private DbService dbService; + @Autowired + private OfficeService officeService; + + @Transactional + public void encrypt() { + List userList = userService.list(); + + List addUserList = new ArrayList<>(userList.size()); + List addDbList = new ArrayList<>(userList.size()); + List addOfficeList = new ArrayList<>(userList.size()); + userList.forEach(user -> { + user.setLoginName(CodecUtils.encrypt(user.getLoginName())); + user.setPhone(CodecUtils.encrypt(user.getPhone())); + addUserList.add(user); + + Db db = dbService.getOne(new LambdaQueryWrapper().eq(Db::getUserId, user.getId())); + if (db != null) { + db.setPhone(CodecUtils.encrypt(db.getPhone())); + addDbList.add(db); + } + + Office office = officeService.getOne(new LambdaQueryWrapper().eq(Office::getUserId, user.getId())); + if (office != null) { + office.setPhone(CodecUtils.encrypt(office.getPhone())); + addOfficeList.add(office); + } + }); + userService.updateBatchById(addUserList); + dbService.updateBatchById(addDbList); + officeService.updateBatchById(addOfficeList); + System.out.println("手机号加密完成"); + } + +} diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/ActivityAuditUserController.java b/src/main/java/com/ydool/boot/modules/rddb/web/ActivityAuditUserController.java index 9f5fad2..953f2c5 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/ActivityAuditUserController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/ActivityAuditUserController.java @@ -4,13 +4,14 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.core.web.BaseController; import com.ydool.boot.modules.rddb.entity.ActivityAuditUser; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.ActivityAuditUserService; import com.ydool.boot.modules.rddb.service.ActivityService; import com.ydool.boot.modules.rddb.wrapper.ActivityAuditUserWrapper; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; import org.springframework.stereotype.Controller; @@ -72,7 +73,7 @@ public class ActivityAuditUserController extends BaseController { //县级工作人员 userQueryWrapper.eq("account_type", "admin"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/AuditUserController.java b/src/main/java/com/ydool/boot/modules/rddb/web/AuditUserController.java index c80f6d3..1281c31 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/AuditUserController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/AuditUserController.java @@ -5,10 +5,11 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ydool.boot.api.controller.ApiBaseController; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.modules.rddb.entity.AuditUser; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.AuditUserService; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +65,7 @@ public class AuditUserController extends ApiBaseController { //县级工作人员审核 userQueryWrapper.eq("account_type", "admin"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/ConferenceUserController.java b/src/main/java/com/ydool/boot/modules/rddb/web/ConferenceUserController.java index 8ebcd77..df4a681 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/ConferenceUserController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/ConferenceUserController.java @@ -4,11 +4,12 @@ package com.ydool.boot.modules.rddb.web; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.core.web.BaseController; import com.ydool.boot.modules.rddb.entity.ConferenceUser; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.ConferenceUserService; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +65,7 @@ public class ConferenceUserController extends BaseController { //人大代表开会 userQueryWrapper.eq("account_type", "rddb"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/DbController.java b/src/main/java/com/ydool/boot/modules/rddb/web/DbController.java index cf5931d..87e521c 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/DbController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/DbController.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.excel.ImportDataListener; import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.utils.SpringUtils; @@ -80,7 +81,8 @@ public class DbController extends BaseAdminController { @PostMapping("/list") @ResponseBody public void list(DbVO dbVO) { - QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(), dbVO.getShowScreen()); + QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getSex(), dbVO.getShowScreen()); + qw.like(StrUtil.isNotBlank(dbVO.getPhone()),"AES_DECRYPT(from_base64 (phone),'"+ CodecUtils.KEY +"')",dbVO.getPhone()); IPage paged = dbService.page(new Page<>(getPageNum(), getPageSize()), qw); renderJson(Ret.ok().paged(DbWrapper.build().pageVO(paged))); } @@ -163,7 +165,8 @@ public class DbController extends BaseAdminController { @PostMapping("/export") @ResponseBody public void export(DbVO dbVO, String[] ids) { - QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(), dbVO.getShowScreen()); + QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getSex(), dbVO.getShowScreen()); + qw.like(StrUtil.isNotBlank(dbVO.getPhone()),"AES_DECRYPT(from_base64 (phone),'"+ CodecUtils.KEY +"')",dbVO.getPhone()); if (ArrayUtil.isNotEmpty(ids)) { qw.in("id", Arrays.asList(ids)); } @@ -193,10 +196,9 @@ public class DbController extends BaseAdminController { render(Ret.ok().data(officeList)); } - private QueryWrapper getQueryWrapper(String name, String phone, String sex, Integer showScreen) { + private QueryWrapper getQueryWrapper(String name, String sex, Integer showScreen) { QueryWrapper qw = new QueryWrapper<>(); Condition.appendIfNotEmpty(name, "name#like", qw); - Condition.appendIfNotEmpty(phone, "phone#like", qw); Condition.appendIfNotEmpty(sex, "sex", qw); Condition.appendIfNotEmpty(showScreen, "show_screen", qw); qw.orderByDesc("sort_no"); diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/OfficeController.java b/src/main/java/com/ydool/boot/modules/rddb/web/OfficeController.java index ccd5b0c..bae4753 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/OfficeController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/OfficeController.java @@ -2,8 +2,10 @@ package com.ydool.boot.modules.rddb.web; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.core.auth.PreAuth; import com.ydool.boot.modules.rddb.entity.Office; @@ -49,8 +51,8 @@ public class OfficeController extends BaseAdminController { public void list(Office office) { QueryWrapper wrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(office.getName())) wrapper.like("name", office.getName()); - if (StringUtils.isNotBlank(office.getPhone())) wrapper.like("phone", office.getPhone()); if (StringUtils.isNotBlank(office.getDuty())) wrapper.like("duty", office.getDuty()); + wrapper.like(StrUtil.isNotBlank(office.getPhone()),"AES_DECRYPT(from_base64 (phone),'"+ CodecUtils.KEY +"')",office.getPhone()); wrapper.orderByDesc("created_at"); Page page = officeService.page(new Page(getPageNum(), getPageSize()), wrapper); render(Ret.ok().paged(OfficeWrapper.build().pageVO(page))); diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/ReadFileUserController.java b/src/main/java/com/ydool/boot/modules/rddb/web/ReadFileUserController.java index e1684c9..693fca6 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/ReadFileUserController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/ReadFileUserController.java @@ -4,10 +4,11 @@ package com.ydool.boot.modules.rddb.web; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.modules.rddb.entity.ReadFileUser; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.ReadFileUserService; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.web.BaseAdminController; @@ -64,7 +65,7 @@ public class ReadFileUserController extends BaseAdminController { //县级工作人员 userQueryWrapper.eq("account_type", "admin"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/SuperviseThingUserController.java b/src/main/java/com/ydool/boot/modules/rddb/web/SuperviseThingUserController.java index 9f7bce4..50f06be 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/SuperviseThingUserController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/SuperviseThingUserController.java @@ -4,11 +4,12 @@ package com.ydool.boot.modules.rddb.web; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.core.web.BaseController; import com.ydool.boot.modules.rddb.entity.SuperviseThingUser; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.SuperviseThingUserService; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +65,7 @@ public class SuperviseThingUserController extends BaseController { //人大代表督事 userQueryWrapper.eq("account_type", "rddb"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/VoterController.java b/src/main/java/com/ydool/boot/modules/rddb/web/VoterController.java index caa9a95..8b64802 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/VoterController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/VoterController.java @@ -13,6 +13,7 @@ import com.ydool.boot.core.auth.PreAuth; import com.ydool.boot.core.mybatis.Condition; import com.ydool.boot.core.mybatis.Query; import com.ydool.boot.modules.rddb.entity.dto.UserDto; +import com.ydool.boot.modules.rddb.service.TestService; import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.sys.entity.Role; import com.ydool.boot.modules.sys.entity.User; @@ -41,6 +42,8 @@ public class VoterController extends BaseAdminController { private RoleService roleService; @Autowired private UserRoleService userRoleService; + @Autowired + private TestService testService; @ModelAttribute public User getUser(String id) { @@ -56,7 +59,9 @@ public class VoterController extends BaseAdminController { @PreAuth("sys:rddb:list") public void list(User user, Query query) { user.setLoginName(CodecUtils.decrypt(user.getLoginName())); - QueryWrapper wrapper = Condition.getQueryWrapper(user, "loginName#like", "accountType"); + QueryWrapper wrapper = new QueryWrapper() + .eq(StrUtil.isNotBlank(user.getAccountType()),"account_type", user.getAccountType()) + .like(StrUtil.isNotBlank(user.getLoginName()),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",user.getLoginName()); IPage paged = userService.page(Condition.getPage(query), wrapper.orderByDesc("created_at")); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(paged))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/VoterSuggestSolveController.java b/src/main/java/com/ydool/boot/modules/rddb/web/VoterSuggestSolveController.java index 27bf861..13a9f4f 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/VoterSuggestSolveController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/VoterSuggestSolveController.java @@ -4,12 +4,13 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ydool.boot.api.util.CodecUtils; import com.ydool.boot.common.result.Ret; import com.ydool.boot.core.web.BaseController; import com.ydool.boot.modules.rddb.entity.VoterSuggestSolve; -import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.service.VoterSuggestService; import com.ydool.boot.modules.rddb.service.VoterSuggestSolveService; +import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper; import com.ydool.boot.modules.rddb.wrapper.VoterSuggestSolveWrapper; import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.service.UserService; @@ -72,7 +73,7 @@ public class VoterSuggestSolveController extends BaseController { //县级工作人员 // userQueryWrapper.eq("account_type", "admin"); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); - if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); + userQueryWrapper.like(StrUtil.isNotBlank(loginName),"AES_DECRYPT(from_base64 (login_name),'"+ CodecUtils.KEY +"')",loginName); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page))); } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/WelcomeController.java b/src/main/java/com/ydool/boot/modules/rddb/web/WelcomeController.java index e09f062..b428556 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/WelcomeController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/WelcomeController.java @@ -1,16 +1,28 @@ package com.ydool.boot.modules.rddb.web; +import com.ydool.boot.modules.rddb.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping(value = "${ydool.path}/welcome") public class WelcomeController { + @Autowired + private TestService testService; + @GetMapping public String index() { return "welcome.html"; } + + @GetMapping("encrypt") + @ResponseBody + public void encrypt() { + testService.encrypt(); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4f81fee..50eb19e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,14 +1,14 @@ #online -db.user = ydool_rd -db.pass = MfaSPabGrDmPtET@123 -db.url = jdbc:mysql://122.112.138.17:3306/ydool_rd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 -db.driver = com.mysql.cj.jdbc.Driver +#db.user = ydool_rd +#db.pass = MfaSPabGrDmPtET@123 +#db.url = jdbc:mysql://122.112.138.17:3306/ydool_rd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 +#db.driver = com.mysql.cj.jdbc.Driver #local -#db.user = root -#db.pass = 123456 -#db.url = jdbc:mysql://127.0.0.1:3306/ydool_rd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 -#db.driver = com.mysql.cj.jdbc.Driver +db.user = root +db.pass = 123456 +db.url = jdbc:mysql://127.0.0.1:3306/ydool_rd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 +db.driver = com.mysql.cj.jdbc.Driver spring.servlet.multipart.max-file-size=500MB spring.servlet.multipart.max-request-size=500MB