opt:1.国际化完善。

This commit is contained in:
2026-02-04 13:53:11 +08:00
parent ab393a8fee
commit dd6f7ac79d
14 changed files with 65 additions and 49 deletions

View File

@@ -2,6 +2,7 @@ package org.nl.sys.modular.anomalyInfo.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.logging.annotation.Log; import org.nl.logging.annotation.Log;
import org.nl.sys.modular.anomalyInfo.dao.ErrorHandling; import org.nl.sys.modular.anomalyInfo.dao.ErrorHandling;
@@ -53,7 +54,7 @@ public class AnomalyInfoController {
@Log("导入excel异常信息") @Log("导入excel异常信息")
public ResponseEntity<Object> importErrorInfoExcel(@RequestParam("file") MultipartFile file) throws IOException { public ResponseEntity<Object> importErrorInfoExcel(@RequestParam("file") MultipartFile file) throws IOException {
if (file.isEmpty()) { if (file.isEmpty()) {
throw new BadRequestException("请选择文件上传"); throw new BadRequestException(LangProcess.msg("anomaly_file_not_selected"));
} }
// 创建监听器实例传入所需的Service // 创建监听器实例传入所需的Service
@@ -72,7 +73,7 @@ public class AnomalyInfoController {
@Log("导入excel异常处理信息") @Log("导入excel异常处理信息")
public ResponseEntity<Object> importErrorHandlingExcel(@RequestParam("file") MultipartFile file) throws IOException { public ResponseEntity<Object> importErrorHandlingExcel(@RequestParam("file") MultipartFile file) throws IOException {
if (file.isEmpty()) { if (file.isEmpty()) {
throw new BadRequestException("请选择文件上传"); throw new BadRequestException(LangProcess.msg("anomaly_file_not_selected"));
} }
// 创建监听器实例传入所需的Service // 创建监听器实例传入所需的Service
@@ -91,13 +92,13 @@ public class AnomalyInfoController {
@Log("导入异常图片") @Log("导入异常图片")
public ResponseEntity<Object> importErrorImage(@RequestParam("file") MultipartFile file) throws IOException { public ResponseEntity<Object> importErrorImage(@RequestParam("file") MultipartFile file) throws IOException {
if (file.isEmpty()) { if (file.isEmpty()) {
throw new BadRequestException("文件不能为空"); throw new BadRequestException(LangProcess.msg("anomaly_file_name_empty"));
} }
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
if (originalFilename == null || if (originalFilename == null ||
(!originalFilename.toLowerCase().endsWith(".zip"))) { (!originalFilename.toLowerCase().endsWith(".zip"))) {
throw new BadRequestException("目前只支持ZIP格式"); throw new BadRequestException(LangProcess.msg("anomaly_file_format_error"));
} }
try { try {
@@ -114,7 +115,7 @@ public class AnomalyInfoController {
return new ResponseEntity<>("上传成功!",HttpStatus.OK); return new ResponseEntity<>("上传成功!",HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
throw new BadRequestException("处理文件失败:{}"+e.getMessage()); throw new BadRequestException(LangProcess.msg("anomaly_file_parse_failed",e.getMessage()));
} }
} }

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.response.WebResponse; import org.nl.response.WebResponse;
import org.nl.sys.modular.anomalyInfo.dao.ErrorInfo; import org.nl.sys.modular.anomalyInfo.dao.ErrorInfo;
@@ -40,7 +41,7 @@ public class ErrorInfoServiceImpl extends ServiceImpl<ErrorInfoMapper, ErrorInfo
public WebResponse updateErrorInfo(ErrorInfo errorInfo) { public WebResponse updateErrorInfo(ErrorInfo errorInfo) {
boolean result = errorInfoMapper.updateById(errorInfo) > 0; boolean result = errorInfoMapper.updateById(errorInfo) > 0;
if (!result){ if (!result){
throw new BadRequestException("修改异常信息失败"); throw new BadRequestException(LangProcess.msg("anomaly_update_failed"));
} }
return WebResponse.requestOk(); return WebResponse.requestOk();
} }

View File

@@ -24,6 +24,7 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -249,7 +250,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
// 1M // 1M
int len = 1024 * 1024; int len = 1024 * 1024;
if (size > (maxSize * len)) { if (size > (maxSize * len)) {
throw new BadRequestException("文件超出规定大小"); throw new BadRequestException(LangProcess.msg("file_size_exceed"));
} }
} }

View File

@@ -18,6 +18,7 @@ package org.nl.sys.modular.backgroundmanagement.dept.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode; import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.logging.annotation.Log; import org.nl.logging.annotation.Log;
import org.nl.sys.modular.backgroundmanagement.common.base.TableDataInfo; import org.nl.sys.modular.backgroundmanagement.common.base.TableDataInfo;
@@ -91,7 +92,7 @@ public class DeptController {
// @SaCheckPermission("dept:edit") // @SaCheckPermission("dept:edit")
public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept){ public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept){
if (dept.getPid() != null && dept.getDept_id().equals(dept.getPid())) { if (dept.getPid() != null && dept.getDept_id().equals(dept.getPid())) {
throw new BadRequestException("上级不能为自己"); throw new BadRequestException(LangProcess.msg("dept_parent_cannot_self"));
} }
deptService.updateDept(dept); deptService.updateDept(dept);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
import org.nl.sys.modular.backgroundmanagement.common.domain.vo.DeptVo; import org.nl.sys.modular.backgroundmanagement.common.domain.vo.DeptVo;
@@ -157,7 +158,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
if (!CollectionUtils.isEmpty(depeIds)){ if (!CollectionUtils.isEmpty(depeIds)){
List<Map> deptRelation = sysDeptMapper.getDeptRelation(depeIds); List<Map> deptRelation = sysDeptMapper.getDeptRelation(depeIds);
if (!CollectionUtils.isEmpty(deptRelation)){ if (!CollectionUtils.isEmpty(deptRelation)){
throw new BadRequestException("部门存在绑定的人员,请先解绑人员对应部门"); throw new BadRequestException(LangProcess.msg("dept_has_users"));
} }
} }
} }

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
import org.nl.sys.modular.backgroundmanagement.common.util.SecurityUtils; import org.nl.sys.modular.backgroundmanagement.common.util.SecurityUtils;
@@ -59,7 +60,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
String date = DateUtil.now(); String date = DateUtil.now();
List<Dict> oldDict = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>() List<Dict> oldDict = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>()
.eq(ObjectUtil.isNotEmpty(dict.getCode()), Dict::getCode, dict.getCode())); .eq(ObjectUtil.isNotEmpty(dict.getCode()), Dict::getCode, dict.getCode()));
if (ObjectUtil.isNotEmpty(oldDict)) throw new BadRequestException("字典[" + dict.getCode() + "]已存在"); if (ObjectUtil.isNotEmpty(oldDict)) throw new BadRequestException(LangProcess.msg("dict_code_exists", dict.getCode()));
dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr()); dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr());
dict.setCreate_id(currentUserId); dict.setCreate_id(currentUserId);
dict.setCreate_name(nickName); dict.setCreate_name(nickName);
@@ -75,11 +76,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
public void updateDict(Dict dto) { public void updateDict(Dict dto) {
Dict dict = sysDictMapper.selectById(dto.getDict_id()); Dict dict = sysDictMapper.selectById(dto.getDict_id());
if (ObjectUtil.isEmpty(dict)) { if (ObjectUtil.isEmpty(dict)) {
throw new BadRequestException("字典不存在"); throw new BadRequestException(LangProcess.msg("dict_not_exist"));
} }
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dto.getCode())); List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dto.getCode()));
if (ObjectUtil.isNotEmpty(dictList) && !dto.getCode().equals(dict.getCode())) if (ObjectUtil.isNotEmpty(dictList) && !dto.getCode().equals(dict.getCode()))
throw new BadRequestException("字典[" + dto.getCode() + "]已存在"); throw new BadRequestException(LangProcess.msg("dict_code_exists", dto.getCode()));
String currentUserId = SecurityUtils.getCurrentUserId(); String currentUserId = SecurityUtils.getCurrentUserId();
String currentNickName = SecurityUtils.getCurrentNickName(); String currentNickName = SecurityUtils.getCurrentNickName();
// 根据code获取所有字典 // 根据code获取所有字典
@@ -130,7 +131,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
// 校验是否已经有标签 // 校验是否已经有标签
Dict one = sysDictMapper.selectOne(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, dict.getLabel()) Dict one = sysDictMapper.selectOne(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, dict.getLabel())
.eq(Dict::getCode, dict.getCode())); .eq(Dict::getCode, dict.getCode()));
if (ObjectUtil.isNotEmpty(one)) throw new BadRequestException("标签[" + dict.getLabel() + "]已存在"); if (ObjectUtil.isNotEmpty(one)) throw new BadRequestException(LangProcess.msg("dict_label_exists", dict.getLabel()));
// 判断是否有空的值 // 判断是否有空的值
List<Dict> selectOne = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dict.getCode())); List<Dict> selectOne = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dict.getCode()));
Dict dic = selectOne.get(0); Dict dic = selectOne.get(0);
@@ -165,13 +166,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
public void updateDetail(Dict resources) { public void updateDetail(Dict resources) {
Dict dict = sysDictMapper.selectById(resources.getDict_id()); Dict dict = sysDictMapper.selectById(resources.getDict_id());
if (ObjectUtil.isEmpty(dict)) { if (ObjectUtil.isEmpty(dict)) {
throw new BadRequestException("被删除或无权限,操作失败!"); throw new BadRequestException(LangProcess.msg("dict_no_permission"));
} }
// 校验是否已经有标签 // 校验是否已经有标签
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, resources.getLabel()) List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, resources.getLabel())
.eq(Dict::getCode, resources.getCode())); .eq(Dict::getCode, resources.getCode()));
if (ObjectUtil.isNotEmpty(dictList) && !resources.getLabel().equals(dict.getLabel())) { if (ObjectUtil.isNotEmpty(dictList) && !resources.getLabel().equals(dict.getLabel())) {
throw new BadRequestException("标签[" + resources.getLabel() + "]已存在"); throw new BadRequestException(LangProcess.msg("dict_label_exists", resources.getLabel()));
} }
resources.setUpdate_id(SecurityUtils.getCurrentUserId()); resources.setUpdate_id(SecurityUtils.getCurrentUserId());
resources.setUpdate_name(SecurityUtils.getCurrentNickName()); resources.setUpdate_name(SecurityUtils.getCurrentNickName());

View File

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.constant.DictConstantPool; import org.nl.sys.modular.backgroundmanagement.common.domain.constant.DictConstantPool;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
@@ -114,7 +115,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
if (resources.getIframe()) { if (resources.getIframe()) {
String http = "http://", https = "https://"; String http = "http://", https = "https://";
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) { if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
throw new BadRequestException("外链必须以http://或者https://开头"); throw new BadRequestException(LangProcess.msg("menu_url_must_http"));
} }
} }
resources.setMenu_id(IdUtil.getStringId()); resources.setMenu_id(IdUtil.getStringId());
@@ -189,12 +190,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
String allChild = baseMapper.findAllChild(menuId); // 获取当前菜单的所有子菜单 String allChild = baseMapper.findAllChild(menuId); // 获取当前菜单的所有子菜单
List<String> allChildIds = ObjectUtil.isNotEmpty(allChild)?Arrays.asList(allChild.split(",")):null; List<String> allChildIds = ObjectUtil.isNotEmpty(allChild)?Arrays.asList(allChild.split(",")):null;
if (ObjectUtil.isNotEmpty(allChildIds) && allChildIds.contains(resources.getPid())){ if (ObjectUtil.isNotEmpty(allChildIds) && allChildIds.contains(resources.getPid())){
throw new BadRequestException("上级不能为自己或自己的下级"); throw new BadRequestException(LangProcess.msg("menu_parent_cannot_self"));
} }
if (resources.getIframe()) { if (resources.getIframe()) {
String http = "http://", https = "https://"; String http = "http://", https = "https://";
if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) { if (!(resources.getPath().toLowerCase().startsWith(http) || resources.getPath().toLowerCase().startsWith(https))) {
throw new BadRequestException("外链必须以http://或者https://开头"); throw new BadRequestException(LangProcess.msg("menu_url_must_http"));
} }
} }
@@ -383,7 +384,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
public List<MenuVo> buildMenus(String systemType) { public List<MenuVo> buildMenus(String systemType) {
Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType)); Dict dict = sysDictMapper.selectOne(new QueryWrapper<Dict>().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType));
if (dict == null || StringUtils.isEmpty(dict.getPara1())){ if (dict == null || StringUtils.isEmpty(dict.getPara1())){
throw new BadRequestException("获取对应的系统菜单不存在"); throw new BadRequestException(LangProcess.msg("system_get_menu_failed"));
} }
String pid = dict.getPara1(); String pid = dict.getPara1();
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(),systemType); List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(),systemType);

View File

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
import org.nl.sys.modular.backgroundmanagement.common.enums.NoticeEnum; import org.nl.sys.modular.backgroundmanagement.common.enums.NoticeEnum;
@@ -80,7 +81,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
@Override @Override
public void update(SysNotice entity) { public void update(SysNotice entity) {
SysNotice dto = sysNoticeMapper.selectById(entity.getNotice_id()); SysNotice dto = sysNoticeMapper.selectById(entity.getNotice_id());
if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!"); if (dto == null) throw new BadRequestException(LangProcess.msg("dict_no_permission"));
sysNoticeMapper.updateById(entity); sysNoticeMapper.updateById(entity);
} }
@@ -117,7 +118,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
public void read(String id) { public void read(String id) {
SysNotice notice = this.getById(id); SysNotice notice = this.getById(id);
if (ObjectUtil.isEmpty(notice)) { if (ObjectUtil.isEmpty(notice)) {
throw new BadRequestException("该信息不存在!"); throw new BadRequestException(LangProcess.msg("notice_not_exist"));
} }
notice.setHave_read(NoticeEnum.HAVE_READ_ON.getValue()); notice.setHave_read(NoticeEnum.HAVE_READ_ON.getValue());
notice.setRead_time(DateUtil.now()); notice.setRead_time(DateUtil.now());
@@ -128,7 +129,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
public void deal(String id) { public void deal(String id) {
SysNotice notice = this.getById(id); SysNotice notice = this.getById(id);
if (ObjectUtil.isEmpty(notice)) { if (ObjectUtil.isEmpty(notice)) {
throw new BadRequestException("该信息不存在!"); throw new BadRequestException(LangProcess.msg("notice_not_exist"));
} }
// 设置处理 // 设置处理
notice.setDeal_status(NoticeEnum.DEAL_STATUS_YES.getValue()); notice.setDeal_status(NoticeEnum.DEAL_STATUS_YES.getValue());
@@ -175,7 +176,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
try { try {
webSocketServer.sendInfo(messageInfo, "messageInfo"); webSocketServer.sendInfo(messageInfo, "messageInfo");
} catch (IOException e) { } catch (IOException e) {
throw new BadRequestException("消息发送失败"); throw new BadRequestException(LangProcess.msg("notice_send_failed"));
} }
} }

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
import org.nl.sys.modular.backgroundmanagement.common.util.MapOf; import org.nl.sys.modular.backgroundmanagement.common.util.MapOf;
@@ -49,7 +50,7 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void create(Param param) { public void create(Param param) {
List code = paramMapper.selectByMap(MapOf.of("code", param.getCode())); List code = paramMapper.selectByMap(MapOf.of("code", param.getCode()));
if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException("编码不能一致"); if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException(LangProcess.msg("param_code_not_match"));
param.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); param.setId(IdUtil.getSnowflake(1, 1).nextIdStr());
String currentUserId = SecurityUtils.getCurrentUserId(); String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName(); String nickName = SecurityUtils.getCurrentNickName();
@@ -68,12 +69,12 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
public void update(Param param) { public void update(Param param) {
Param paramObj = paramMapper.selectById(param.getId()); Param paramObj = paramMapper.selectById(param.getId());
if (ObjectUtil.isEmpty(paramObj)) { if (ObjectUtil.isEmpty(paramObj)) {
throw new BadRequestException("被删除或无权限,操作失败!"); throw new BadRequestException(LangProcess.msg("dict_no_permission"));
} }
Param param1 = paramMapper.selectOne(new LambdaQueryWrapper<Param>().eq(Param::getCode, param.getCode()) Param param1 = paramMapper.selectOne(new LambdaQueryWrapper<Param>().eq(Param::getCode, param.getCode())
.and(lam -> lam.ne(Param::getId, param.getId()))); .and(lam -> lam.ne(Param::getId, param.getId())));
if (ObjectUtil.isNotEmpty(param1)) { if (ObjectUtil.isNotEmpty(param1)) {
throw new BadRequestException("编码[" + param.getCode() + "]已存在"); throw new BadRequestException(LangProcess.msg("param_code_exists", param.getCode()));
} }
param.setUpdate_id(SecurityUtils.getCurrentUserId()); param.setUpdate_id(SecurityUtils.getCurrentUserId());
param.setUpdate_name(SecurityUtils.getCurrentNickName()); param.setUpdate_name(SecurityUtils.getCurrentNickName());

View File

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery; import org.nl.sys.modular.backgroundmanagement.common.domain.query.PageQuery;
import org.nl.sys.modular.backgroundmanagement.common.util.SecurityUtils; import org.nl.sys.modular.backgroundmanagement.common.util.SecurityUtils;
@@ -59,12 +60,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
public void create(JSONObject param) { public void create(JSONObject param) {
//判断角色名字是否存在 //判断角色名字是否存在
String name = param.getString("name"); String name = param.getString("name");
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!"); if (StrUtil.isEmpty(name)) throw new BadRequestException(LangProcess.msg("role_name_empty"));
SysRole sysRole = JSONObject.parseObject(JSONObject.toJSONString(param), SysRole.class); SysRole sysRole = JSONObject.parseObject(JSONObject.toJSONString(param), SysRole.class);
//判断角色名字是否存在 //判断角色名字是否存在
SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getName, sysRole.getName())); SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getName, sysRole.getName()));
if (ObjectUtil.isNotEmpty(role)) throw new BadRequestException("角色【" + name + "】已存在!"); if (ObjectUtil.isNotEmpty(role)) throw new BadRequestException(LangProcess.msg("role_name_exists", name));
String userId = SecurityUtils.getCurrentUserId(); String userId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName(); String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now(); String now = DateUtil.now();
@@ -85,12 +86,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
SysRole sysRole = JSONObject.parseObject(JSONObject.toJSONString(param), SysRole.class); SysRole sysRole = JSONObject.parseObject(JSONObject.toJSONString(param), SysRole.class);
//判断角色名字是否存在 //判断角色名字是否存在
String name = sysRole.getName(); String name = sysRole.getName();
if (StrUtil.isEmpty(name)) throw new BadRequestException("角色名字不能为空!"); if (StrUtil.isEmpty(name)) throw new BadRequestException(LangProcess.msg("role_name_empty"));
//判断角色名字是否存在 //判断角色名字是否存在
SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getName, sysRole.getName()) SysRole role = roleMapper.selectOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getName, sysRole.getName())
.ne(SysRole::getRole_id, sysRole.getRole_id())); .ne(SysRole::getRole_id, sysRole.getRole_id()));
if (ObjectUtil.isNotEmpty(role)) throw new BadRequestException("角色【" + name + "】已存在!"); if (ObjectUtil.isNotEmpty(role)) throw new BadRequestException(LangProcess.msg("role_name_exists", name));
String userId = SecurityUtils.getCurrentUserId(); String userId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName(); String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now(); String now = DateUtil.now();

View File

@@ -26,6 +26,7 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.sys.modular.backgroundmanagement.common.util.*; import org.nl.sys.modular.backgroundmanagement.common.util.*;
import org.nl.sys.modular.backgroundmanagement.common.util.dto.CurrentUser; import org.nl.sys.modular.backgroundmanagement.common.util.dto.CurrentUser;
@@ -220,16 +221,16 @@ public class OnlineUserService {
// 清除验证码 // 清除验证码
redisUtils.del(authUser.getUuid()); redisUtils.del(authUser.getUuid());
if (StrUtil.isEmpty(code)) { if (StrUtil.isEmpty(code)) {
throw new BadRequestException("验证码不存在或已过期"); throw new BadRequestException(LangProcess.msg("user_code_not_exist"));
} }
if (StrUtil.isEmpty(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) { if (StrUtil.isEmpty(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) {
throw new BadRequestException("验证码错误"); throw new BadRequestException(LangProcess.msg("user_code_error"));
} }
// 校验数据库 // 校验数据库
// 根据用户名查询,在比对密码 // 根据用户名查询,在比对密码
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username",authUser.getUsername())); SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username",authUser.getUsername()));
if (userInfo == null||!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密 if (userInfo == null||!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
throw new BadRequestException("账号或密码错误"); throw new BadRequestException(LangProcess.msg("user_account_password_error"));
} }
// 获取权限列表 - 登录查找权限 // 获取权限列表 - 登录查找权限
@@ -237,7 +238,7 @@ public class OnlineUserService {
if (!userInfo.getIs_used()) { if (!userInfo.getIs_used()) {
throw new BadRequestException("账号未激活"); throw new BadRequestException(LangProcess.msg("user_account_not_active"));
} }
// 登录输入,登出删除 // 登录输入,登出删除

View File

@@ -98,10 +98,10 @@ public class UserController {
String newPass = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,passVo.getString("newPass")); String newPass = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,passVo.getString("newPass"));
SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, SecurityUtils.getCurrentUsername())); SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, SecurityUtils.getCurrentUsername()));
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) { if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
throw new BadRequestException("修改失败,旧密码错误"); throw new BadRequestException(LangProcess.msg("user_old_password_error"));
} }
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) { if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) {
throw new BadRequestException("新密码不能与旧密码相同"); throw new BadRequestException(LangProcess.msg("user_password_not_match"));
} }
user.setPassword(SaSecureUtil.md5BySalt(newPass, "salt")); user.setPassword(SaSecureUtil.md5BySalt(newPass, "salt"));
userService.updateById(user); userService.updateById(user);
@@ -120,7 +120,7 @@ public class UserController {
String password = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,user.getPassword()); String password = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,user.getPassword());
SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username",SecurityUtils.getCurrentUsername())); SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username",SecurityUtils.getCurrentUsername()));
if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){ if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){
throw new BadRequestException("密码错误"); throw new BadRequestException(LangProcess.msg("user_password_error"));
} }
userService.update(new UpdateWrapper<SysUser>().set(userInfo.getUsername(),user.getEmail())); userService.update(new UpdateWrapper<SysUser>().set(userInfo.getUsername(),user.getEmail()));
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.nl.api.task.api.TaskAPI; import org.nl.api.task.api.TaskAPI;
import org.nl.api.task.core.TaskRequestParam; import org.nl.api.task.core.TaskRequestParam;
import org.nl.config.language.LangProcess;
import org.nl.enums.TaskSourceEnum; import org.nl.enums.TaskSourceEnum;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.response.WebResponse; import org.nl.response.WebResponse;
@@ -23,6 +24,8 @@ import org.nl.sys.modular.qrcode.service.QRCodeService;
import org.nl.util.FileProperties; import org.nl.util.FileProperties;
import org.nl.util.IdUtil; import org.nl.util.IdUtil;
import org.nl.util.QRCodeUtil; import org.nl.util.QRCodeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@@ -32,6 +35,7 @@ import org.springframework.stereotype.Service;
@Service @Service
public class QRCodeServiceImpl implements QRCodeService { public class QRCodeServiceImpl implements QRCodeService {
private static final Logger log = LoggerFactory.getLogger(QRCodeServiceImpl.class);
@Resource @Resource
private FileProperties fileProperties; private FileProperties fileProperties;
@@ -44,10 +48,10 @@ public class QRCodeServiceImpl implements QRCodeService {
@Override @Override
public WebResponse generateQRCode(GenerateQRCodeParam param) { public WebResponse generateQRCode(GenerateQRCodeParam param) {
if (StrUtil.isBlank(param.getData())){ if (StrUtil.isBlank(param.getData())){
throw new BadRequestException("二维码内容不能为空"); throw new BadRequestException(LangProcess.msg("qrcode_data_empty"));
} }
if (StrUtil.isBlank(param.getRoom())){ if (StrUtil.isBlank(param.getRoom())){
throw new BadRequestException("二维码房间号不能为空"); throw new BadRequestException(LangProcess.msg("qrcode_room_number_empty"));
} }
//二维码高宽如果为空 默认150像素 //二维码高宽如果为空 默认150像素
int qrcodeWidth = ObjectUtil.isNotEmpty(param.getWidth()) ? param.getWidth() : 150; int qrcodeWidth = ObjectUtil.isNotEmpty(param.getWidth()) ? param.getWidth() : 150;
@@ -60,12 +64,12 @@ public class QRCodeServiceImpl implements QRCodeService {
String result = QRCodeUtil.generateQRCode(param.getData(), qrcodeWidth, String result = QRCodeUtil.generateQRCode(param.getData(), qrcodeWidth,
qrcodeHeight,localAddress,fileName); qrcodeHeight,localAddress,fileName);
if (StrUtil.isBlank(result)){ if (StrUtil.isBlank(result)){
throw new BadRequestException("生成二维码失败"); throw new BadRequestException(LangProcess.msg("qrcode_generate_failed"));
} }
// 检验该房间是否已经存在二维码 // 检验该房间是否已经存在二维码
boolean exists = this.verifyQRCodeByRoom(param.getRoom()); boolean exists = this.verifyQRCodeByRoom(param.getRoom());
if (exists){ if (exists){
throw new BadRequestException("该房间已存在二维码,无法继续生成"); throw new BadRequestException(LangProcess.msg("qrcode_room_exists"));
} }
QRcodeInfo qrcodeInfo = new QRcodeInfo(); QRcodeInfo qrcodeInfo = new QRcodeInfo();
qrcodeInfo.setQrcode_id(IdUtil.getStringId()); qrcodeInfo.setQrcode_id(IdUtil.getStringId());
@@ -98,7 +102,7 @@ public class QRCodeServiceImpl implements QRCodeService {
// 检验该房间是否已经存在二维码 // 检验该房间是否已经存在二维码
boolean exists = this.verifyQRCodeByRoom(param.getNewRoom()); boolean exists = this.verifyQRCodeByRoom(param.getNewRoom());
if (exists){ if (exists){
throw new BadRequestException("该房间已存在二维码,无法修改"); throw new BadRequestException(LangProcess.msg("qrcode_room_exists_cannot_update"));
} }
} }
String fileName = param.getNewRoom() + ".png"; String fileName = param.getNewRoom() + ".png";
@@ -106,7 +110,7 @@ public class QRCodeServiceImpl implements QRCodeService {
String fileSizeKB = QRCodeUtil.generateQRCode(param.getQrcode_data(), param.getQrcode_width(), String fileSizeKB = QRCodeUtil.generateQRCode(param.getQrcode_data(), param.getQrcode_width(),
param.getQrcode_height(),fileProperties.getPath().getQrcode(),fileName); param.getQrcode_height(),fileProperties.getPath().getQrcode(),fileName);
if (StrUtil.isBlank(fileSizeKB)){ if (StrUtil.isBlank(fileSizeKB)){
throw new BadRequestException("生成二维码失败"); throw new BadRequestException(LangProcess.msg("qrcode_generate_failed"));
} }
//更新二维码信息 //更新二维码信息
boolean result = qrcodeInfoMapper.update(null,new LambdaUpdateWrapper<>(QRcodeInfo.class) boolean result = qrcodeInfoMapper.update(null,new LambdaUpdateWrapper<>(QRcodeInfo.class)
@@ -121,7 +125,7 @@ public class QRCodeServiceImpl implements QRCodeService {
.eq(QRcodeInfo::getQrcode_id,param.getQrcode_id()) .eq(QRcodeInfo::getQrcode_id,param.getQrcode_id())
) > 0; ) > 0;
if (!result){ if (!result){
throw new BadRequestException("修改二维码信息失败"); throw new BadRequestException(LangProcess.msg("qrcode_update_failed"));
} }
return WebResponse.requestOk(); return WebResponse.requestOk();
} }
@@ -129,15 +133,15 @@ public class QRCodeServiceImpl implements QRCodeService {
@Override @Override
public WebResponse deleteQRCodeInfo(QRcodeInfo qRcodeInfo) { public WebResponse deleteQRCodeInfo(QRcodeInfo qRcodeInfo) {
if (StrUtil.isBlank(qRcodeInfo.getQrcode_id())){ if (StrUtil.isBlank(qRcodeInfo.getQrcode_id())){
throw new BadRequestException("二维码标识不能为空"); throw new BadRequestException(LangProcess.msg("qrcode_id_empty"));
} }
boolean deleteResult = QRCodeUtil.deleteQRCode(fileProperties.getPath().getQrcode(),qRcodeInfo.getFile_name()); boolean deleteResult = QRCodeUtil.deleteQRCode(fileProperties.getPath().getQrcode(),qRcodeInfo.getFile_name());
if (!deleteResult){ if (!deleteResult){
throw new BadRequestException("删除二维码文件失败"); throw new BadRequestException(LangProcess.msg("qrcode_delete_file_failed"));
} }
boolean result = qrcodeInfoMapper.deleteById(qRcodeInfo.getQrcode_id())>0; boolean result = qrcodeInfoMapper.deleteById(qRcodeInfo.getQrcode_id())>0;
if (!result){ if (!result){
throw new BadRequestException("删除二维码失败"); throw new BadRequestException(LangProcess.msg("qrcode_delete_failed"));
} }
return WebResponse.requestOk(); return WebResponse.requestOk();
} }
@@ -166,7 +170,7 @@ public class QRCodeServiceImpl implements QRCodeService {
@Override @Override
public boolean verifyQRCodeByRoom(String room) { public boolean verifyQRCodeByRoom(String room) {
if (StrUtil.isBlank(room)){ if (StrUtil.isBlank(room)){
throw new BadRequestException("房间号不能为空"); throw new BadRequestException(LangProcess.msg("qrcode_station_code_empty"));
} }
return qrcodeInfoMapper.selectCount(new LambdaQueryWrapper<>(QRcodeInfo.class) return qrcodeInfoMapper.selectCount(new LambdaQueryWrapper<>(QRcodeInfo.class)
.eq(QRcodeInfo::getRoom_code,room) .eq(QRcodeInfo::getRoom_code,room)

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.nl.api.setting.api.SettingAPI; import org.nl.api.setting.api.SettingAPI;
import org.nl.config.language.LangProcess;
import org.nl.exception.BadRequestException; import org.nl.exception.BadRequestException;
import org.nl.response.WebResponse; import org.nl.response.WebResponse;
import org.nl.sys.modular.secutiry.service.SecurityService; import org.nl.sys.modular.secutiry.service.SecurityService;
@@ -28,7 +29,7 @@ public class SecurityServiceImpl implements SecurityService {
String new_password = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,password); String new_password = RsaUtils.decryptByPrivateKey(RsaUtils.privateKey,password);
JSONObject setting = settingAPI.querySettingParamByCode("password").getJSONObject("data"); JSONObject setting = settingAPI.querySettingParamByCode("password").getJSONObject("data");
if (ObjectUtil.isEmpty(setting) || !setting.getString("value").equals(SaSecureUtil.md5BySalt(new_password,"salt"))) { if (ObjectUtil.isEmpty(setting) || !setting.getString("value").equals(SaSecureUtil.md5BySalt(new_password,"salt"))) {
throw new BadRequestException("密码错误"); throw new BadRequestException(LangProcess.msg("security_password_error"));
} }
return WebResponse.requestOk(); return WebResponse.requestOk();
} }