diff --git a/.gitignore b/.gitignore index 4f4febd..b34d8b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ - .DS_Store node_modules/ dist/ @@ -27,4 +26,3 @@ target/ **/out/ package-lock.json yarn.lock - diff --git a/README.md b/README.md index 7354d4e..ae9ec78 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ +# bs-jxc -# ba-base - -基础框架 +保税进销存 \ No newline at end of file diff --git a/bs-admin/pom.xml b/bs-admin/pom.xml index 6fe3be0..b424d0a 100644 --- a/bs-admin/pom.xml +++ b/bs-admin/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - my-base + bs-jxc com.bs 3.8.6 @@ -16,10 +16,7 @@ - - cn.hutool - hutool-all - + org.springframework.boot diff --git a/bs-admin/src/main/java/com/bs/BsApplication.java b/bs-admin/src/main/java/com/bs/BsApplication.java index a1302fe..e6dad6a 100644 --- a/bs-admin/src/main/java/com/bs/BsApplication.java +++ b/bs-admin/src/main/java/com/bs/BsApplication.java @@ -3,7 +3,6 @@ package com.bs; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; /** * 启动程序 @@ -11,13 +10,12 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties * @author bs */ @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) -@EnableConfigurationProperties public class BsApplication { public static void main(String[] args) { // System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(BsApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙ "); + System.out.println("(♥◠‿◠)ノ゙ 保税启动成功 ლ(´ڡ`ლ)゙ "); } } diff --git a/bs-admin/src/main/java/com/bs/cm/controller/CmAttachController.java b/bs-admin/src/main/java/com/bs/cm/controller/CmAttachController.java deleted file mode 100644 index 17252cf..0000000 --- a/bs-admin/src/main/java/com/bs/cm/controller/CmAttachController.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.bs.cm.controller; - -import cn.hutool.core.lang.Validator; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.bs.cm.domain.CmAttach; -import com.bs.cm.service.ICmAttachService; -import com.bs.common.annotation.Log; -import com.bs.common.core.controller.BaseController; -import com.bs.common.core.domain.AjaxResult; -import com.bs.common.core.page.TableDataInfo; -import com.bs.common.enums.BusinessType; -import com.bs.common.utils.poi.ExcelUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * 附件信息Controller - * - * @author bs - * @date 2024-03-03 - */ -@Api(tags = "附件信息") -@RestController -@RequestMapping("/cm/attach") -public class CmAttachController extends BaseController { - @Resource - private ICmAttachService cmAttachService; - - /** - * 分页查询附件信息列表 - */ - @ApiOperation("分页查询附件信息列表") - @GetMapping("/pageList") - public TableDataInfo pageList(CmAttach cmAttach) { - startPage(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, cmAttach); - List list = cmAttachService.list(queryWrapper); - return getDataTable(list); - } - - /** - * 查询附件信息列表 - */ - @ApiOperation("查询附件信息列表") - @GetMapping("/list") - public AjaxResult list(CmAttach cmAttach) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, cmAttach); - List list = cmAttachService.list(queryWrapper); - return success(list); - } - - /** - * 导出附件信息列表 - */ - @ApiOperation("导出附件信息列表") - @Log(title = "附件信息导出", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, CmAttach cmAttach) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, cmAttach); - List list = cmAttachService.list(queryWrapper); - ExcelUtil util = new ExcelUtil(CmAttach.class); - util.exportExcel(response, list, "附件信息数据"); - } - - /** - * 获取附件信息详细信息 - */ - @ApiOperation("获取附件信息详细信息") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(cmAttachService.getById(id)); - } - - /** - * 新增附件信息 - */ - @ApiOperation("新增附件信息") - @Log(title = "附件信息新增", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody CmAttach cmAttach) { - return toAjax(cmAttachService.save(cmAttach)); - } - - /** - * 修改附件信息 - */ - @ApiOperation("修改附件信息") - @Log(title = "附件信息修改", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody CmAttach cmAttach) { - return toAjax(cmAttachService.updateById(cmAttach)); - } - - /** - * 删除附件信息 - */ - @ApiOperation("删除附件信息") - @Log(title = "附件信息删除", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable List ids) { - return toAjax(cmAttachService.removeBatchByIds(ids)); - } - - - /** - * 条件设置 - */ - private void condition(LambdaQueryWrapper queryWrapper, CmAttach cmAttach) { - //用户id - if (Validator.isNotEmpty(cmAttach.getId())) { - queryWrapper.eq(CmAttach::getId, cmAttach.getId()); - } - - //文件组id - if (Validator.isNotEmpty(cmAttach.getFileId())) { - queryWrapper.eq(CmAttach::getFileId, cmAttach.getFileId()); - } - - //文件排序 - if (Validator.isNotEmpty(cmAttach.getFileSort())) { - queryWrapper.eq(CmAttach::getFileSort, cmAttach.getFileSort()); - } - - //文件名称(编译后) - if (Validator.isNotEmpty(cmAttach.getAttachName())) { - queryWrapper.eq(CmAttach::getAttachName, cmAttach.getAttachName()); - } - - //文件类型 - if (Validator.isNotEmpty(cmAttach.getAttachFileType())) { - queryWrapper.eq(CmAttach::getAttachFileType, cmAttach.getAttachFileType()); - } - - //文件编码类型 - if (Validator.isNotEmpty(cmAttach.getAttachContentType())) { - queryWrapper.eq(CmAttach::getAttachContentType, cmAttach.getAttachContentType()); - } - - //文件大小 - if (Validator.isNotEmpty(cmAttach.getAttachFileSize())) { - queryWrapper.eq(CmAttach::getAttachFileSize, cmAttach.getAttachFileSize()); - } - - //文件路径 - if (Validator.isNotEmpty(cmAttach.getAttachFileUrl())) { - queryWrapper.eq(CmAttach::getAttachFileUrl, cmAttach.getAttachFileUrl()); - } - - //文件名(原始) - if (Validator.isNotEmpty(cmAttach.getOldName())) { - queryWrapper.eq(CmAttach::getOldName, cmAttach.getOldName()); - } - - //文件版本号 - if (Validator.isNotEmpty(cmAttach.getVersionNo())) { - queryWrapper.eq(CmAttach::getVersionNo, cmAttach.getVersionNo()); - } - - //创建部门 - if (Validator.isNotEmpty(cmAttach.getCreateDept())) { - queryWrapper.eq(CmAttach::getCreateDept, cmAttach.getCreateDept()); - } - - //创建人 - if (Validator.isNotEmpty(cmAttach.getCreateBy())) { - queryWrapper.eq(CmAttach::getCreateBy, cmAttach.getCreateBy()); - } - - //创建时间 - if (Validator.isNotEmpty(cmAttach.getCreateTime())) { - queryWrapper.eq(CmAttach::getCreateTime, cmAttach.getCreateTime()); - } - - //修改人 - if (Validator.isNotEmpty(cmAttach.getUpdateBy())) { - queryWrapper.eq(CmAttach::getUpdateBy, cmAttach.getUpdateBy()); - } - - //修改时间 - if (Validator.isNotEmpty(cmAttach.getUpdateTime())) { - queryWrapper.eq(CmAttach::getUpdateTime, cmAttach.getUpdateTime()); - } - - //备注 - if (Validator.isNotEmpty(cmAttach.getRemark())) { - queryWrapper.eq(CmAttach::getRemark, cmAttach.getRemark()); - } - - //删除标志(0代表存在 2代表删除) - if (Validator.isNotEmpty(cmAttach.getDelFlag())) { - queryWrapper.eq(CmAttach::getDelFlag, cmAttach.getDelFlag()); - } - - //${column.columnComment} - if (Validator.isNotEmpty(cmAttach.getTenantId())) { - queryWrapper.eq(CmAttach::getTenantId, cmAttach.getTenantId()); - } - - } - -} diff --git a/bs-admin/src/main/java/com/bs/cm/domain/CmAttach.java b/bs-admin/src/main/java/com/bs/cm/domain/CmAttach.java deleted file mode 100644 index f600da3..0000000 --- a/bs-admin/src/main/java/com/bs/cm/domain/CmAttach.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.bs.cm.domain; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.bs.common.annotation.Excel; -import com.bs.common.core.domain.BaseEntity; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 附件信息对象 cm_attach - * - * @author bs - * @date 2024-03-03 - */ -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -@TableName("cm_attach") -@Data -public class CmAttach extends BaseEntity{ - private static final long serialVersionUID = 1L; - - /** 用户id */ - @TableId(value = "id",type = IdType.AUTO) - @ApiModelProperty(value = "用户id") - private Long id; - - /** 文件组id */ - - @Excel(name = "文件组id") - @ApiModelProperty(value = "文件组id") - private String fileId; - - /** 文件排序 */ - - @Excel(name = "文件排序") - @ApiModelProperty(value = "文件排序") - private Integer fileSort; - - /** 文件名称(编译后) */ - - @Excel(name = "文件名称", readConverterExp = "编=译后") - @ApiModelProperty(value = "文件名称(编译后)") - private String attachName; - - /** 文件类型 */ - - @Excel(name = "文件类型") - @ApiModelProperty(value = "文件类型") - private String attachFileType; - - /** 文件编码类型 */ - - @Excel(name = "文件编码类型") - @ApiModelProperty(value = "文件编码类型") - private String attachContentType; - - /** 文件大小 */ - - @Excel(name = "文件大小") - @ApiModelProperty(value = "文件大小") - private Long attachFileSize; - - /** 文件路径 */ - - @Excel(name = "文件路径") - @ApiModelProperty(value = "文件路径") - private String attachFileUrl; - - /** 文件名(原始) */ - - @Excel(name = "文件名", readConverterExp = "原=始") - @ApiModelProperty(value = "文件名(原始)") - private String oldName; - - /** 文件版本号 */ - - @Excel(name = "文件版本号") - @ApiModelProperty(value = "文件版本号") - private String versionNo; - - /** 备注 */ - - @Excel(name = "备注") - @ApiModelProperty(value = "备注") - private String remark; - - - - -} diff --git a/bs-admin/src/main/java/com/bs/cm/mapper/CmAttachMapper.java b/bs-admin/src/main/java/com/bs/cm/mapper/CmAttachMapper.java deleted file mode 100644 index d607342..0000000 --- a/bs-admin/src/main/java/com/bs/cm/mapper/CmAttachMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.bs.cm.mapper; - -import com.bs.common.mybatis.mapper.BaseMapperX; -import com.bs.cm.domain.CmAttach; - -/** - * 附件信息Mapper接口 - * - * @author bs - * @date 2024-03-03 - */ -public interface CmAttachMapper extends BaseMapperX { - -} diff --git a/bs-admin/src/main/java/com/bs/cm/service/ICmAttachService.java b/bs-admin/src/main/java/com/bs/cm/service/ICmAttachService.java deleted file mode 100644 index c387dd4..0000000 --- a/bs-admin/src/main/java/com/bs/cm/service/ICmAttachService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.bs.cm.service; - -import com.bs.cm.domain.CmAttach; -import com.bs.common.core.domain.AjaxResult; -import com.github.yulichang.base.MPJBaseService; - -/** - * 附件信息Service接口 - * - * @author bs - * @date 2024-03-03 - */ -public interface ICmAttachService extends MPJBaseService{ - -} diff --git a/bs-admin/src/main/java/com/bs/cm/service/impl/CmAttachServiceImpl.java b/bs-admin/src/main/java/com/bs/cm/service/impl/CmAttachServiceImpl.java deleted file mode 100644 index 1c83609..0000000 --- a/bs-admin/src/main/java/com/bs/cm/service/impl/CmAttachServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.bs.cm.service.impl; - -import com.bs.cm.mapper.CmAttachMapper; -import com.bs.cm.domain.CmAttach; -import com.bs.cm.service.ICmAttachService; -import com.github.yulichang.base.MPJBaseServiceImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -/** - * 附件信息Service业务层处理 - * - * @author bs - * @date 2024-03-03 - */ -@Service -@Transactional(rollbackFor = Exception.class) -public class CmAttachServiceImpl extends MPJBaseServiceImpl implements ICmAttachService { - -} diff --git a/bs-admin/src/main/java/com/bs/web/controller/common/CommonController.java b/bs-admin/src/main/java/com/bs/web/controller/common/CommonController.java index 5257a2b..2dfce22 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/common/CommonController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/common/CommonController.java @@ -1,33 +1,25 @@ package com.bs.web.controller.common; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.bs.cm.domain.CmAttach; -import com.bs.cm.service.ICmAttachService; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import com.bs.common.config.BsConfig; import com.bs.common.constant.Constants; import com.bs.common.core.domain.AjaxResult; -import com.bs.common.exception.ServiceException; -import com.bs.common.utils.FileUtil; import com.bs.common.utils.StringUtils; import com.bs.common.utils.file.FileUploadUtils; import com.bs.common.utils.file.FileUtils; import com.bs.framework.config.ServerConfig; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** * 通用请求处理 @@ -36,29 +28,28 @@ import java.util.stream.Collectors; */ @RestController @RequestMapping("/common") -@Api(tags = "文件上传") -public class CommonController { +public class CommonController +{ private static final Logger log = LoggerFactory.getLogger(CommonController.class); @Autowired private ServerConfig serverConfig; - @Autowired - private ICmAttachService cmAttachService; - private static final String FILE_DELIMETER = ","; /** * 通用下载请求 * * @param fileName 文件名称 - * @param delete 是否删除 + * @param delete 是否删除 */ @GetMapping("/download") - @ApiOperation("文件下载") - public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { - try { - if (!FileUtils.checkAllowDownload(fileName)) { + public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) + { + try + { + if (!FileUtils.checkAllowDownload(fileName)) + { throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); } String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); @@ -67,70 +58,39 @@ public class CommonController { response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); FileUtils.setAttachmentResponseHeader(response, realFileName); FileUtils.writeBytes(filePath, response.getOutputStream()); - if (delete) { + if (delete) + { FileUtils.deleteFile(filePath); } - } catch (Exception e) { - log.error("下载文件失败", e); } - } - - - @ApiOperation("根据attachId下载对应文件") - @GetMapping("/fileDownloadById") - public void fileDownloadById(String attachId,HttpServletResponse response, HttpServletRequest request) { - if (StringUtils.isBlank(attachId) || "null".equals(attachId)) { - throw new ServiceException("附件ID不能为空"); + catch (Exception e) + { + log.error("下载文件失败", e); } - CmAttach cmAttach = cmAttachService.getById(attachId); - String path =cmAttach.getAttachFileUrl(); - path =BsConfig.getFilePath()+path; -// Constants.RESOURCE_PREFIX - path = path.replace(Constants.RESOURCE_PREFIX, ""); - File compressedImageFile = new File(path); - response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); - FileUtil.downloadFile(request, response, compressedImageFile, false); } - - /** * 通用上传请求(单个) */ @PostMapping("/upload") - @ApiOperation("单文件上传") - public AjaxResult uploadFile(MultipartFile file,String fileId) throws Exception { - try { + public AjaxResult uploadFile(MultipartFile file) throws Exception + { + try + { // 上传文件路径 String filePath = BsConfig.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; - String newFileName = FileUtils.getName(fileName); - String originalFilename = file.getOriginalFilename(); - CmAttach cmAttach = new CmAttach(); - cmAttach.setFileId(fileId); - cmAttach.setFileSort(1); - cmAttach.setAttachName(newFileName); - cmAttach.setAttachContentType(file.getContentType()); - cmAttach.setAttachFileSize(file.getSize()); - String suffix = FileUtil.getExtensionName(originalFilename); - String type = FileUtil.getFileType(suffix); - cmAttach.setAttachFileType(type); - cmAttach.setAttachFileUrl(fileName); - cmAttach.setOldName(originalFilename); - cmAttach.setVersionNo("1"); - cmAttach.setRemark(""); - cmAttachService.save(cmAttach); AjaxResult ajax = AjaxResult.success(); ajax.put("url", url); ajax.put("fileName", fileName); - ajax.put("newFileName", newFileName); - ajax.put("cmAttach", cmAttach); - ajax.put("originalFilename", originalFilename); + ajax.put("newFileName", FileUtils.getName(fileName)); + ajax.put("originalFilename", file.getOriginalFilename()); return ajax; - } catch (Exception e) { - e.printStackTrace(); + } + catch (Exception e) + { return AjaxResult.error(e.getMessage()); } } @@ -139,143 +99,50 @@ public class CommonController { * 通用上传请求(多个) */ @PostMapping("/uploads") - @ApiOperation("多文件上传") - public AjaxResult uploadFiles(List files, String fileId) throws Exception { - try { + public AjaxResult uploadFiles(List files) throws Exception + { + try + { // 上传文件路径 String filePath = BsConfig.getUploadPath(); List urls = new ArrayList(); List fileNames = new ArrayList(); List newFileNames = new ArrayList(); List originalFilenames = new ArrayList(); - List cmAttachList = new ArrayList<>(); - for (MultipartFile file : files) { + for (MultipartFile file : files) + { // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; urls.add(url); fileNames.add(fileName); - String newFileName = FileUtils.getName(fileName); - newFileNames.add(newFileName); - String originalFilename = file.getOriginalFilename(); - originalFilenames.add(originalFilename); - CmAttach cmAttach = new CmAttach(); - cmAttach.setFileId(fileId); - cmAttach.setFileSort(1); - cmAttach.setAttachName(newFileName); - cmAttach.setAttachContentType(file.getContentType()); - cmAttach.setAttachFileSize(file.getSize()); - String suffix = FileUtil.getExtensionName(originalFilename); - String type = FileUtil.getFileType(suffix); - cmAttach.setAttachFileType(type); - cmAttach.setAttachFileUrl(fileName); - cmAttach.setOldName(originalFilename); - cmAttach.setVersionNo("1"); - cmAttach.setRemark(""); - cmAttachList.add(cmAttach); + newFileNames.add(FileUtils.getName(fileName)); + originalFilenames.add(file.getOriginalFilename()); } - cmAttachService.saveBatch(cmAttachList); AjaxResult ajax = AjaxResult.success(); ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); return ajax; - } catch (Exception e) { - e.printStackTrace(); - return AjaxResult.error(e.getMessage()); - } - } - - /** - * 上查询文件列表 - * @param fileId - * @param type - * @return - */ - @ApiOperation("根据fileId查找附件列表") - @GetMapping(value = "/getAttachList/{fileId}") - public AjaxResult getAttachVo(@PathVariable String fileId, String type) { - if (org.apache.commons.lang3.StringUtils.isBlank(fileId) || "null".equals(fileId)) { - return AjaxResult.error("fileId不能为空"); - } else if ("undefined".equals(fileId)) { - return AjaxResult.success(); - } - List attachVo = cmAttachService.list(new LambdaQueryWrapper().eq(CmAttach::getFileId,fileId)); - //压缩图片 - return AjaxResult.success(attachVo); - } - - /** - * 根据fileIds查找附件列表 - * @param fileIds - * @return - */ - @ApiOperation("根据fileIds查找附件列表") - @GetMapping(value = "/getFileIdsByAttachVos") - public AjaxResult getFileIdsByAttachVos(String[] fileIds) { - LambdaQueryWrapper refWrapper = new LambdaQueryWrapper(); - if (null != fileIds && fileIds.length > 0) { - refWrapper.in(CmAttach::getFileId, fileIds); - List refs = cmAttachService.list(refWrapper); - //通过fileId进行分组 - Map> attachVoMap = refs.stream().collect(Collectors.groupingBy(CmAttach::getFileId)); - return AjaxResult.success(attachVoMap); - } else { - return AjaxResult.warn("请输入文件fileIds!"); } - } - - - @ApiOperation("根据fileId删除表及对应文件") - @DeleteMapping(value = "/deleteFileByFileId/{fileId}") - public AjaxResult deleteFileByFileId(@PathVariable String fileId) { - if (org.apache.commons.lang3.StringUtils.isBlank(fileId) || "null".equals(fileId)) { - return AjaxResult.error("fileId不能为空"); - } - List cmAttachs = cmAttachService.list(new LambdaQueryWrapper().eq(CmAttach::getFileId,fileId)); - cmAttachs.forEach(cmAttach->{ - String path =cmAttach.getAttachFileUrl(); - /* path = path.replace(Constants.RESOURCE_PREFIX, ""); - path = path.replace(cmAttach.getAttachName(), ""); - path =BsConfig.getFilePath()+path+"xt_"+cmAttach.getAttachName();*/ - path =BsConfig.getFilePath()+path; - File compressedImageFile = new File(path); - if (compressedImageFile.exists()) { - FileUtil.del(compressedImageFile); - } - }); - cmAttachService.remove(new LambdaQueryWrapper().eq(CmAttach::getFileId,fileId)); - return AjaxResult.success(); - } - - - @ApiOperation("根据attachId删除表及对应文件") - @DeleteMapping(value = "/deleteFile/{attachId}") - public AjaxResult deleteFile(@PathVariable Long attachId) { - if (attachId==null) { - return AjaxResult.error("attachId不能为空"); - } - CmAttach cmAttach = cmAttachService.getById(attachId); - String path =cmAttach.getAttachFileUrl(); - path =BsConfig.getFilePath()+path; - File compressedImageFile = new File(path); - if (compressedImageFile.exists()) { - FileUtil.del(compressedImageFile); + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); } - cmAttachService.removeById(attachId); - return AjaxResult.success(); } - /** * 本地资源通用下载 */ @GetMapping("/download/resource") public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) - throws Exception { - try { - if (!FileUtils.checkAllowDownload(resource)) { + throws Exception + { + try + { + if (!FileUtils.checkAllowDownload(resource)) + { throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); } // 本地资源路径 @@ -287,7 +154,9 @@ public class CommonController { response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); FileUtils.setAttachmentResponseHeader(response, downloadName); FileUtils.writeBytes(downloadPath, response.getOutputStream()); - } catch (Exception e) { + } + catch (Exception e) + { log.error("下载文件失败", e); } } diff --git a/bs-admin/src/main/java/com/bs/web/controller/monitor/SysUserOnlineController.java b/bs-admin/src/main/java/com/bs/web/controller/monitor/SysUserOnlineController.java index 9a2bfa9..9200f25 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/monitor/SysUserOnlineController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/monitor/SysUserOnlineController.java @@ -1,6 +1,16 @@ package com.bs.web.controller.monitor; -import cn.hutool.core.lang.Validator; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import com.bs.common.annotation.Log; import com.bs.common.constant.CacheConstants; import com.bs.common.core.controller.BaseController; @@ -12,14 +22,6 @@ import com.bs.common.enums.BusinessType; import com.bs.common.utils.StringUtils; import com.bs.system.domain.SysUserOnline; import com.bs.system.service.ISysUserOnlineService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; /** * 在线用户监控 @@ -45,15 +47,15 @@ public class SysUserOnlineController extends BaseController for (String key : keys) { LoginUser user = redisCache.getCacheObject(key); - if (Validator.isNotEmpty(ipaddr) && Validator.isNotEmpty(userName)) + if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); } - else if (Validator.isNotEmpty(ipaddr)) + else if (StringUtils.isNotEmpty(ipaddr)) { userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); } - else if (Validator.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) + else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) { userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); } diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysLoginController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysLoginController.java index e10a8fc..4af0c4e 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysLoginController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/system/SysLoginController.java @@ -1,29 +1,25 @@ package com.bs.web.controller.system; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; import com.bs.common.constant.Constants; import com.bs.common.core.domain.AjaxResult; import com.bs.common.core.domain.entity.SysMenu; import com.bs.common.core.domain.entity.SysUser; -import com.bs.common.core.domain.entity.TenantConfig; import com.bs.common.core.domain.model.LoginBody; import com.bs.common.utils.SecurityUtils; import com.bs.framework.web.service.SysLoginService; import com.bs.framework.web.service.SysPermissionService; import com.bs.system.service.ISysMenuService; -import com.bs.system.service.ITenantConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Set; /** * 登录验证 - * + * * @author bs */ @RestController @@ -38,12 +34,9 @@ public class SysLoginController @Autowired private SysPermissionService permissionService; - @Autowired - private ITenantConfigService tenantConfigService; - /** * 登录方法 - * + * * @param loginBody 登录信息 * @return 结果 */ @@ -60,24 +53,19 @@ public class SysLoginController /** * 获取用户信息 - * + * * @return 用户信息 */ @GetMapping("getInfo") public AjaxResult getInfo() { SysUser user = SecurityUtils.getLoginUser().getUser(); - TenantConfig tenantConfig = tenantConfigService.getOne(new LambdaQueryWrapper().eq(TenantConfig::getId, user.getTenantId())); // 角色集合 Set roles = permissionService.getRolePermission(user); // 权限集合 Set permissions = permissionService.getMenuPermission(user); - if(tenantConfig==null){ - tenantConfig = new TenantConfig(); - } AjaxResult ajax = AjaxResult.success(); ajax.put("user", user); - ajax.put("tenantConfig", tenantConfig); ajax.put("roles", roles); ajax.put("permissions", permissions); return ajax; @@ -85,7 +73,7 @@ public class SysLoginController /** * 获取路由信息 - * + * * @return 路由信息 */ @GetMapping("getRouters") diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysMenuController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysMenuController.java index 54dffc9..7e748b2 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysMenuController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/system/SysMenuController.java @@ -1,6 +1,17 @@ package com.bs.web.controller.system; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import com.bs.common.annotation.Log; import com.bs.common.constant.UserConstants; import com.bs.common.core.controller.BaseController; @@ -8,18 +19,11 @@ import com.bs.common.core.domain.AjaxResult; import com.bs.common.core.domain.entity.SysMenu; import com.bs.common.enums.BusinessType; import com.bs.common.utils.StringUtils; -import com.bs.system.mapper.SysMenuMapper; import com.bs.system.service.ISysMenuService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; /** * 菜单信息 - * + * * @author bs */ @RestController @@ -28,8 +32,6 @@ public class SysMenuController extends BaseController { @Autowired private ISysMenuService menuService; - @Autowired - private SysMenuMapper sysMenuMapper; /** * 获取菜单列表 @@ -127,13 +129,14 @@ public class SysMenuController extends BaseController @DeleteMapping("/{menuId}") public AjaxResult remove(@PathVariable("menuId") Long menuId) { - + if (menuService.hasChildByMenuId(menuId)) + { + return warn("存在子菜单,不允许删除"); + } if (menuService.checkMenuExistRole(menuId)) { return warn("菜单已分配,不允许删除"); } - //select count(1) from sys_menu where parent_id = #{menuId} - sysMenuMapper.delete(new LambdaQueryWrapper().eq(SysMenu::getParentId, menuId)); return toAjax(menuService.deleteMenuById(menuId)); } } diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysNoticeController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysNoticeController.java index ee8aeb5..f30550a 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysNoticeController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/system/SysNoticeController.java @@ -1,17 +1,14 @@ package com.bs.web.controller.system; import java.util.List; -import javax.servlet.http.HttpServletResponse; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -20,151 +17,75 @@ import com.bs.common.core.controller.BaseController; import com.bs.common.core.domain.AjaxResult; import com.bs.common.core.page.TableDataInfo; import com.bs.common.enums.BusinessType; -import com.bs.common.utils.poi.ExcelUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import cn.hutool.core.lang.Validator; import com.bs.system.domain.SysNotice; import com.bs.system.service.ISysNoticeService; -import javax.annotation.Resource; /** - * 通知公告Controller + * 公告 信息操作处理 * * @author bs - * @date 2023-08-06 */ -@Api(tags = "通知公告") @RestController @RequestMapping("/system/notice") -public class SysNoticeController extends BaseController { - @Resource - private ISysNoticeService sysNoticeService; +public class SysNoticeController extends BaseController +{ + @Autowired + private ISysNoticeService noticeService; /** - * 分页查询通知公告列表 + * 获取通知公告列表 */ - @ApiOperation("分页查询通知公告列表") - @GetMapping("/pageList") - public TableDataInfo pageList(SysNotice sysNotice) { + @PreAuthorize("@ss.hasPermi('system:notice:list')") + @GetMapping("/list") + public TableDataInfo list(SysNotice notice) + { startPage(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper,sysNotice); - List list = sysNoticeService.list(queryWrapper); + List list = noticeService.selectNoticeList(notice); return getDataTable(list); } /** - * 查询通知公告列表 - */ - @ApiOperation("查询通知公告列表") - @GetMapping("/list") - public AjaxResult list(SysNotice sysNotice) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper,sysNotice); - List list = sysNoticeService.list(queryWrapper); - return success(list); - } - - /** - * 导出通知公告列表 - */ - @ApiOperation("导出通知公告列表") - @Log(title = "通知公告导出", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, SysNotice sysNotice) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper,sysNotice); - List list = sysNoticeService.list(queryWrapper); - ExcelUtil util = new ExcelUtil(SysNotice. class); - util.exportExcel(response, list, "通知公告数据"); - } - - /** - * 获取通知公告详细信息 + * 根据通知公告编号获取详细信息 */ - @ApiOperation("获取通知公告详细信息") + @PreAuthorize("@ss.hasPermi('system:notice:query')") @GetMapping(value = "/{noticeId}") - public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId) { - return success(sysNoticeService.getById(noticeId)); + public AjaxResult getInfo(@PathVariable Long noticeId) + { + return success(noticeService.selectNoticeById(noticeId)); } /** * 新增通知公告 */ - @ApiOperation("新增通知公告") - @Log(title = "通知公告新增", businessType = BusinessType.INSERT) + @PreAuthorize("@ss.hasPermi('system:notice:add')") + @Log(title = "通知公告", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody SysNotice sysNotice) { - return toAjax(sysNoticeService.save(sysNotice)); + public AjaxResult add(@Validated @RequestBody SysNotice notice) + { + notice.setCreateBy(getUsername()); + return toAjax(noticeService.insertNotice(notice)); } /** * 修改通知公告 */ - @ApiOperation("修改通知公告") - @Log(title = "通知公告修改", businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('system:notice:edit')") + @Log(title = "通知公告", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody SysNotice sysNotice) { - return toAjax(sysNoticeService.updateById(sysNotice)); + public AjaxResult edit(@Validated @RequestBody SysNotice notice) + { + notice.setUpdateBy(getUsername()); + return toAjax(noticeService.updateNotice(notice)); } /** * 删除通知公告 */ - @ApiOperation("删除通知公告") - @Log(title = "通知公告删除", businessType = BusinessType.DELETE) + @PreAuthorize("@ss.hasPermi('system:notice:remove')") + @Log(title = "通知公告", businessType = BusinessType.DELETE) @DeleteMapping("/{noticeIds}") - public AjaxResult remove(@PathVariable List noticeIds) { - return toAjax(sysNoticeService.removeBatchByIds(noticeIds)); + public AjaxResult remove(@PathVariable Long[] noticeIds) + { + return toAjax(noticeService.deleteNoticeByIds(noticeIds)); } - - /** - * 条件设置 - */ - private void condition (LambdaQueryWrapper queryWrapper,SysNotice sysNotice){ - - - //公告标题 - if(Validator.isNotEmpty(sysNotice.getNoticeTitle())){ - queryWrapper.eq(SysNotice::getNoticeTitle,sysNotice.getNoticeTitle()); - } - - //公告类型sys_notice_type字典(1通知 2公告) - if(Validator.isNotEmpty(sysNotice.getNoticeType())){ - queryWrapper.eq(SysNotice::getNoticeType,sysNotice.getNoticeType()); - } - - //公告内容 - if(Validator.isNotEmpty(sysNotice.getNoticeContent())){ - queryWrapper.eq(SysNotice::getNoticeContent,sysNotice.getNoticeContent()); - } - - //公告状态(0正常 1关闭) - if(Validator.isNotEmpty(sysNotice.getStatus())){ - queryWrapper.eq(SysNotice::getStatus,sysNotice.getStatus()); - } - - //阅读状态(0未阅读 1已阅读) - if(Validator.isNotEmpty(sysNotice.getReadStatus())){ - queryWrapper.eq(SysNotice::getReadStatus,sysNotice.getReadStatus()); - } - - //查看人 - if(sysNotice.getReadUser()!=null){ - queryWrapper.eq(SysNotice::getReadUser,sysNotice.getReadUser()); - } - - //删除标志(0代表存在 2代表删除) - if(Validator.isNotEmpty(sysNotice.getDelFlag())){ - queryWrapper.eq(SysNotice::getDelFlag,sysNotice.getDelFlag()); - } - - - //创建人 - if(sysNotice.getCreateBy()!=null){ - queryWrapper.eq(SysNotice::getCreateBy,sysNotice.getCreateBy()); - } - - } - } diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysProfileController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysProfileController.java index a1410d7..853aa6d 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysProfileController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/system/SysProfileController.java @@ -1,24 +1,27 @@ package com.bs.web.controller.system; -import cn.hutool.core.lang.Validator; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import com.bs.common.annotation.Log; import com.bs.common.config.BsConfig; import com.bs.common.core.controller.BaseController; import com.bs.common.core.domain.AjaxResult; -import com.bs.common.core.domain.entity.SysTenant; import com.bs.common.core.domain.entity.SysUser; import com.bs.common.core.domain.model.LoginUser; import com.bs.common.enums.BusinessType; import com.bs.common.utils.SecurityUtils; +import com.bs.common.utils.StringUtils; import com.bs.common.utils.file.FileUploadUtils; import com.bs.common.utils.file.MimeTypeUtils; import com.bs.framework.web.service.TokenService; import com.bs.system.service.ISysUserService; -import com.bs.system.service.SysTenantService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; /** * 个人信息 业务处理 @@ -31,8 +34,6 @@ public class SysProfileController extends BaseController { @Autowired private ISysUserService userService; - @Autowired - private SysTenantService sysTenantService; @Autowired private TokenService tokenService; @@ -61,11 +62,11 @@ public class SysProfileController extends BaseController LoginUser loginUser = getLoginUser(); SysUser sysUser = loginUser.getUser(); user.setUserName(sysUser.getUserName()); - if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) + if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); } - if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) + if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } @@ -106,13 +107,6 @@ public class SysProfileController extends BaseController } if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) { - SysUser user = userService.getOne(new LambdaQueryWrapper().eq(SysUser::getUserName, userName)); - //如果是租户管理员,密码写一份到租户信息 - if(user.getIsTenantAdmin().equals("Y")){ - SysTenant sysTenant = sysTenantService.getById(user.getTenantId()); - sysTenant.setPassword(newPassword); - sysTenantService.updateById(sysTenant); - } // 更新缓存用户密码 loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); tokenService.setLoginUser(loginUser); diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysTenantController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysTenantController.java deleted file mode 100644 index f607b28..0000000 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysTenantController.java +++ /dev/null @@ -1,335 +0,0 @@ -package com.bs.web.controller.system; - -import cn.hutool.core.lang.Validator; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.bs.common.annotation.Log; -import com.bs.common.core.controller.BaseController; -import com.bs.common.core.domain.AjaxResult; -import com.bs.common.core.domain.entity.SysDept; -import com.bs.common.core.domain.entity.SysTenant; -import com.bs.common.core.domain.entity.SysUser; -import com.bs.common.core.page.TableDataInfo; -import com.bs.common.enums.BusinessType; -import com.bs.common.utils.SecurityUtils; -import com.bs.common.utils.poi.ExcelUtil; -import com.bs.system.domain.SysPost; -import com.bs.system.domain.SysUserRole; -import com.bs.system.mapper.SysDeptMapper; -import com.bs.system.mapper.SysPostMapper; -import com.bs.system.mapper.SysUserMapper; -import com.bs.system.mapper.SysUserRoleMapper; -import com.bs.system.service.ISysUserService; -import com.bs.system.service.SysTenantService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 租户信息Controller - * - * @author bs - * @date 2024-02-22 - */ -@Api(tags = "租户信息") -@RestController -@RequestMapping("/system/tenant") -public class SysTenantController extends BaseController { - @Resource - private SysTenantService sysTenantService; - @Autowired - private ISysUserService userService; - - @Autowired - private SysUserMapper userMapper; - @Autowired - private SysUserRoleMapper sysUserRoleMapper; - - @Autowired - private SysDeptMapper deptMapper; - - @Autowired - private SysPostMapper postMapepr; - - /** - * 分页查询租户信息列表 - */ - @ApiOperation("分页查询租户信息列表") - @GetMapping("/pageList") - public TableDataInfo pageList(SysTenant sysTenant) { - startPage(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, sysTenant); - List list = sysTenantService.list(queryWrapper); - return getDataTable(list); - } - - /** - * 查询租户信息列表 - */ - @ApiOperation("查询租户信息列表") - @GetMapping("/list") - public AjaxResult list(SysTenant sysTenant) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, sysTenant); - List list = sysTenantService.list(queryWrapper); - return success(list); - } - - /** - * 导出租户信息列表 - */ - @ApiOperation("导出租户信息列表") - @Log(title = "租户信息导出", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, SysTenant sysTenant) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, sysTenant); - List list = sysTenantService.list(queryWrapper); - ExcelUtil util = new ExcelUtil(SysTenant.class); - util.exportExcel(response, list, "租户信息数据"); - } - - /** - * 获取租户信息详细信息 - */ - @ApiOperation("获取租户信息详细信息") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) { - final SysTenant sysTenant = sysTenantService.getById(id); - SysUser sysUser = userMapper.selectTenantAdmin(sysTenant.getId()); - final List sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper().eq(SysUserRole::getUserId, sysUser.getUserId())); - final List roleIds = sysUserRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); - sysTenant.setRoleIds(roleIds); - return success(sysTenant); - } - - /** - * 新增租户信息 - */ - @ApiOperation("新增租户信息") - @Log(title = "租户信息新增", businessType = BusinessType.INSERT) - @PostMapping - @Transactional(rollbackFor = Exception.class) - public AjaxResult add(@RequestBody SysTenant sysTenant) { - //新增租户的时候,进行租户管理员账号的添加 - sysTenantService.save(sysTenant); - SysUser user = new SysUser(); - user.setNickName(sysTenant.getName() + "管理员"); - user.setUserName(sysTenant.getUserName()); - user.setPassword(sysTenant.getPassword()); - user.setStatus("0"); - user.setIsTenant("Y"); - user.setIsTenantAdmin("Y"); - user.setPhonenumber(sysTenant.getContactPhone()); - if (!userService.checkUserNameUnique(user)) { - return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); - } - if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { - return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); - } - user.setCreateBy(getUsername()); - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setTenantId(sysTenant.getId()); - - initTenantDate(user); - userMapper.insert(user); - List userRoles = new ArrayList<>(); - sysTenant.getRoleIds().forEach(roleId -> { - SysUserRole sysUserRole = new SysUserRole(); - sysUserRole.setUserId(user.getUserId()); - sysUserRole.setRoleId(roleId); - userRoles.add(sysUserRole); - }); - sysUserRoleMapper.insertBatch(userRoles); - return success("添加成功"); - } - - /** - * 初始化租户的数据 - * 新建部门,复制一份基础租户的角色,配置给admin - * 复制一份字典给租户 - */ - public void initTenantDate(SysUser user) { - //查询 sys_dept 表,租户id为空的,复制一份 - //初始化部门 - SysDept parentsysDepts = new SysDept(); - parentsysDepts.setParentId(0L); - parentsysDepts.setDeptName("总公司"); - parentsysDepts.setOrderNum(0); - parentsysDepts.setAncestors("0"); - parentsysDepts.setLeader("admin"); - parentsysDepts.setPhone("15888888888"); - parentsysDepts.setEmail("zgs@qq.com"); - parentsysDepts.setTenantId(user.getTenantId()); - deptMapper.insert(parentsysDepts); - SysDept sonSysDepts = new SysDept(); - sonSysDepts.setParentId(parentsysDepts.getDeptId()); - sonSysDepts.setDeptName("福建分公司"); - sonSysDepts.setOrderNum(1); - //祖辈id列表 - sonSysDepts.setAncestors("0," + parentsysDepts.getDeptId()); - sonSysDepts.setLeader("admin"); - sonSysDepts.setPhone("15888888888"); - sonSysDepts.setEmail("zgs@qq.com"); - sonSysDepts.setTenantId(user.getTenantId()); - deptMapper.insert(sonSysDepts); - //初始化岗位 - List sysPosts = postMapepr.selectList(new LambdaQueryWrapper().eq(SysPost::getDelFlag, "0").eq(SysPost::getTenantId, "0")); - sysPosts.forEach(ele -> { - ele.setTenantId(user.getTenantId()); - ele.setPostId(null); - }); - postMapepr.insertBatch(sysPosts); - //最高部门 - user.setDeptId(parentsysDepts.getDeptId()); - //ceo - Long[] postIds = new Long[1]; - sysPosts.forEach(ele -> { - if (ele.getPostCode().equals("ceo")) { - postIds[0] = ele.getPostId(); - } - }); - user.setPostIds(postIds); - } - - - /** - * 修改租户信息 - */ - @ApiOperation("修改租户信息") - @Log(title = "租户信息修改", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody SysTenant sysTenant) { - //修改租户,判断密码是否有更换,如有更换进行修改用户密码 - SysTenant tenant = sysTenantService.getById(sysTenant.getId()); - SysUser user = userMapper.selectTenantAdmin(sysTenant.getId()); - if (!tenant.getPassword().equals(sysTenant.getPassword()) || !tenant.getUserName().equals(sysTenant.getUserName())) { - - user.setPassword(SecurityUtils.encryptPassword(sysTenant.getPassword())); - user.setUserName(sysTenant.getUserName()); - userService.resetPwd(user); - } - //修改租户的角色信息 - sysUserRoleMapper.delete(new LambdaUpdateWrapper().eq(SysUserRole::getUserId, user.getUserId())); - List userRoles = new ArrayList<>(); - sysTenant.getRoleIds().forEach(roleId -> { - SysUserRole sysUserRole = new SysUserRole(); - sysUserRole.setUserId(user.getUserId()); - sysUserRole.setRoleId(roleId); - userRoles.add(sysUserRole); - }); - if(userRoles.size()>0){ - sysUserRoleMapper.insertBatch(userRoles); - } - return toAjax(sysTenantService.updateById(sysTenant)); - } - - /** - * 删除租户信息 - */ - @ApiOperation("删除租户信息") - @Log(title = "租户信息删除", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable List ids) { - return toAjax(sysTenantService.removeBatchByIds(ids)); - } - - /** - * 条件设置 - */ - private void condition(LambdaQueryWrapper queryWrapper, SysTenant sysTenant) { - - - //用户ID - if (Validator.isNotEmpty(sysTenant.getId())) { - queryWrapper.eq(SysTenant::getId, sysTenant.getId()); - } - - //租户名 - if (Validator.isNotEmpty(sysTenant.getName())) { - queryWrapper.eq(SysTenant::getName, sysTenant.getName()); - } - - //租户简名 - if (Validator.isNotEmpty(sysTenant.getSimpleName())) { - queryWrapper.eq(SysTenant::getSimpleName, sysTenant.getSimpleName()); - } - - //行政区划 - if (Validator.isNotEmpty(sysTenant.getAreaCode())) { - queryWrapper.eq(SysTenant::getAreaCode, sysTenant.getAreaCode()); - } - - - //租户密码 - if (Validator.isNotEmpty(sysTenant.getPassword())) { - queryWrapper.eq(SysTenant::getPassword, sysTenant.getPassword()); - } - - //租户账号 - if (Validator.isNotEmpty(sysTenant.getUserName())) { - queryWrapper.eq(SysTenant::getUserName, sysTenant.getUserName()); - } - - //联系人 - if (Validator.isNotEmpty(sysTenant.getContactUser())) { - queryWrapper.eq(SysTenant::getContactUser, sysTenant.getContactUser()); - } - - //联系电话 - if (Validator.isNotEmpty(sysTenant.getContactPhone())) { - queryWrapper.eq(SysTenant::getContactPhone, sysTenant.getContactPhone()); - } - - //状态,启用1,禁用0,即将过期2 - if (Validator.isNotEmpty(sysTenant.getStatus())) { - queryWrapper.eq(SysTenant::getStatus, sysTenant.getStatus()); - } - - //创建部门 - if (Validator.isNotEmpty(sysTenant.getCreateDept())) { - queryWrapper.eq(SysTenant::getCreateDept, sysTenant.getCreateDept()); - } - - //创建人 - if (Validator.isNotEmpty(sysTenant.getCreateBy())) { - queryWrapper.eq(SysTenant::getCreateBy, sysTenant.getCreateBy()); - } - - //创建时间 - if (Validator.isNotEmpty(sysTenant.getCreateTime())) { - queryWrapper.eq(SysTenant::getCreateTime, sysTenant.getCreateTime()); - } - - //修改人 - if (Validator.isNotEmpty(sysTenant.getUpdateBy())) { - queryWrapper.eq(SysTenant::getUpdateBy, sysTenant.getUpdateBy()); - } - - //修改时间 - if (Validator.isNotEmpty(sysTenant.getUpdateTime())) { - queryWrapper.eq(SysTenant::getUpdateTime, sysTenant.getUpdateTime()); - } - - //备注 - if (Validator.isNotEmpty(sysTenant.getRemark())) { - queryWrapper.eq(SysTenant::getRemark, sysTenant.getRemark()); - } - - //删除标志(0代表存在 2代表删除) - if (Validator.isNotEmpty(sysTenant.getDelFlag())) { - queryWrapper.eq(SysTenant::getDelFlag, sysTenant.getDelFlag()); - } - - } - -} diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/SysUserController.java b/bs-admin/src/main/java/com/bs/web/controller/system/SysUserController.java index c9a00ec..92cfe03 100644 --- a/bs-admin/src/main/java/com/bs/web/controller/system/SysUserController.java +++ b/bs-admin/src/main/java/com/bs/web/controller/system/SysUserController.java @@ -1,7 +1,21 @@ package com.bs.web.controller.system; -import cn.hutool.core.lang.Validator; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.List; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import com.bs.common.annotation.Log; import com.bs.common.core.controller.BaseController; import com.bs.common.core.domain.AjaxResult; @@ -13,22 +27,10 @@ import com.bs.common.enums.BusinessType; import com.bs.common.utils.SecurityUtils; import com.bs.common.utils.StringUtils; import com.bs.common.utils.poi.ExcelUtil; -import com.bs.system.domain.SysUserRole; -import com.bs.system.mapper.SysUserRoleMapper; import com.bs.system.service.ISysDeptService; import com.bs.system.service.ISysPostService; import com.bs.system.service.ISysRoleService; import com.bs.system.service.ISysUserService; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.stream.Collectors; /** * 用户信息 @@ -37,16 +39,14 @@ import java.util.stream.Collectors; */ @RestController @RequestMapping("/system/user") -public class SysUserController extends BaseController { +public class SysUserController extends BaseController +{ @Autowired private ISysUserService userService; @Autowired private ISysRoleService roleService; - @Autowired - private SysUserRoleMapper sysUserRoleMapper; - @Autowired private ISysDeptService deptService; @@ -58,7 +58,8 @@ public class SysUserController extends BaseController { */ @PreAuthorize("@ss.hasPermi('system:user:list')") @GetMapping("/list") - public TableDataInfo list(SysUser user) { + public TableDataInfo list(SysUser user) + { startPage(); List list = userService.selectUserList(user); return getDataTable(list); @@ -67,7 +68,8 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:user:export')") @PostMapping("/export") - public void export(HttpServletResponse response, SysUser user) { + public void export(HttpServletResponse response, SysUser user) + { List list = userService.selectUserList(user); ExcelUtil util = new ExcelUtil(SysUser.class); util.exportExcel(response, list, "用户数据"); @@ -76,7 +78,8 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:user:import')") @PostMapping("/importData") - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { ExcelUtil util = new ExcelUtil(SysUser.class); List userList = util.importExcel(file.getInputStream()); Long operName = getUsername(); @@ -85,7 +88,8 @@ public class SysUserController extends BaseController { } @PostMapping("/importTemplate") - public void importTemplate(HttpServletResponse response) { + public void importTemplate(HttpServletResponse response) + { ExcelUtil util = new ExcelUtil(SysUser.class); util.importTemplateExcel(response, "用户数据"); } @@ -94,49 +98,44 @@ public class SysUserController extends BaseController { * 根据用户编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('system:user:query')") - @GetMapping(value = {"/", "/{userId}"}) - public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { + @GetMapping(value = { "/", "/{userId}" }) + public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) + { userService.checkUserDataScope(userId); AjaxResult ajax = AjaxResult.success(); List roles = roleService.selectRoleAll(); ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); ajax.put("posts", postService.selectPostAll()); - if (StringUtils.isNotNull(userId)) { + if (StringUtils.isNotNull(userId)) + { SysUser sysUser = userService.selectUserById(userId); - final List sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper().eq(SysUserRole::getUserId, userId)); ajax.put(AjaxResult.DATA_TAG, sysUser); ajax.put("postIds", postService.selectPostListByUserId(userId)); - ajax.put("roleIds", sysUserRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList())); + ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); } return ajax; } - - /** - 获取所有非admin角色,用于租户配置 - */ - @GetMapping("/getRoles") - public AjaxResult getRoles() { - List roles = roleService.selectRoleAll(); - return AjaxResult.success().put("roles", roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); - } - /** * 新增用户 */ @PreAuthorize("@ss.hasPermi('system:user:add')") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysUser user) { - if (!userService.checkUserNameUnique(user)) { + public AjaxResult add(@Validated @RequestBody SysUser user) + { + if (!userService.checkUserNameUnique(user)) + { return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); - } else if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) + { return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); - } else if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { + } + else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) + { return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } - user.setIsTenant(SecurityUtils.getLoginUser().getIsTenant()); - user.setIsTenantAdmin("N"); user.setCreateBy(getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); return toAjax(userService.insertUser(user)); @@ -148,14 +147,20 @@ public class SysUserController extends BaseController { @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@Validated @RequestBody SysUser user) { + public AjaxResult edit(@Validated @RequestBody SysUser user) + { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); - if (!userService.checkUserNameUnique(user)) { + if (!userService.checkUserNameUnique(user)) + { return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); - } else if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { + } + else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) + { return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); - } else if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { + } + else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) + { return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } user.setUpdateBy(getUsername()); @@ -168,8 +173,10 @@ public class SysUserController extends BaseController { @PreAuthorize("@ss.hasPermi('system:user:remove')") @Log(title = "用户管理", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") - public AjaxResult remove(@PathVariable Long[] userIds) { - if (ArrayUtils.contains(userIds, getUserId())) { + public AjaxResult remove(@PathVariable Long[] userIds) + { + if (ArrayUtils.contains(userIds, getUserId())) + { return error("当前用户不能删除"); } return toAjax(userService.deleteUserByIds(userIds)); @@ -181,7 +188,8 @@ public class SysUserController extends BaseController { @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") - public AjaxResult resetPwd(@RequestBody SysUser user) { + public AjaxResult resetPwd(@RequestBody SysUser user) + { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); @@ -195,7 +203,8 @@ public class SysUserController extends BaseController { @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysUser user) { + public AjaxResult changeStatus(@RequestBody SysUser user) + { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); user.setUpdateBy(getUsername()); @@ -207,7 +216,8 @@ public class SysUserController extends BaseController { */ @PreAuthorize("@ss.hasPermi('system:user:query')") @GetMapping("/authRole/{userId}") - public AjaxResult authRole(@PathVariable("userId") Long userId) { + public AjaxResult authRole(@PathVariable("userId") Long userId) + { AjaxResult ajax = AjaxResult.success(); SysUser user = userService.selectUserById(userId); List roles = roleService.selectRolesByUserId(userId); @@ -222,7 +232,8 @@ public class SysUserController extends BaseController { @PreAuthorize("@ss.hasPermi('system:user:edit')") @Log(title = "用户管理", businessType = BusinessType.GRANT) @PutMapping("/authRole") - public AjaxResult insertAuthRole(Long userId, Long[] roleIds) { + public AjaxResult insertAuthRole(Long userId, Long[] roleIds) + { userService.checkUserDataScope(userId); userService.insertUserAuth(userId, roleIds); return success(); @@ -233,7 +244,8 @@ public class SysUserController extends BaseController { */ @PreAuthorize("@ss.hasPermi('system:user:list')") @GetMapping("/deptTree") - public AjaxResult deptTree(SysDept dept) { + public AjaxResult deptTree(SysDept dept) + { return success(deptService.selectDeptTreeList(dept)); } } diff --git a/bs-admin/src/main/java/com/bs/web/controller/system/TenantConfigController.java b/bs-admin/src/main/java/com/bs/web/controller/system/TenantConfigController.java deleted file mode 100644 index aa4b542..0000000 --- a/bs-admin/src/main/java/com/bs/web/controller/system/TenantConfigController.java +++ /dev/null @@ -1,231 +0,0 @@ -package com.bs.web.controller.system; - -import cn.hutool.core.lang.Validator; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.bs.common.annotation.Log; -import com.bs.common.config.BsConfig; -import com.bs.common.core.controller.BaseController; -import com.bs.common.core.domain.AjaxResult; -import com.bs.common.core.domain.entity.TenantConfig; -import com.bs.common.core.page.TableDataInfo; -import com.bs.common.enums.BusinessType; -import com.bs.common.utils.file.FileUploadUtils; -import com.bs.common.utils.file.MimeTypeUtils; -import com.bs.common.utils.poi.ExcelUtil; -import com.bs.system.service.ITenantConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * 租户配置Controller - * - * @author ruoyi - * @date 2023-04-02 - */ -@RestController -@RequestMapping("/tenant/config") -public class TenantConfigController extends BaseController { - @Autowired - private ITenantConfigService tenantConfigService; - - /** - * 分页查询租户配置列表 - */ - @PreAuthorize("@ss.hasPermi('tenant:config:pageList')") - @GetMapping("/pageList") - public TableDataInfo pageList(TenantConfig tenantConfig) { - startPage(); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, tenantConfig); - List list = tenantConfigService.list(queryWrapper); - return getDataTable(list); - } - - /** - * 查询租户配置列表 - */ - @PreAuthorize("@ss.hasPermi('tenant:config:list')") - @GetMapping("/list") - public AjaxResult list(TenantConfig tenantConfig) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, tenantConfig); - List list = tenantConfigService.list(queryWrapper); - return success(list); - } - - /** - * 导出租户配置列表 - */ - @Log(title = "租户配置导出", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, TenantConfig tenantConfig) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - condition(queryWrapper, tenantConfig); - List list = tenantConfigService.list(queryWrapper); - ExcelUtil util = new ExcelUtil(TenantConfig.class); - util.exportExcel(response, list, "租户配置数据"); - } - - /** - * 获取租户配置详细信息 - */ - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") String id) { - TenantConfig tenantConfig = tenantConfigService.getById(id); - tenantConfig.setTenantId(tenantConfig.getId()) ; - return success(tenantConfig); - } - - /** - * 新增租户配置 - */ - @Log(title = "租户配置新增", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody TenantConfig tenantConfig) { - tenantConfig.setId(tenantConfig.getTenantId()) ; - return toAjax(tenantConfigService.save(tenantConfig)); - } - - /** - * 修改租户配置 - */ - @Log(title = "租户配置修改", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody TenantConfig tenantConfig) { - tenantConfig.setId(tenantConfig.getTenantId()) ; - return toAjax(tenantConfigService.updateById(tenantConfig)); - } - - /** - * 删除租户配置 - */ - @Log(title = "租户配置删除", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable List ids) { - return toAjax(tenantConfigService.removeBatchByIds(ids)); - } - - /** - * 租户logo图片上传 - */ - @Log(title = "租户logo图片上传", businessType = BusinessType.UPDATE) - @PostMapping("/logo") - public AjaxResult avatar(@RequestParam("tenantLogo") MultipartFile file) throws Exception { - if (!file.isEmpty()) { - String logo = FileUploadUtils.upload(BsConfig.getUploadPath(), file, MimeTypeUtils.IMAGE_EXTENSION); - AjaxResult ajax = success(); - ajax.put("imgUrl", logo); - return ajax; - } - return error("上传图片异常,请联系管理员"); - } - - - - /** - * 条件设置 - */ - private void condition(LambdaQueryWrapper queryWrapper, TenantConfig tenantConfig) { - - - //${column.columnComment} - if (Validator.isNotEmpty(tenantConfig.getId())) { - queryWrapper.eq(TenantConfig::getId, tenantConfig.getId()); - } - - //开始时间 - if (tenantConfig.getStartData() != null) { - queryWrapper.eq(TenantConfig::getStartData, tenantConfig.getStartData()); - } - - //结束时间 - if (tenantConfig.getStopData() != null) { - queryWrapper.eq(TenantConfig::getStopData, tenantConfig.getStopData()); - } - - //是否限制用户数 - if (Validator.isNotEmpty(tenantConfig.getIsUserAstrict())) { - queryWrapper.eq(TenantConfig::getIsUserAstrict, tenantConfig.getIsUserAstrict()); - } - - //用户数 - if (tenantConfig.getUserQuantity() != null) { - queryWrapper.eq(TenantConfig::getUserQuantity, tenantConfig.getUserQuantity()); - } - - //是否限制在线数 - if (Validator.isNotEmpty(tenantConfig.getIsOnLine())) { - queryWrapper.eq(TenantConfig::getIsOnLine, tenantConfig.getIsOnLine()); - } - - //在线数 - if (tenantConfig.getOnLineUserQuantity() != null) { - queryWrapper.eq(TenantConfig::getOnLineUserQuantity, tenantConfig.getOnLineUserQuantity()); - } - - //是否定义系统名称 - if (Validator.isNotEmpty(tenantConfig.getIsDefinitionName())) { - queryWrapper.eq(TenantConfig::getIsDefinitionName, tenantConfig.getIsDefinitionName()); - } - - //系统名称 - if (Validator.isNotEmpty(tenantConfig.getSysName())) { - queryWrapper.like(TenantConfig::getSysName, tenantConfig.getSysName()); - } - - //是否定义系统logo - if (Validator.isNotEmpty(tenantConfig.getIsDefinitionLogo())) { - queryWrapper.eq(TenantConfig::getIsDefinitionLogo, tenantConfig.getIsDefinitionLogo()); - } - - //系统log - if (Validator.isNotEmpty(tenantConfig.getSysLog())) { - queryWrapper.eq(TenantConfig::getSysLog, tenantConfig.getSysLog()); - } - - //是否定义系统色调 - if (Validator.isNotEmpty(tenantConfig.getIsDefinitionHue())) { - queryWrapper.eq(TenantConfig::getIsDefinitionHue, tenantConfig.getIsDefinitionHue()); - } - - //系统色调 - if (Validator.isNotEmpty(tenantConfig.getSysHue())) { - queryWrapper.eq(TenantConfig::getSysHue, tenantConfig.getSysHue()); - } - - //定制化数据,键值对{key:{type1:"",type2:"",value:""},key2:{type1:"",type2:"",value:""}}具体操作时候,做具体说明 - if (Validator.isNotEmpty(tenantConfig.getCustomizationFields())) { - queryWrapper.eq(TenantConfig::getCustomizationFields, tenantConfig.getCustomizationFields()); - } - - - //创建人员 - if (Validator.isNotEmpty(tenantConfig.getCreateBy())) { - queryWrapper.eq(TenantConfig::getCreateBy, tenantConfig.getCreateBy()); - } - - - //修改人员 - if (Validator.isNotEmpty(tenantConfig.getUpdateBy())) { - queryWrapper.eq(TenantConfig::getUpdateBy, tenantConfig.getUpdateBy()); - } - - - //部门ID - if (Validator.isNotEmpty(tenantConfig.getCreateDept())) { - queryWrapper.eq(TenantConfig::getCreateDept, tenantConfig.getCreateDept()); - } - - //删除标示 默认为1 有效数据 ,0为无效已删除 - if (Validator.isNotEmpty(tenantConfig.getDelFlag())) { - queryWrapper.eq(TenantConfig::getDelFlag, tenantConfig.getDelFlag()); - } - - } - -} diff --git a/bs-admin/src/main/java/com/bs/web/core/config/SwaggerConfig.java b/bs-admin/src/main/java/com/bs/web/core/config/SwaggerConfig.java index 13367a1..7561225 100644 --- a/bs-admin/src/main/java/com/bs/web/core/config/SwaggerConfig.java +++ b/bs-admin/src/main/java/com/bs/web/core/config/SwaggerConfig.java @@ -113,7 +113,7 @@ public class SwaggerConfig // 用ApiInfoBuilder进行定制 return new ApiInfoBuilder() // 设置标题 - .title("标题:保税仓库管理系统_接口文档") + .title("标题:若依管理系统_接口文档") // 描述 .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") // 作者信息 diff --git a/bs-admin/src/main/resources/application-druid.yml b/bs-admin/src/main/resources/application-druid.yml index a2fe2cb..b271cf9 100644 --- a/bs-admin/src/main/resources/application-druid.yml +++ b/bs-admin/src/main/resources/application-druid.yml @@ -1,68 +1,61 @@ # 数据源配置 spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - #url: jdbc:mysql://124.71.134.146:63306/bs-jxc-dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true - #username: root - #password: fastrise@chain - url: jdbc:mysql://localhost:3306/my-base?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true - username: root - password: abcd123 - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置连接超时时间 - connectTimeout: 30000 - # 配置网络超时时间 - socketTimeout: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: bs - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true -bs: - tenant: - #开启租户 - openTenant: true \ No newline at end of file + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/bs-jxc-dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true + username: root + password: abcd123 + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: bs + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true diff --git a/bs-admin/src/main/resources/application-priv.yml b/bs-admin/src/main/resources/application-priv.yml deleted file mode 100644 index f280d56..0000000 --- a/bs-admin/src/main/resources/application-priv.yml +++ /dev/null @@ -1,68 +0,0 @@ -# 数据源配置 -spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - #url: jdbc:mysql://124.71.134.146:63306/bs-jxc-dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true - #username: root - #password: fastrise@chain - url: jdbc:mysql://localhost:3306/bs-jxc-dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true - username: root - password: abcd123 - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置连接超时时间 - connectTimeout: 30000 - # 配置网络超时时间 - socketTimeout: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: bs - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true -bs: - tenant: - #关闭租户 - openTenant: false \ No newline at end of file diff --git a/bs-admin/src/main/resources/application-prot.yml b/bs-admin/src/main/resources/application-prot.yml deleted file mode 100644 index 76eb85f..0000000 --- a/bs-admin/src/main/resources/application-prot.yml +++ /dev/null @@ -1,66 +0,0 @@ -# 数据源配置 -spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://124.71.134.146:63306/bs-jxc-prot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true - username: root - password: fastrise@chain - - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置连接超时时间 - connectTimeout: 30000 - # 配置网络超时时间 - socketTimeout: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: bs - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true -bs: - tenant: - #开启租户 - openTenant: true \ No newline at end of file diff --git a/bs-admin/src/main/resources/application.yml b/bs-admin/src/main/resources/application.yml index 91ef24a..c51a2b4 100644 --- a/bs-admin/src/main/resources/application.yml +++ b/bs-admin/src/main/resources/application.yml @@ -1,11 +1,3 @@ -# Spring配置 -spring: - # 资源信息 - messages: - # 国际化资源文件路径 - basename: i18n/messages - profiles: - active: druid # 项目相关配置 bs: # 名称 @@ -18,37 +10,11 @@ bs: demoEnabled: true # 文件路径 示例( Windows配置D:/bs/uploadPath,Linux配置 /home/bs/uploadPath) profile: D:/bs/uploadPath - # 文件存储路径 windows 路径 - winLocalFilePath: D:/bs/uploadPath - # winLocalFilePath: E:/test - # 文件存储路径 linux 路径 - linuxLocalFilePath: /home/chain-mos/attachment - # 文件存储路径 mac 路径 - macLocalFilePath: ~/chain-mos/attachment # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数字计算 char 字符验证 - captchaType: char - tenant: - column: tenant_id - noIgnoreTables: - - sys_tenant - - tenant_config - - gen_table - - gen_table_column - - sys_user_role - - sys_dict_data - - sys_dict_type - - sys_job - - sys_job_log - - sys_logininfor - - sys_menu - - sys_oper_log - - sys_role_dept - - sys_role_menu - - sys_user_post - - sys_user_role - - sys_config + captchaType: math + # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 @@ -81,7 +47,14 @@ user: # 密码锁定时间(默认10分钟) lockTime: 10 - +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + profiles: + active: druid # 文件上传 servlet: multipart: @@ -101,7 +74,7 @@ user: # 端口,默认为6379 port: 6379 # 数据库索引 - database: 2 + database: 0 # 密码 password: # 连接超时时间 @@ -124,7 +97,7 @@ token: # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) - expireTime: 300 + expireTime: 30 # MyBatis Plus配置 diff --git a/bs-admin/src/main/resources/mapper/cm/CmAttachMapper.xml b/bs-admin/src/main/resources/mapper/cm/CmAttachMapper.xml deleted file mode 100644 index 75deb16..0000000 --- a/bs-admin/src/main/resources/mapper/cm/CmAttachMapper.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/bs-common/pom.xml b/bs-common/pom.xml index f8000de..8d951dd 100644 --- a/bs-common/pom.xml +++ b/bs-common/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - my-base + bs-jxc com.bs 3.8.6 @@ -16,29 +16,6 @@ - - org.apache.ant - ant - 1.9.15 - - - com.github.jsqlparser - jsqlparser - 4.2 - - - - com.alibaba - transmittable-thread-local - 2.13.0 - - - - - - com.github.xiaoymin - knife4j-spring-boot-starter - com.alibaba @@ -72,11 +49,7 @@ org.springframework spring-context-support - - - cn.hutool - hutool-all - + org.springframework diff --git a/bs-common/src/main/java/com/bs/common/annotation/TenantClear.java b/bs-common/src/main/java/com/bs/common/annotation/TenantClear.java deleted file mode 100644 index 74e1bdd..0000000 --- a/bs-common/src/main/java/com/bs/common/annotation/TenantClear.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.bs.common.annotation;/** - * @作者 tjw - * @创建时间 2024-03-02-15:11 - * @说明 : - */ - -import java.lang.annotation.*; - -/** - * @author tjw - * @since 2023/11/21 20:41 - */ -@Target({ ElementType.METHOD, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface TenantClear { - - /** - *

执行该方法后,是否全局过滤租户标志

- *
    - *
  • true:执行完该线程之前,后续对db操作不添加租户操作
  • - *
  • false:执行完当前方法后,后续方法的db操作添加租户操作
  • - *
- * - * @return 默认后续不添加租户操作 - */ - boolean globalFlag() default true; -} diff --git a/bs-common/src/main/java/com/bs/common/aspectj/TenantClearAspect.java b/bs-common/src/main/java/com/bs/common/aspectj/TenantClearAspect.java deleted file mode 100644 index cf3ff3e..0000000 --- a/bs-common/src/main/java/com/bs/common/aspectj/TenantClearAspect.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.bs.common.aspectj; - -import com.bs.common.annotation.TenantClear; -import lombok.SneakyThrows; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.stereotype.Component; -import com.bs.common.config.TenantConfigProperties; - -/** - * @作者 tjw - * @创建时间 2024-03-02-15:10 - * @说明 : - */ - -@Aspect -@Component -public class TenantClearAspect { - @Autowired - private TenantConfigProperties tenantConfigProperties; - - @SneakyThrows - @Around("@within(clear) || @annotation(clear)") - public Object around(ProceedingJoinPoint point, TenantClear clear) { - // 如果在类上,而不是在方法上,则为空 - if (clear == null) { - Class aClass = point.getTarget().getClass(); - clear = AnnotationUtils.findAnnotation(aClass, TenantClear.class); - } - if (clear != null) { - if(clear.globalFlag()){ - tenantConfigProperties.setTenantSkip(); - } - } - Object result = point.proceed(); - if (!clear.globalFlag()) { - tenantConfigProperties.clearSkip(); - } - return result; - } - -} \ No newline at end of file diff --git a/bs-common/src/main/java/com/bs/common/config/BsConfig.java b/bs-common/src/main/java/com/bs/common/config/BsConfig.java index 7fc5486..404c786 100644 --- a/bs-common/src/main/java/com/bs/common/config/BsConfig.java +++ b/bs-common/src/main/java/com/bs/common/config/BsConfig.java @@ -1,11 +1,8 @@ package com.bs.common.config; -import com.bs.common.utils.OsInfoUtil; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; -import java.util.Set; - /** * 读取项目相关配置 * @@ -18,15 +15,6 @@ public class BsConfig /** 项目名称 */ private String name; - /** - * 维护租户列名称 - */ - private static String column = "tenant_id"; - - /** - * 多租户的数据表集合(不忽略的表) - */ - private static Set noIgnoreTables; /** 版本 */ private String version; @@ -45,44 +33,6 @@ public class BsConfig /** 验证码类型 */ private static String captchaType; - /** - * windows附件地址 - */ - private static String winLocalFilePath; - /** - * linux附件地址 - */ - private static String linuxLocalFilePath; - /** - * mac附件地址 - */ - private static String macLocalFilePath; - - public void setWinLocalFilePath(String winLocalFilePath) { - BsConfig.winLocalFilePath = winLocalFilePath; - } - - public void setLinuxLocalFilePath(String linuxLocalFilePath) { - BsConfig.linuxLocalFilePath = linuxLocalFilePath; - } - - public void setMacLocalFilePath(String macLocalFilePath) { - BsConfig.macLocalFilePath = macLocalFilePath; - } - - public static String getWinLocalFilePath() { - return winLocalFilePath; - } - - public static String getLinuxLocalFilePath() { - return linuxLocalFilePath; - } - public static String getMacLocalFilePath() { - return macLocalFilePath; - } - - - public String getName() { return name; @@ -133,24 +83,6 @@ public class BsConfig BsConfig.profile = profile; } - public static String getColumn() { - return column; - } - - public static void setColumn(String column) { - BsConfig.column = column; - } - public static Set getTables() { - return getNoIgnoreTables(); - } - public static Set getNoIgnoreTables() { - return noIgnoreTables; - } - - public static void setNoIgnoreTables(Set noIgnoreTables) { - BsConfig.noIgnoreTables = noIgnoreTables; - } - public static boolean isAddressEnabled() { return addressEnabled; @@ -174,7 +106,7 @@ public class BsConfig */ public static String getImportPath() { - return getFilePath() + "/import"; + return getProfile() + "/import"; } /** @@ -182,7 +114,7 @@ public class BsConfig */ public static String getAvatarPath() { - return getFilePath() + "/avatar"; + return getProfile() + "/avatar"; } /** @@ -190,7 +122,7 @@ public class BsConfig */ public static String getDownloadPath() { - return getFilePath() + "/download/"; + return getProfile() + "/download/"; } /** @@ -198,23 +130,6 @@ public class BsConfig */ public static String getUploadPath() { - return getFilePath() + "/upload"; - } - - - /** - * 根据系统切换存放附件绝对地址 - * - * @return 存放附件绝对地址 - */ - public static String getFilePath() { - if (OsInfoUtil.isLinux()) { - return getLinuxLocalFilePath(); - } - if (OsInfoUtil.isMacOS() || OsInfoUtil.isMacOSX()) { - return getMacLocalFilePath(); - } - return getWinLocalFilePath(); + return getProfile() + "/upload"; } - } diff --git a/bs-common/src/main/java/com/bs/common/config/TenantConfigProperties.java b/bs-common/src/main/java/com/bs/common/config/TenantConfigProperties.java deleted file mode 100644 index 01b34dc..0000000 --- a/bs-common/src/main/java/com/bs/common/config/TenantConfigProperties.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.bs.common.config; - -import com.alibaba.ttl.TransmittableThreadLocal; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import java.util.Set; - -@Component -@ConfigurationProperties(prefix = "bs.tenant") -public class TenantConfigProperties { - - /** - * 维护租户列名称 - */ - private String column; - - /** - * 多租户的数据表集合(不忽略的表) - */ - private Set noIgnoreTables; - - - private boolean openTenant; - - /** - * 租户过滤标识 - */ - private final ThreadLocal TENANT_SKIP = new TransmittableThreadLocal<>(); - /** - * 设置是否过滤的标识 - */ - public void setTenantSkip() { - TENANT_SKIP.set(Boolean.TRUE); - } - /** - * 获取是否跳过租户过滤的标识 - * @return true-过滤 false-不过滤 - */ - public Boolean getTenantSkip() { - return TENANT_SKIP.get() != null && TENANT_SKIP.get(); - } - - /** - * 清空租户过滤标识 - */ - public void clearSkip(){ - TENANT_SKIP.remove(); - } - - - public String getColumn() { - return column; - } - - public void setColumn(String column) { - this.column = column; - } - - - public Boolean getOpenTenant() { - return openTenant; - } - - public void setOpenTenant(Boolean openTenant) { - this.openTenant = openTenant; - } - - - public Set getNoIgnoreTables() { - return noIgnoreTables; - } - - public void setNoIgnoreTables(Set noIgnoreTables) { - this.noIgnoreTables = noIgnoreTables; - } - - public Set getTables() { - return getNoIgnoreTables(); - } -} - diff --git a/bs-common/src/main/java/com/bs/common/core/controller/BaseController.java b/bs-common/src/main/java/com/bs/common/core/controller/BaseController.java index 64ac5f9..dea666a 100644 --- a/bs-common/src/main/java/com/bs/common/core/controller/BaseController.java +++ b/bs-common/src/main/java/com/bs/common/core/controller/BaseController.java @@ -1,5 +1,14 @@ package com.bs.common.core.controller; +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.bs.common.constant.HttpStatus; import com.bs.common.core.domain.AjaxResult; import com.bs.common.core.domain.model.LoginUser; @@ -11,16 +20,6 @@ import com.bs.common.utils.PageUtils; import com.bs.common.utils.SecurityUtils; import com.bs.common.utils.StringUtils; import com.bs.common.utils.sql.SqlUtil; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; - -import java.beans.PropertyEditorSupport; -import java.util.Date; -import java.util.List; /** * web层通用数据处理 @@ -90,19 +89,6 @@ public class BaseController rspData.setTotal(new PageInfo(list).getTotal()); return rspData; } - /** - * 响应请求分页数据 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected TableDataInfo getDataTable(List list,long total) - { - TableDataInfo rspData = new TableDataInfo(); - rspData.setCode(HttpStatus.SUCCESS); - rspData.setMsg("查询成功"); - rspData.setRows(list); - rspData.setTotal(total); - return rspData; - } /** * 返回成功 diff --git a/bs-common/src/main/java/com/bs/common/core/domain/BaseEntity.java b/bs-common/src/main/java/com/bs/common/core/domain/BaseEntity.java index 564484b..a0b97eb 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/BaseEntity.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/BaseEntity.java @@ -1,5 +1,11 @@ package com.bs.common.core.domain; +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableLogic; @@ -7,11 +13,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; - /** * Entity基类 * @@ -30,7 +31,8 @@ public class BaseEntity implements Serializable { @TableField(exist = false) private String searchValue; - private Long tenantId; + @TableField(exist = false) + private String tenantId; /** * 创建部门 @@ -48,7 +50,7 @@ public class BaseEntity implements Serializable { * 创建时间 */ @TableField(fill = FieldFill.INSERT) - private LocalDateTime createTime; + private Date createTime; /** * 更新者 @@ -60,7 +62,7 @@ public class BaseEntity implements Serializable { * 更新时间 */ @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateTime; + private Date updateTime; /** * 逻辑删除标示 */ @@ -89,5 +91,77 @@ public class BaseEntity implements Serializable { @TableField(exist = false) private Map params = new HashMap<>(); - + public String getSearchValue() + { + return searchValue; + } + + public void setSearchValue(String searchValue) + { + this.searchValue = searchValue; + } + + public String getCreateBy() + { + return createBy; + } + + public void setCreateBy(String createBy) + { + this.createBy = createBy; + } + + public Date getCreateTime() + { + return createTime; + } + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } + + public String getUpdateBy() + { + return updateBy; + } + + public void setUpdateBy(String updateBy) + { + this.updateBy = updateBy; + } + + public Date getUpdateTime() + { + return updateTime; + } + + public void setUpdateTime(Date updateTime) + { + this.updateTime = updateTime; + } + + public String getRemark() + { + return remark; + } + + public void setRemark(String remark) + { + this.remark = remark; + } + + public Map getParams() + { + if (params == null) + { + params = new HashMap<>(); + } + return params; + } + + public void setParams(Map params) + { + this.params = params; + } } diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysDept.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysDept.java index 6a83c55..1c63745 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysDept.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysDept.java @@ -1,19 +1,16 @@ package com.bs.common.core.domain.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.bs.common.core.domain.BaseEntity; -import lombok.Data; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - +import java.util.ArrayList; +import java.util.List; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.List; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.bs.common.core.domain.BaseEntity; /** * 部门表 sys_dept @@ -27,7 +24,6 @@ public class SysDept extends BaseEntity { /** * 部门ID */ - @TableId(value = "dept_id",type = IdType.AUTO) private Long deptId; /** @@ -70,17 +66,19 @@ public class SysDept extends BaseEntity { */ private String status; + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; /** * 父部门名称 */ - @TableField(exist = false) private String parentName; /** * 子部门 */ - @TableField(exist = false) private List children = new ArrayList(); public Long getDeptId() { @@ -161,6 +159,13 @@ public class SysDept extends BaseEntity { this.status = status; } + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } public String getParentName() { return parentName; diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysMenu.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysMenu.java index c0f8217..6aab64a 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysMenu.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysMenu.java @@ -1,18 +1,15 @@ package com.bs.common.core.domain.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.bs.common.core.domain.BaseEntity; -import lombok.Data; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - +import java.util.ArrayList; +import java.util.List; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.util.ArrayList; -import java.util.List; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.bs.common.core.domain.BaseEntity; /** * 菜单权限表 sys_menu @@ -25,14 +22,12 @@ public class SysMenu extends BaseEntity private static final long serialVersionUID = 1L; /** 菜单ID */ - @TableId(value = "menu_id", type = IdType.AUTO) private Long menuId; /** 菜单名称 */ private String menuName; /** 父菜单名称 */ - @TableField(exist = false) private String parentName; /** 父菜单ID */ @@ -48,7 +43,6 @@ public class SysMenu extends BaseEntity private String component; /** 路由参数 */ - @TableField("`query`") private String query; /** 是否为外链(0是 1否) */ @@ -73,7 +67,6 @@ public class SysMenu extends BaseEntity private String icon; private String remark; /** 子菜单 */ - @TableField(exist = false) private List children = new ArrayList(); public Long getMenuId() diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysRole.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysRole.java index 2ea7a45..3061881 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysRole.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysRole.java @@ -1,19 +1,16 @@ package com.bs.common.core.domain.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.bs.common.annotation.Excel; -import com.bs.common.annotation.Excel.ColumnType; -import com.bs.common.core.domain.BaseEntity; -import lombok.Data; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - +import java.util.Set; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.util.Set; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.bs.common.annotation.Excel; +import com.bs.common.annotation.Excel.ColumnType; +import com.bs.common.core.domain.BaseEntity; /** * 角色表 sys_role @@ -27,7 +24,6 @@ public class SysRole extends BaseEntity /** 角色ID */ @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) - @TableId(value = "role_id", type = IdType.AUTO) private Long roleId; /** 角色名称 */ @@ -56,20 +52,19 @@ public class SysRole extends BaseEntity @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") private String status; + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + /** 用户是否存在此角色标识 默认不存在 */ - @TableField(exist = false) private boolean flag = false; /** 菜单组 */ - @TableField(exist = false) private Long[] menuIds; /** 部门组(数据权限) */ - @TableField(exist = false) private Long[] deptIds; /** 角色菜单权限 */ - @TableField(exist = false) private Set permissions; public SysRole() @@ -177,6 +172,15 @@ public class SysRole extends BaseEntity this.status = status; } + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } public boolean isFlag() { diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysTenant.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysTenant.java deleted file mode 100644 index 08c8b33..0000000 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysTenant.java +++ /dev/null @@ -1,57 +0,0 @@ - -package com.bs.common.core.domain.entity; - - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.bs.common.core.domain.BaseEntity; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@Data -public class SysTenant extends BaseEntity { - - @TableId(value = "ID", type = IdType.AUTO) - private Long id; - private String name; - private String simpleName; - private String contactUser; - private String contactPhone; - private Integer status; - private String userName; - private String password; - - @ApiModelProperty(value = "行政区划") - private String areaCode; - /** - * 所有模块集合 - */ - @TableField(exist = false) - private String systemNames; - @TableField(exist = false) - private Long tenantId; - @TableField(exist = false) - private String deptId; - @TableField(exist = false) - private TenantConfig tenantConfig; - /** - * 备注 - */ - private String remark; - /** - * 所属系统 - */ - @TableField(exist = false) - private List systems; - - @TableField(exist = false) - private String areaName; - - @TableField(exist = false) - private List roleIds; - - -} diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysUser.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysUser.java index 109a319..c68d37a 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/SysUser.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/entity/SysUser.java @@ -1,21 +1,18 @@ package com.bs.common.core.domain.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; +import java.util.Date; +import java.util.List; +import javax.validation.constraints.*; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; import com.bs.common.annotation.Excel; import com.bs.common.annotation.Excel.ColumnType; import com.bs.common.annotation.Excel.Type; import com.bs.common.annotation.Excels; import com.bs.common.core.domain.BaseEntity; import com.bs.common.xss.Xss; -import lombok.Data; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import java.util.Date; -import java.util.List; /** * 用户对象 sys_user @@ -29,7 +26,6 @@ public class SysUser extends BaseEntity /** 用户ID */ @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") - @TableId(value = "user_id",type = IdType.AUTO) private Long userId; /** 部门ID */ @@ -81,15 +77,6 @@ public class SysUser extends BaseEntity @Excel(name = "最后登录IP", type = Type.EXPORT) private String loginIp; - - /** 是否是租户,Y是N,不是 */ - @Excel(name = "是否是租户,Y是N,不是", type = Type.EXPORT) - private String isTenant; - - /** 是否是租户管理员,Y是N,不是 */ - @Excel(name = "是否是租户管理员,Y是N,不是", type = Type.EXPORT) - private String isTenantAdmin; - /** 最后登录时间 */ @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) private Date loginDate; @@ -99,23 +86,18 @@ public class SysUser extends BaseEntity @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) - @TableField(exist = false) private SysDept dept; /** 角色对象 */ - @TableField(exist = false) private List roles; /** 角色组 */ - @TableField(exist = false) private Long[] roleIds; /** 岗位组 */ - @TableField(exist = false) private Long[] postIds; /** 角色ID */ - @TableField(exist = false) private Long roleId; private String remark; public SysUser() diff --git a/bs-common/src/main/java/com/bs/common/core/domain/entity/TenantConfig.java b/bs-common/src/main/java/com/bs/common/core/domain/entity/TenantConfig.java deleted file mode 100644 index d091d14..0000000 --- a/bs-common/src/main/java/com/bs/common/core/domain/entity/TenantConfig.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.bs.common.core.domain.entity; - -import com.baomidou.mybatisplus.annotation.*; -import com.bs.common.annotation.Excel; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; -import java.util.Date; - -/** - * 租户配置对象 tenant_config - * - * @author ruoyi - * @date 2023-04-02 - */ -@Accessors(chain = true) -@TableName("tenant_config") -@Data -public class TenantConfig -{ - private static final long serialVersionUID = 1L; - - /** $column.columnComment */ - @TableId(value = "ID",type = IdType.AUTO) - @ApiModelProperty(value = "${column.columnComment}") - private Long id; - - /** - * 创建部门 - */ - @TableField(fill = FieldFill.INSERT) - private Long createDept; - @TableField(exist = false) - private Long tenantId; - - /** - * 创建者 - */ - @TableField(fill = FieldFill.INSERT) - private Long createBy; - - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createTime; - - /** - * 更新者 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private Long updateBy; - - /** - * 更新时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updateTime; - /** - * 逻辑删除标示 - */ - //做删除操作的时候,会变成update,del_flag = '2' - @TableLogic(value = "0", delval = "2") - @TableField(fill = FieldFill.INSERT) - @JsonIgnore - private String delFlag; - - - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") - @ApiModelProperty(value = "开始时间") - private Date startData; - - /** 结束时间 */ - - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") - @ApiModelProperty(value = "结束时间") - private Date stopData; - - /** 是否限制用户数 */ - - @Excel(name = "是否限制用户数") - @ApiModelProperty(value = "是否限制用户数") - private String isUserAstrict; - - @Excel(name = "首页类型") - @ApiModelProperty(value = "首页类型") - private String homeType; - - /** 用户数 */ - - @Excel(name = "用户数") - @ApiModelProperty(value = "用户数") - private Integer userQuantity; - - /** 是否限制在线数 */ - - @Excel(name = "是否限制在线数") - @ApiModelProperty(value = "是否限制在线数") - private String isOnLine; - - /** 在线数 */ - - @Excel(name = "在线数") - @ApiModelProperty(value = "在线数") - private Integer onLineUserQuantity; - - /** 是否定义系统名称 */ - - @Excel(name = "是否定义系统名称") - @ApiModelProperty(value = "是否定义系统名称") - private String isDefinitionName; - - /** 系统名称 */ - - @Excel(name = "系统名称") - @ApiModelProperty(value = "系统名称") - private String sysName; - - /** 是否定义系统logo */ - - @Excel(name = "是否定义系统logo") - @ApiModelProperty(value = "是否定义系统logo") - private String isDefinitionLogo; - - /** 系统log */ - - @Excel(name = "系统log") - @ApiModelProperty(value = "系统log") - private String sysLog; - - /** 是否定义系统色调 */ - - @Excel(name = "是否定义系统色调") - @ApiModelProperty(value = "是否定义系统色调") - private String isDefinitionHue; - - /** 系统色调 */ - - @Excel(name = "系统色调") - @ApiModelProperty(value = "系统色调") - private String sysHue; - - /** 定制化数据,键值对{key:{type1:"",type2:"",value:""},key2:{type1:"",type2:"",value:""}}具体操作时候,做具体说明 */ - - @ApiModelProperty(value = "定制化数据,键值对{key:{type1:'',type2:'',value:''},key2:{type1:'',type2:'',value:''}}具体操作时候,做具体说明") - private String customizationFields; - - - -} diff --git a/bs-common/src/main/java/com/bs/common/core/domain/model/LoginUser.java b/bs-common/src/main/java/com/bs/common/core/domain/model/LoginUser.java index 096e578..daa4af5 100644 --- a/bs-common/src/main/java/com/bs/common/core/domain/model/LoginUser.java +++ b/bs-common/src/main/java/com/bs/common/core/domain/model/LoginUser.java @@ -9,7 +9,7 @@ import java.util.Set; /** * 登录用户身份权限 - * + * * @author bs */ public class LoginUser implements UserDetails @@ -71,49 +71,6 @@ public class LoginUser implements UserDetails */ private SysUser user; - /** - * 租户id - */ - private Long tenantId; - /** - * 是否租户 - */ - private String isTenant; - /** 是否租户管理员 */ - /** - * 是否租户admin - * Y 是 N 否 - * - * @return - */ - private String isTenantAdmin; - - public Long getTenantId() - { - return tenantId; - } - - public void setTenantId(Long tenantId) - { - this.tenantId = tenantId; - } - - public String getIsTenant() { - return isTenant; - } - - public void setIsTenant(String isTenant) { - this.isTenant = isTenant; - } - - public String getIsTenantAdmin() { - return isTenantAdmin; - } - - public void setIsTenantAdmin(String isTenantAdmin) { - this.isTenantAdmin = isTenantAdmin; - } - public LoginUser() { } @@ -128,9 +85,6 @@ public class LoginUser implements UserDetails { this.userId = userId; this.deptId = deptId; - this.tenantId = user.getTenantId(); - this.isTenant = user.getIsTenant(); - this.isTenantAdmin = user.getIsTenantAdmin(); this.user = user; this.permissions = permissions; } @@ -190,7 +144,7 @@ public class LoginUser implements UserDetails /** * 指定用户是否解锁,锁定的用户无法进行身份验证 - * + * * @return */ @JSONField(serialize = false) @@ -202,7 +156,7 @@ public class LoginUser implements UserDetails /** * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 - * + * * @return */ @JSONField(serialize = false) @@ -214,7 +168,7 @@ public class LoginUser implements UserDetails /** * 是否可用 ,禁用的用户不能身份验证 - * + * * @return */ @JSONField(serialize = false) diff --git a/bs-common/src/main/java/com/bs/common/filter/XssFilter.java b/bs-common/src/main/java/com/bs/common/filter/XssFilter.java index a4b65d3..1ce2501 100644 --- a/bs-common/src/main/java/com/bs/common/filter/XssFilter.java +++ b/bs-common/src/main/java/com/bs/common/filter/XssFilter.java @@ -1,18 +1,22 @@ package com.bs.common.filter; -import com.bs.common.enums.HttpMethod; -import com.bs.common.utils.StringUtils; - -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import com.bs.common.utils.StringUtils; +import com.bs.common.enums.HttpMethod; /** * 防止XSS攻击的过滤器 - * + * * @author bs */ public class XssFilter implements Filter diff --git a/bs-common/src/main/java/com/bs/common/mybatis/handler/DefaultDBFieldHandler.java b/bs-common/src/main/java/com/bs/common/mybatis/handler/DefaultDBFieldHandler.java index 4c25141..04088a6 100644 --- a/bs-common/src/main/java/com/bs/common/mybatis/handler/DefaultDBFieldHandler.java +++ b/bs-common/src/main/java/com/bs/common/mybatis/handler/DefaultDBFieldHandler.java @@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.bs.common.utils.SecurityUtils; import org.apache.ibatis.reflection.MetaObject; -import java.time.LocalDateTime; -import java.util.Objects; +import java.time.ZonedDateTime; +import java.util.Date; /** * 通用参数填充实现类 @@ -31,7 +31,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { */ boolean createTime = metaObject.hasSetter("createTime"); if(createTime){ - this.setFieldValByName("createTime", LocalDateTime.now() , metaObject); + this.setFieldValByName("createTime", Date.from(ZonedDateTime.now().toInstant()), metaObject); } /** * createDate 创建时间 @@ -58,19 +58,15 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { */ boolean updateByOf = metaObject.hasSetter("updateBy"); if(updateByOf){ - if (Objects.nonNull(SecurityUtils.getUsername())) { - this.setFieldValByName("updateBy", SecurityUtils.getUsername(), metaObject); - } + this.setFieldValByName("updateBy",SecurityUtils.getUsername(), metaObject); } - - /** * updateDate 更新时间 */ boolean updateTimeOf = metaObject.hasSetter("updateTime"); if(updateTimeOf){ - this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject); + this.setFieldValByName("updateTime", Date.from(ZonedDateTime.now().toInstant()), metaObject); } } } diff --git a/bs-common/src/main/java/com/bs/common/utils/DictUtils.java b/bs-common/src/main/java/com/bs/common/utils/DictUtils.java index 9157b6a..84fed6a 100644 --- a/bs-common/src/main/java/com/bs/common/utils/DictUtils.java +++ b/bs-common/src/main/java/com/bs/common/utils/DictUtils.java @@ -1,17 +1,16 @@ package com.bs.common.utils; +import java.util.Collection; +import java.util.List; import com.alibaba.fastjson2.JSONArray; import com.bs.common.constant.CacheConstants; import com.bs.common.core.domain.entity.SysDictData; import com.bs.common.core.redis.RedisCache; import com.bs.common.utils.spring.SpringUtils; -import java.util.Collection; -import java.util.List; - /** * 字典工具类 - * + * * @author bs */ public class DictUtils @@ -23,7 +22,7 @@ public class DictUtils /** * 设置字典缓存 - * + * * @param key 参数键 * @param dictDatas 字典数据列表 */ @@ -34,7 +33,7 @@ public class DictUtils /** * 获取字典缓存 - * + * * @param key 参数键 * @return dictDatas 字典数据列表 */ @@ -50,7 +49,7 @@ public class DictUtils /** * 根据字典类型和字典值获取字典标签 - * + * * @param dictType 字典类型 * @param dictValue 字典值 * @return 字典标签 @@ -62,7 +61,7 @@ public class DictUtils /** * 根据字典类型和字典标签获取字典值 - * + * * @param dictType 字典类型 * @param dictLabel 字典标签 * @return 字典值 @@ -74,7 +73,7 @@ public class DictUtils /** * 根据字典类型和字典值获取字典标签 - * + * * @param dictType 字典类型 * @param dictValue 字典值 * @param separator 分隔符 @@ -117,7 +116,7 @@ public class DictUtils /** * 根据字典类型和字典标签获取字典值 - * + * * @param dictType 字典类型 * @param dictLabel 字典标签 * @param separator 分隔符 @@ -157,7 +156,7 @@ public class DictUtils /** * 删除指定字典缓存 - * + * * @param key 字典键 */ public static void removeDictCache(String key) @@ -176,7 +175,7 @@ public class DictUtils /** * 设置cache key - * + * * @param configKey 参数键 * @return 缓存键key */ diff --git a/bs-common/src/main/java/com/bs/common/utils/FileUtil.java b/bs-common/src/main/java/com/bs/common/utils/FileUtil.java deleted file mode 100644 index 4faf5f6..0000000 --- a/bs-common/src/main/java/com/bs/common/utils/FileUtil.java +++ /dev/null @@ -1,939 +0,0 @@ -package com.bs.common.utils; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.poi.excel.BigExcelWriter; -import cn.hutool.poi.excel.ExcelUtil; -import com.bs.common.constant.Constants; -import com.bs.common.core.domain.AjaxResult; -import com.bs.common.exception.ServiceException; -import com.bs.common.utils.uuid.IdUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.poi.util.IOUtils; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipOutputStream; -import org.springframework.core.io.ClassPathResource; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.awt.image.BufferedImage; -import java.io.*; -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.SecureRandom; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * File工具类,扩展 hutool 工具包 - */ -@Slf4j -public class FileUtil extends cn.hutool.core.io.FileUtil { - - /** - * 定义GB的计算常量 - */ - private static final int GB = 1024 * 1024 * 1024; - /** - * 定义MB的计算常量 - */ - private static final int MB = 1024 * 1024; - /** - * 定义KB的计算常量 - */ - private static final int KB = 1024; - - /** - * 格式化小数 - */ - private static final DecimalFormat DF = new DecimalFormat("0.00"); - /** - * 系统临时目录 - *
- * windows 包含路径分割符,但Linux 不包含, - * 在windows \\==\ 前提下, - * 为安全起见 同意拼装 路径分割符, - *
-     *       java.io.tmpdir
-     *       windows : C:\Users/xxx\AppData\Local\Temp\
-     *       linux: /temp
-     * 
- */ - public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator; - - private static final int FILE_READ_BTYE = 1024; - - /** - * MultipartFile转File - */ - public static File toFile(MultipartFile multipartFile) { - // 获取文件名 - String fileName = multipartFile.getOriginalFilename(); - // 获取文件后缀 - String prefix = "." + getExtensionName(fileName); - File file = null; - try { - // 用uuid作为文件名,防止生成的临时文件重复 - file = File.createTempFile(IdUtil.simpleUUID(), prefix); - // MultipartFile to File - multipartFile.transferTo(file); - } catch (IOException e) { - e.printStackTrace(); - } - return file; - } - - /** - * 获取文件扩展名,不带 . - */ - public static String getExtensionName(String filename) { - if ((filename != null) && (filename.length() > 0)) { - int dot = filename.lastIndexOf('.'); - if ((dot > -1) && (dot < (filename.length() - 1))) { - return filename.substring(dot + 1); - } - } - return filename; - } - - public static String getExtensionNameBase64(String filename) { - if (filename.contains("data:image/png;base64")) { - return "png"; - }else if(filename.contains("data:image/jpg;base64")){ - return "jpg"; - }else if(filename.contains("data:image/jpeg;base64")){ - return "jpeg"; - } - return "bmp"; - } - /** - * Java文件操作 获取不带扩展名的文件名 - */ - public static String getFileNameNoEx(String filename) { - if ((filename != null) && (filename.length() > 0)) { - int dot = filename.lastIndexOf('.'); - if ((dot > -1) && (dot < (filename.length()))) { - return filename.substring(0, dot); - } - } - return filename; - } - - /** - * 文件大小转换 - */ - public static String getSize(long size) { - String resultSize; - if (size / GB >= 1) { - //如果当前Byte的值大于等于1GB - resultSize = DF.format(size / (float) GB) + "GB "; - } else if (size / MB >= 1) { - //如果当前Byte的值大于等于1MB - resultSize = DF.format(size / (float) MB) + "MB "; - } else if (size / KB >= 1) { - //如果当前Byte的值大于等于1KB - resultSize = DF.format(size / (float) KB) + "KB "; - } else { - resultSize = size + "B "; - } - return resultSize; - } - - - /** - * 将文件名解析成文件的上传路径 - */ - public static File upload(MultipartFile file, String filePath) { - //String name = getFileNameNoEx(file.getOriginalFilename()); - String suffix = getExtensionName(file.getOriginalFilename()); - StringBuffer nowStr = fileRename(); - try { - String fileName = nowStr + "." + suffix; - String path = filePath + fileName; - // getCanonicalFile 可解析正确各种路径 - File dest = new File(path).getCanonicalFile(); - // 检测是否存在目录 - if (!dest.getParentFile().exists()) { - dest.getParentFile().mkdirs(); - } - // 文件写入 - file.transferTo(dest); - return dest; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static String fileToBase64(File file) throws Exception { - FileInputStream inputFile = new FileInputStream(file); - String base64; - byte[] buffer = new byte[(int) file.length()]; - inputFile.read(buffer); - inputFile.close(); - base64 = Base64.encode(buffer); - return base64.replaceAll("[\\s*\t\n\r]", ""); - } - - - public static String getFileType(String type) { - String documents = "txt doc pdf ppt pps xlsx xls docx"; - String music = "mp3 wav wma mpa ram ra aac aif m4a"; - String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg"; - String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg"; - if (image.contains(type)) { - return "pic"; - } else if (documents.contains(type)) { - return "txt"; - } else if (music.contains(type)) { - return "music"; - } else if (video.contains(type)) { - return "vedio"; - } else { - return "other"; - } - } - - - public static void checkSize(long maxSize, long size) { - // 1M - int len = 1024 * 1024; - if (size > (maxSize * len)) { - throw new ServiceException("文件超出规定大小"); - - } - } - - /** - * 判断两个文件是否相同 - */ - public static boolean check(File file1, File file2) { - String img1Md5 = getMd5(file1); - String img2Md5 = getMd5(file2); - return img1Md5.equals(img2Md5); - } - - /** - * 判断两个文件是否相同 - */ - public static boolean check(String file1Md5, String file2Md5) { - return file1Md5.equals(file2Md5); - } - - private static byte[] getByte(File file) { - // 得到文件长度 - byte[] b = new byte[(int) file.length()]; - try { - InputStream in = new FileInputStream(file); - try { - in.read(b); - } catch (IOException e) { - e.printStackTrace(); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - return b; - } - - private static String getMd5(byte[] bytes) { - // 16进制字符 - char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - try { - MessageDigest mdTemp = MessageDigest.getInstance("MD5"); - mdTemp.update(bytes); - byte[] md = mdTemp.digest(); - int j = md.length; - char[] str = new char[j * 2]; - int k = 0; - // 移位 输出字符串 - for (byte byte0 : md) { - str[k++] = hexDigits[byte0 >>> 4 & 0xf]; - str[k++] = hexDigits[byte0 & 0xf]; - } - return new String(str); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 下载文件 - * - * @param request / - * @param response / - * @param file / - */ - public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) { - response.setCharacterEncoding(request.getCharacterEncoding()); - response.setContentType("application/octet-stream"); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); - IOUtils.copy(fis, response.getOutputStream()); - response.flushBuffer(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (fis != null) { - try { - fis.close(); - if (deleteOnExit) { - file.deleteOnExit(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static String getMd5(File file) { - return getMd5(getByte(file)); - } - - /** - * 读取json文件,返回json串 - * - * @param fileName - * @return - */ - public static String readJsonFile(String fileName) { - String jsonStr = ""; - try { - File jsonFile = new File(fileName); - FileReader fileReader = new FileReader(jsonFile); - - Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8"); - int ch = 0; - StringBuffer sb = new StringBuffer(); - while ((ch = reader.read()) != -1) { - sb.append((char) ch); - } - fileReader.close(); - reader.close(); - jsonStr = sb.toString(); - return jsonStr; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - public static BufferedImage inputImage(MultipartFile file) { - BufferedImage srcImage = null; - try { - FileInputStream in = (FileInputStream) file.getInputStream(); - srcImage = javax.imageio.ImageIO.read(in); - } catch (IOException e) { - System.out.println("读取图片文件出错!" + e.getMessage()); - } - return srcImage; - } - - /** - * 自动调节精度(经验数值) - * - * @param size 源图片大小 - * @return 图片压缩质量比 - */ - public static float getAccuracy(long size) { - float accuracy; - if (size < 400) { - accuracy = 0.85f; - } else if (size < 900) { - accuracy = 0.75f; - } else if (size < 2047) { - accuracy = 0.6f; - } else if (size < 3275) { - accuracy = 0.44f; - } else { - accuracy = 0.4f; - } - return accuracy; - } - - /** - * 上传文件重命名 - * - * @return 新的文件名 - */ - public static StringBuffer fileRename() { - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); - String time = sdf.format(new Date()); - StringBuffer buf = new StringBuffer(time); - SecureRandom r = new SecureRandom(); - //循环取得三个不大于10的随机整数 - for (int x = 0; x < 3; x++) { - buf.append(r.nextInt(10)); - } - return buf; - } - - /** - * 对中文字符进行UTF-8编码 - * - * @param source 要转义的字符串 - * @return - * @throws UnsupportedEncodingException - */ - public static String transformStyle(String source) throws UnsupportedEncodingException { - char[] arr = source.toCharArray(); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < arr.length; i++) { - char temp = arr[i]; - if (isChinese(temp)) { - sb.append(URLEncoder.encode("" + temp, Constants.UTF8)); - continue; - } - sb.append(arr[i]); - } - return sb.toString(); - } - - /** - * 判断是不是中文字符 - * - * @param c - * @return - */ - public static boolean isChinese(char c) { - - Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); - - if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS - - || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS - - || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A - - || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION - - || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION - - || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { - - return true; - - } - - return false; - - } - - - /** - * 上传文件重命名Mos系统 - * - * @return 新的文件名 - */ - public static String fileRenameMos(String prefix, String suffix) { - // 生成唯一的文件名[带前缀以及后缀] - String fileName = (prefix == null ? "" - : prefix.trim()) + IdUtils.simpleUUID() + (suffix == null ? "" - : suffix.trim()); - return fileName; - } - - /** - * 上传文件Mos系统 - */ - public static File uploadMos(MultipartFile file, String path) { - try { - // getCanonicalFile 可解析正确各种路径 - File dest = new File(path).getCanonicalFile(); - // 检测是否存在目录 - if (!dest.getParentFile().exists()) { - dest.getParentFile().mkdirs(); - } - // 文件写入 - file.transferTo(dest); - return dest; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static File uploadMosBase64(String imageStr, String path) { - try { - // getCanonicalFile 可解析正确各种路径 - File dest = new File(path).getCanonicalFile(); - // 检测是否存在目录 - if (!dest.getParentFile().exists()) { - dest.getParentFile().mkdirs(); - } - byte[] bytes=Base64.decode(imageStr); //imageStr.getBytes(); - FileOutputStream fos = new FileOutputStream(dest); - try{ - // 文件写入 - fos.write(bytes,0,bytes.length); - fos.flush(); - }catch (IOException e){ - e.printStackTrace(); - }finally { - fos.close(); - } - return dest; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - /** - * 读取文件,返回文件字符串. - * - * @param in 文件输入流 - * @param encoding 文件编码 - * @return String - */ - public static String readFile(InputStream in, String encoding) { - if (in == null) { - return null; - } - - StringBuffer sb = new StringBuffer(); - InputStreamReader reader = null; - try { - reader = new InputStreamReader(in, encoding); - int tmp = -1; - char temp; - while ((tmp = reader.read()) != -1) { - temp = (char) tmp; - sb.append(temp); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (in != null) { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - return sb.toString(); - } - - /** - * 将inputStream写入文件并关闭inputStream. - * - * @param is 文件输入流 - * @param filePath 文件路径 - * @param append true为追加,false为覆盖 - * @return 是否成功 - */ - public static boolean writeFile(InputStream is, String filePath, - boolean append) { - FileOutputStream fos = null; - try { - if (makeDir(filePath) && is != null) { - fos = new FileOutputStream(filePath, append); - byte[] buffer = new byte[FILE_READ_BTYE * FILE_READ_BTYE]; - // int bytesum = 0; - int byteread = 0; - while ((byteread = is.read(buffer)) != -1) { - // bytesum+=byteread; - fos.write(buffer, 0, byteread); - fos.flush(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (is != null) { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return true; - } - - /** - * 将字符串写入到文件. - * - * @param str 字符串 - * @param filePath 文件路径 - * @param encoding 编码 - * @param append 是否累加 - * @return 是否成功 - */ - public static boolean writeFile(String str, String filePath, - String encoding, boolean append) { - FileOutputStream fos = null; - Writer out = null; - boolean isSucc = false; - try { - if (makeDir(filePath)) { - fos = new FileOutputStream(new File(filePath), append); - out = new OutputStreamWriter(fos, encoding); - out.write(str); - - out.flush(); - out.close(); - - fos.flush(); - fos.close(); - } else { - isSucc = false; - } - isSucc = true; - } catch (IOException e) { - e.printStackTrace(); - isSucc = false; - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (out != null) { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return isSucc; - } - - /** - * 创建文件夹。 - * - * @param destDirName 目标文件夹 - * @return 是否创建成功 - */ - public static boolean createDir(String destDirName) { - if (validateEmail(destDirName)) { - return false; - } - File dir = new File(destDirName); - if (dir.exists()) { // 目录已经存在,不用创建 - return true; - } - // 创建单个目录 - if (dir.mkdirs()) { // 创建目录成功 - return true; - } - return true; - } - - public static boolean validateEmail(String s) { - return StringUtils.isEmpty(s) - || s.matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a" - + "-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); - } - - - /** - * 根据文件创建目录. - * - * @param file 文件 - * @return 是否成功 - */ - public static boolean makeDir(File file) { - if (!file.exists()) { - makeDir(file.getAbsolutePath()); - } - return true; - } - - /** - * 根据文件名创建目录 - * - * @param fileName - * @return - */ - public static boolean makeDir(String fileName) { - int index = 0; - int index1 = fileName.lastIndexOf("/"); - int index2 = fileName.lastIndexOf("\\"); - if (index1 > index2) { - index = index1; - } else { - index = index2; - } - fileName = fileName.substring(0, index); - File file = new File(fileName); - file.setWritable(true, false); - if (!file.exists()) { - if (!file.mkdirs()) { - return false; - } - } - return true; - } - - /** - * 删除单个文件 。 - * - * @param sPath 被删除文件的文件名 - * @return 单个文件删除成功返回true,否则返回false - */ - public static boolean deleteFile(String sPath) { - Boolean flag = false; - File file = new File(sPath); - // 路径为文件且不为空则进行删除 - if (file.isFile() && file.exists()) { - file.delete(); - flag = true; - } - return flag; - } - - /** - * 删除单个文件 。 - * - * @param file 被删除文件 - * @return 单个文件删除成功返回true,否则返回false - */ - public static boolean deleteFile(File file) { - Boolean flag = false; - // 路径为文件且不为空则进行删除 - if (file.isFile() && file.exists()) { - file.delete(); - flag = true; - } - return flag; - } - - /** - * 删除文件夹。 - * - * @param sPath 文件夹路径 - * @param flags true删除文件夹,false只删除文件夹下的文件 - * @return 是否删除成功 - */ - public static boolean deleteDirectory(String sPath, Boolean flags) { - // 如果sPath不以文件分隔符结尾,自动添加文件分隔符 - if (!sPath.endsWith(File.separator)) { - sPath = sPath + File.separator; - } - File dirFile = new File(sPath); - // 如果dir对应的文件不存在,或者不是一个目录,则退出 - if (!dirFile.exists() || !dirFile.isDirectory()) { - return false; - } - Boolean flag = true; - // 删除文件夹下的所有文件(包括子目录) - File[] files = dirFile.listFiles(); - for (int i = 0; i < files.length; i++) { - // 删除子文件 - if (files[i].isFile()) { - flag = deleteFile(files[i].getAbsolutePath()); - if (!flag) { - break; - } - } else { - // 删除子目录 - flag = deleteDirectory(files[i].getAbsolutePath(), true); - if (!flag) { - break; - } - } - } - if (!flag) { - return false; - } - if (flags) { - // 删除当前目录 - return dirFile.delete(); - } - return true; - } - - /** - * 文件打包(指定文件). - * - * @param zipFilePath 打包后压缩包的路径 - * @param files 需要打包的文件 - * @param targetFileNames 打包后文件的名称 - * @param encoding 文件名编码 - * @return flag 是否打包成功 - */ - public static Boolean zipFile(String zipFilePath, File[] files, - String[] targetFileNames, String encoding) { - Boolean flag = false; - if (StringUtils.isEmpty(zipFilePath) || files == null - || files.length == 0) { - return flag; - } - if (targetFileNames != null && targetFileNames.length != files.length) { - return flag; - } - byte[] buffer = new byte[FILE_READ_BTYE]; - try { - ZipOutputStream out = new ZipOutputStream(new FileOutputStream( - zipFilePath)); - for (int i = 0; i < files.length; i++) { - FileInputStream fis = new FileInputStream(files[i]); - if (targetFileNames != null) { - if (String.valueOf(targetFileNames[i].toCharArray()[0]) - .equals("/")) { - out.putNextEntry(new ZipEntry(targetFileNames[i] - .substring(1, targetFileNames[i].length()))); - } else { - out.putNextEntry(new ZipEntry(targetFileNames[i])); - } - } else { - out.putNextEntry(new ZipEntry(files[i].getName())); - } - if (StringUtils.isNotEmpty(encoding)) { - out.setEncoding(encoding); - } - int len; - while ((len = fis.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - out.closeEntry(); - fis.close(); - } - out.close(); - flag = true; - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return flag; - } - - /** - * inputStream 转 File - */ - static File inputStreamToFile(InputStream ins, String name) throws Exception { - File file = new File(SYS_TEM_DIR + name); - if (file.exists()) { - return file; - } - OutputStream os = new FileOutputStream(file); - int bytesRead; - int len = 8192; - byte[] buffer = new byte[len]; - while ((bytesRead = ins.read(buffer, 0, len)) != -1) { - os.write(buffer, 0, bytesRead); - } - os.close(); - ins.close(); - return file; - } - - /** - * 导出excel - */ - public static void downloadExcel(List> list, HttpServletResponse response) throws IOException { - String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx"; - File file = new File(tempPath); - BigExcelWriter writer = ExcelUtil.getBigWriter(file); - // 一次性写出内容,使用默认样式,强制输出标题 - writer.write(list, true); - SXSSFSheet sheet = (SXSSFSheet) writer.getSheet(); - //上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法 - sheet.trackAllColumnsForAutoSizing(); - //列宽自适应 - writer.autoSizeColumnAll(); - //response为HttpServletResponse对象 - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); - //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 - response.setHeader("Content-Disposition", "attachment;filename=file.xlsx"); - ServletOutputStream out = response.getOutputStream(); - // 终止后删除临时文件 - file.deleteOnExit(); - writer.flush(out, true); - //此处记得关闭输出Servlet流 - IoUtil.close(out); - } - - - /** - * 下载项目根目录下doc下的文件 - * - * @param response response - * @param fileName 文件名 - * @return 返回结果 成功或者文件不存在 - */ - public static AjaxResult downloadFile(HttpServletResponse response, String fileName) { - ClassPathResource classPathResource = new ClassPathResource(File.separator+"import_template"+File.separator+"material_export"+File.separator+fileName); - InputStream stream = null; - try { - stream = classPathResource.getInputStream(); - if (stream == null) { - log.error("文件没有找到"); - } - response.setHeader("content-type", "application/octet-stream"); - response.setContentType("application/octet-stream"); - String name = URLEncoder.encode(fileName, "UTF-8"); - response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLDecoder.decode(name, "ISO-8859-1")); - } catch (UnsupportedEncodingException e) { - log.error("文件名转换编码出现问题:" + e.getMessage()); - }catch (Exception e){ - log.error( e.getMessage()); - } - byte[] buff = new byte[1024]; - BufferedInputStream bis = null; - OutputStream os = null; - try { - os = response.getOutputStream(); - bis = new BufferedInputStream(stream); - int i = bis.read(buff); - while (i != -1) { - os.write(buff, 0, buff.length); - os.flush(); - i = bis.read(buff); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - log.error("系统找不到指定的文件:" + e.getMessage()); - return AjaxResult.error("500", "系统找不到指定的文件"); - } catch (IOException e) { - e.printStackTrace(); - log.error("Io流写入出现错误:" + e.getMessage()); - return AjaxResult.error("500", "Io流写入出现错误"); - } finally { - if (bis != null) { - try { - bis.close(); - } catch (IOException e) { - e.printStackTrace(); - log.error("关闭流出现错误:" + e.getMessage()); - return AjaxResult.error("500", "关闭流出现错误"); - } - } - } - return AjaxResult.success(); - } - - -} diff --git a/bs-common/src/main/java/com/bs/common/utils/OsInfoUtil.java b/bs-common/src/main/java/com/bs/common/utils/OsInfoUtil.java deleted file mode 100644 index ed5601e..0000000 --- a/bs-common/src/main/java/com/bs/common/utils/OsInfoUtil.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.bs.common.utils; - - -public class OsInfoUtil { - private static String OS = System.getProperty("os.name").toLowerCase(); - - private static OsInfoUtil _instance = new OsInfoUtil(); - - private SystemEnum platform; - - private OsInfoUtil() { - } - - public static boolean isLinux() { - return OS.indexOf("linux") >= 0; - } - - public static boolean isMacOS() { - return OS.indexOf("mac") >= 0 && OS.indexOf("os") > 0 && OS.indexOf("x") < 0; - } - - public static boolean isMacOSX() { - return OS.indexOf("mac") >= 0 && OS.indexOf("os") > 0 && OS.indexOf("x") > 0; - } - - public static boolean isWindows() { - return OS.indexOf("windows") >= 0; - } - - public static boolean isOS2() { - return OS.indexOf("os/2") >= 0; - } - - public static boolean isSolaris() { - return OS.indexOf("solaris") >= 0; - } - - public static boolean isSunOS() { - return OS.indexOf("sunos") >= 0; - } - - public static boolean isMPEiX() { - return OS.indexOf("mpe/ix") >= 0; - } - - public static boolean isHPUX() { - return OS.indexOf("hp-ux") >= 0; - } - - public static boolean isAix() { - return OS.indexOf("aix") >= 0; - } - - public static boolean isOS390() { - return OS.indexOf("os/390") >= 0; - } - - public static boolean isFreeBSD() { - return OS.indexOf("freebsd") >= 0; - } - - public static boolean isIrix() { - return OS.indexOf("irix") >= 0; - } - - public static boolean isDigitalUnix() { - return OS.indexOf("digital") >= 0 && OS.indexOf("unix") > 0; - } - - public static boolean isNetWare() { - return OS.indexOf("netware") >= 0; - } - - public static boolean isOSF1() { - return OS.indexOf("osf1") >= 0; - } - - public static boolean isOpenVMS() { - return OS.indexOf("openvms") >= 0; - } - - /** - * 获取操作系统名字 - * - * @return 操作系统名 - */ - public static SystemEnum getOSname() { - if (isAix()) { - _instance.platform = SystemEnum.AIX; - } else if (isDigitalUnix()) { - _instance.platform = SystemEnum.DIGITAL_UNIX; - } else if (isFreeBSD()) { - _instance.platform = SystemEnum.FreeBSD; - } else if (isHPUX()) { - _instance.platform = SystemEnum.HP_UX; - } else if (isIrix()) { - _instance.platform = SystemEnum.IRIX; - } else if (isLinux()) { - _instance.platform = SystemEnum.LINUX; - } else if (isMacOS()) { - _instance.platform = SystemEnum.MAC_OS; - } else if (isMacOSX()) { - _instance.platform = SystemEnum.MAC_OS_X; - } else if (isMPEiX()) { - _instance.platform = SystemEnum.MPEiX; - } else if (isNetWare()) { - _instance.platform = SystemEnum.NETWARE_411; - } else if (isOpenVMS()) { - _instance.platform = SystemEnum.OPENVMS; - } else if (isOS2()) { - _instance.platform = SystemEnum.OS2; - } else if (isOS390()) { - _instance.platform = SystemEnum.OS390; - } else if (isOSF1()) { - _instance.platform = SystemEnum.OSF1; - } else if (isSolaris()) { - _instance.platform = SystemEnum.SOLARIS; - } else if (isSunOS()) { - _instance.platform = SystemEnum.SUNOS; - } else if (isWindows()) { - _instance.platform = SystemEnum.WINDOWS; - } else { - _instance.platform = SystemEnum.OTHERS; - } - return _instance.platform; - } - - /** - * @param args - */ - public static void main(String[] args) { - System.out.println(OsInfoUtil.getOSname());// 获取系统类型 - System.out.println(OsInfoUtil.isMacOSX());// 判断是否为windows系统 - } - - -} diff --git a/bs-common/src/main/java/com/bs/common/utils/SecurityUtils.java b/bs-common/src/main/java/com/bs/common/utils/SecurityUtils.java index 31984f7..5126916 100644 --- a/bs-common/src/main/java/com/bs/common/utils/SecurityUtils.java +++ b/bs-common/src/main/java/com/bs/common/utils/SecurityUtils.java @@ -29,30 +29,6 @@ public class SecurityUtils } } - /** - * 获取租户id - **/ - public static Long getTenantId() { - try { - return getLoginUser().getTenantId(); - } catch (Exception e) { - //e.printStackTrace(); - //throw new ServiceException("获取租户id异常", HttpStatus.UNAUTHORIZED); - //log.info("此异常只有在获取不到的场景才会触发(此时不用理会err),如果当前场景下应当获取到信息,应及时处理(全局搜索这段话)"); - //log.error("获取租户id异常",e.getMessage()); - return null; - - } - } - /** - * 是否租户账号 - **/ - public static Boolean isTenant() { - if(getTenantId()!=0L){ - return true; - } - return false; - } /** * 获取部门ID **/ @@ -79,7 +55,7 @@ public class SecurityUtils } catch (Exception e) { - return null; + throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); } } diff --git a/bs-common/src/main/java/com/bs/common/utils/SystemEnum.java b/bs-common/src/main/java/com/bs/common/utils/SystemEnum.java deleted file mode 100644 index c3c7d9c..0000000 --- a/bs-common/src/main/java/com/bs/common/utils/SystemEnum.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.bs.common.utils; - -public enum SystemEnum { - - ANY("any"), - LINUX("Linux"), - MAC_OS("Mac OS"), - MAC_OS_X("Mac OS X"), - WINDOWS("Windows"), - OS2("OS/2"), - SOLARIS("Solaris"), - SUNOS("SunOS"), - MPEiX("MPE/iX"), - HP_UX("HP-UX"), - AIX("AIX"), - OS390("OS/390"), - FreeBSD("FreeBSD"), - IRIX("Irix"), - DIGITAL_UNIX("Digital Unix"), - NETWARE_411("NetWare"), - OSF1("OSF1"), - OPENVMS("OpenVMS"), - OTHERS("Others"); - - SystemEnum(String desc) { - this.description = desc; - } - - @Override - public String toString() { - return description; - } - - private String description; - -} diff --git a/bs-common/src/main/java/com/bs/common/utils/collection/CollectionUtils.java b/bs-common/src/main/java/com/bs/common/utils/collection/CollectionUtils.java deleted file mode 100644 index 95d8c2a..0000000 --- a/bs-common/src/main/java/com/bs/common/utils/collection/CollectionUtils.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.bs.common.utils.collection; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import com.google.common.collect.ImmutableMap; - -import java.util.*; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * Collection 工具类 - * - * hasPermi - */ -public class CollectionUtils { - - public static boolean containsAny(Object source, Object... targets) { - return Arrays.asList(targets).contains(source); - } - - public static boolean isAnyEmpty(Collection... collections) { - return Arrays.stream(collections).anyMatch(CollectionUtil::isEmpty); - } - - public static List filterList(Collection from, Predicate predicate) { - if (CollUtil.isEmpty(from)) { - return new ArrayList<>(); - } - return from.stream().filter(predicate).collect(Collectors.toList()); - } - - public static List distinct(Collection from, Function keyMapper) { - if (CollUtil.isEmpty(from)) { - return new ArrayList<>(); - } - return distinct(from, keyMapper, (t1, t2) -> t1); - } - - public static List distinct(Collection from, Function keyMapper, BinaryOperator cover) { - if (CollUtil.isEmpty(from)) { - return new ArrayList<>(); - } - return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values()); - } - - public static List convertList(Collection from, Function func) { - if (CollUtil.isEmpty(from)) { - return new ArrayList<>(); - } - return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toList()); - } - - public static List convertList(Collection from, Function func, Predicate filter) { - if (CollUtil.isEmpty(from)) { - return new ArrayList<>(); - } - return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList()); - } - - public static Set convertSet(Collection from, Function func) { - if (CollUtil.isEmpty(from)) { - return new HashSet<>(); - } - return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toSet()); - } - - public static Set convertSet(Collection from, Function func, Predicate filter) { - if (CollUtil.isEmpty(from)) { - return new HashSet<>(); - } - return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toSet()); - } - - public static Map convertMap(Collection from, Function keyFunc) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return convertMap(from, keyFunc, Function.identity()); - } - - public static Map convertMap(Collection from, Function keyFunc, Supplier> supplier) { - if (CollUtil.isEmpty(from)) { - return supplier.get(); - } - return convertMap(from, keyFunc, Function.identity(), supplier); - } - - public static Map convertMap(Collection from, Function keyFunc, Function valueFunc) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1); - } - - public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return convertMap(from, keyFunc, valueFunc, mergeFunction, HashMap::new); - } - - public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, Supplier> supplier) { - if (CollUtil.isEmpty(from)) { - return supplier.get(); - } - return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1, supplier); - } - - public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction, Supplier> supplier) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return from.stream().collect(Collectors.toMap(keyFunc, valueFunc, mergeFunction, supplier)); - } - - public static Map> convertMultiMap(Collection from, Function keyFunc) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(t -> t, Collectors.toList()))); - } - - public static Map> convertMultiMap(Collection from, Function keyFunc, Function valueFunc) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return from.stream() - .collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toList()))); - } - - // 暂时没想好名字,先以 2 结尾噶 - public static Map> convertMultiMap2(Collection from, Function keyFunc, Function valueFunc) { - if (CollUtil.isEmpty(from)) { - return new HashMap<>(); - } - return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toSet()))); - } - - public static Map convertImmutableMap(Collection from, Function keyFunc) { - if (CollUtil.isEmpty(from)) { - return Collections.emptyMap(); - } - ImmutableMap.Builder builder = ImmutableMap.builder(); - from.forEach(item -> builder.put(keyFunc.apply(item), item)); - return builder.build(); - } - - public static boolean containsAny(Collection source, Collection candidates) { - return org.springframework.util.CollectionUtils.containsAny(source, candidates); - } - - public static T getFirst(List from) { - return !CollectionUtil.isEmpty(from) ? from.get(0) : null; - } - - public static T findFirst(List from, Predicate predicate) { - if (CollUtil.isEmpty(from)) { - return null; - } - return from.stream().filter(predicate).findFirst().orElse(null); - } - - public static > V getMaxValue(List from, Function valueFunc) { - if (CollUtil.isEmpty(from)) { - return null; - } - assert from.size() > 0; // 断言,避免告警 - T t = from.stream().max(Comparator.comparing(valueFunc)).get(); - return valueFunc.apply(t); - } - - public static void addIfNotNull(Collection coll, T item) { - if (item == null) { - return; - } - coll.add(item); - } - - public static Collection singleton(T deptId) { - return deptId == null ? Collections.emptyList() : Collections.singleton(deptId); - } - -} diff --git a/bs-common/src/main/java/com/bs/common/utils/file/FileTypeUtils.java b/bs-common/src/main/java/com/bs/common/utils/file/FileTypeUtils.java index 4833abc..fda10c2 100644 --- a/bs-common/src/main/java/com/bs/common/utils/file/FileTypeUtils.java +++ b/bs-common/src/main/java/com/bs/common/utils/file/FileTypeUtils.java @@ -1,8 +1,7 @@ package com.bs.common.utils.file; -import org.apache.commons.lang3.StringUtils; - import java.io.File; +import org.apache.commons.lang3.StringUtils; /** * 文件类型工具类 diff --git a/bs-common/src/main/java/com/bs/common/utils/reflect/ReflectUtils.java b/bs-common/src/main/java/com/bs/common/utils/reflect/ReflectUtils.java index 491d8bf..38c0264 100644 --- a/bs-common/src/main/java/com/bs/common/utils/reflect/ReflectUtils.java +++ b/bs-common/src/main/java/com/bs/common/utils/reflect/ReflectUtils.java @@ -1,15 +1,19 @@ package com.bs.common.utils.reflect; -import com.bs.common.core.text.Convert; -import com.bs.common.utils.DateUtils; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Date; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.apache.poi.ss.usermodel.DateUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import java.lang.reflect.*; -import java.util.Date; +import com.bs.common.core.text.Convert; +import com.bs.common.utils.DateUtils; /** * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. diff --git a/bs-common/src/main/java/com/bs/common/utils/spring/SpringUtils.java b/bs-common/src/main/java/com/bs/common/utils/spring/SpringUtils.java index db9dcf3..ad0ff5a 100644 --- a/bs-common/src/main/java/com/bs/common/utils/spring/SpringUtils.java +++ b/bs-common/src/main/java/com/bs/common/utils/spring/SpringUtils.java @@ -12,11 +12,11 @@ import com.bs.common.utils.StringUtils; /** * spring工具类 方便在非spring管理环境中获取bean - * + * * @author bs */ @Component -public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { /** Spring应用上下文环境 */ private static ConfigurableListableBeanFactory beanFactory; @@ -24,13 +24,13 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC private static ApplicationContext applicationContext; @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { SpringUtils.beanFactory = beanFactory; } @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { SpringUtils.applicationContext = applicationContext; } @@ -113,7 +113,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC /** * 获取aop代理对象 - * + * * @param invoker * @return */ diff --git a/bs-common/src/main/java/com/bs/common/utils/sql/SqlUtil.java b/bs-common/src/main/java/com/bs/common/utils/sql/SqlUtil.java index 3f9a5e8..5b2d9e6 100644 --- a/bs-common/src/main/java/com/bs/common/utils/sql/SqlUtil.java +++ b/bs-common/src/main/java/com/bs/common/utils/sql/SqlUtil.java @@ -5,7 +5,7 @@ import com.bs.common.utils.StringUtils; /** * sql操作工具类 - * + * * @author bs */ public class SqlUtil diff --git a/bs-framework/pom.xml b/bs-framework/pom.xml index 9906a04..5e95de3 100644 --- a/bs-framework/pom.xml +++ b/bs-framework/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - my-base + bs-jxc com.bs 3.8.6 @@ -16,10 +16,7 @@ - - com.bs - bs-system - + org.springframework.boot diff --git a/bs-framework/src/main/java/com/bs/framework/aspectj/DataScopeAspect.java b/bs-framework/src/main/java/com/bs/framework/aspectj/DataScopeAspect.java index 54bb01c..d73e844 100644 --- a/bs-framework/src/main/java/com/bs/framework/aspectj/DataScopeAspect.java +++ b/bs-framework/src/main/java/com/bs/framework/aspectj/DataScopeAspect.java @@ -1,5 +1,11 @@ package com.bs.framework.aspectj; +import java.util.ArrayList; +import java.util.List; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.stereotype.Component; import com.bs.common.annotation.DataScope; import com.bs.common.core.domain.BaseEntity; import com.bs.common.core.domain.entity.SysRole; @@ -9,13 +15,6 @@ import com.bs.common.core.text.Convert; import com.bs.common.utils.SecurityUtils; import com.bs.common.utils.StringUtils; import com.bs.framework.security.context.PermissionContextHolder; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; /** * 数据过滤处理 diff --git a/bs-framework/src/main/java/com/bs/framework/config/CaptchaConfig.java b/bs-framework/src/main/java/com/bs/framework/config/CaptchaConfig.java index 761f949..9cdcdfc 100644 --- a/bs-framework/src/main/java/com/bs/framework/config/CaptchaConfig.java +++ b/bs-framework/src/main/java/com/bs/framework/config/CaptchaConfig.java @@ -21,14 +21,13 @@ public class CaptchaConfig DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); Properties properties = new Properties(); // 是否有边框 默认为true 我们可以自己设置yes,no - properties.setProperty(KAPTCHA_BORDER, "no"); + properties.setProperty(KAPTCHA_BORDER, "yes"); // 验证码文本字符颜色 默认为Color.BLACK - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue"); + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black"); // 验证码图片宽度 默认为200 properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); // 验证码图片高度 默认为50 properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); - properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "10"); // 验证码文本字符大小 默认为40 properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38"); // KAPTCHA_SESSION_KEY @@ -38,11 +37,7 @@ public class CaptchaConfig // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy - //properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); - properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise"); - properties.setProperty(KAPTCHA_BACKGROUND_CLR_FROM, "white"); - // - properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_STRING,"0123456789"); + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); Config config = new Config(properties); defaultKaptcha.setConfig(config); return defaultKaptcha; diff --git a/bs-framework/src/main/java/com/bs/framework/config/MyTenantLineHandlerImpl.java b/bs-framework/src/main/java/com/bs/framework/config/MyTenantLineHandlerImpl.java deleted file mode 100644 index b7c5813..0000000 --- a/bs-framework/src/main/java/com/bs/framework/config/MyTenantLineHandlerImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.bs.framework.config; - -import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; -import com.bs.common.config.TenantConfigProperties; -import com.bs.common.utils.SecurityUtils; -import lombok.extern.slf4j.Slf4j; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; - -/** - * @author: gfk - * @create: 2023/3/3 - * @Description: - * @FileName: MyTenantLineHandlerImpl - * @History: - * @自定义内容: - */ - -/** - * 租户处理器 - * - * @author luohq - * @date 2022-08-07 12:31 - */ -@Slf4j -public class MyTenantLineHandlerImpl implements TenantLineHandler { - /** - * 租户ID请求头名称 - */ - public static final String TENANT_ID_HEADER = "X-TENANT-ID"; - /** - * 默认租户ID - */ - public static final Long DEFAULT_TENANT_ID = 1L; - - private final TenantConfigProperties tenantConfigProperties; - - public MyTenantLineHandlerImpl(TenantConfigProperties tenantConfigProperties) { - this.tenantConfigProperties = tenantConfigProperties; - } - @Override - public Expression getTenantId() { - Long tenantId = SecurityUtils.getTenantId(); -/* String tenantId = Optional.ofNullable(null) - .map(String::valueOf) - //.orElseThrow(() -> new RuntimeException("解析请求头中的X-TENANT-ID失败!")); - .orElseGet(() -> { - log.info("解析请求头中的X-TENANT-ID失败 - 使用默认租户ID: {}", DEFAULT_TENANT_ID); - return "1"; - });*/ - //return new LongValue(tenantId); - if(tenantId==null){ - return new LongValue(0); - } - return new LongValue(tenantId); - - } - - @Override - public String getTenantIdColumn() { - //默认tenant_id - return "tenant_id"; - } - - @Override - public boolean ignoreTable(String tableName) { - //是否忽略此table的租户处理逻辑 - if(SecurityUtils.getTenantId()==null){ - return true; - } - // 1.是否跳过租户对该表对操作 - if (tenantConfigProperties.getTenantSkip()) { - return true; - } - if(tenantConfigProperties.getOpenTenant()){ - return tenantConfigProperties.getNoIgnoreTables().contains(tableName); - } - return true; - - } -} diff --git a/bs-framework/src/main/java/com/bs/framework/config/MybatisPlusConfig.java b/bs-framework/src/main/java/com/bs/framework/config/MybatisPlusConfig.java index fb2f075..3821a69 100644 --- a/bs-framework/src/main/java/com/bs/framework/config/MybatisPlusConfig.java +++ b/bs-framework/src/main/java/com/bs/framework/config/MybatisPlusConfig.java @@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; -import com.bs.common.config.TenantConfigProperties; import com.bs.common.mybatis.handler.DefaultDBFieldHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -23,11 +21,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; public class MybatisPlusConfig { @Bean - public MybatisPlusInterceptor mybatisPlusInterceptor(TenantConfigProperties tenantConfigProperties) + public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); //启用多租户插件 - interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new MyTenantLineHandlerImpl(tenantConfigProperties))); + //interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new MyTenantLineHandlerImpl())); // 分页插件 interceptor.addInnerInterceptor(paginationInnerInterceptor()); // 乐观锁插件 diff --git a/bs-framework/src/main/java/com/bs/framework/web/service/SysPermissionService.java b/bs-framework/src/main/java/com/bs/framework/web/service/SysPermissionService.java index 10bbf55..ba8c57c 100644 --- a/bs-framework/src/main/java/com/bs/framework/web/service/SysPermissionService.java +++ b/bs-framework/src/main/java/com/bs/framework/web/service/SysPermissionService.java @@ -1,16 +1,15 @@ package com.bs.framework.web.service; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import com.bs.common.core.domain.entity.SysRole; import com.bs.common.core.domain.entity.SysUser; import com.bs.system.service.ISysMenuService; import com.bs.system.service.ISysRoleService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; /** * 用户权限处理 @@ -18,7 +17,8 @@ import java.util.Set; * @author bs */ @Component -public class SysPermissionService { +public class SysPermissionService +{ @Autowired private ISysRoleService roleService; @@ -31,12 +31,16 @@ public class SysPermissionService { * @param user 用户信息 * @return 角色权限信息 */ - public Set getRolePermission(SysUser user) { + public Set getRolePermission(SysUser user) + { Set roles = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) { + if (user.isAdmin()) + { roles.add("admin"); - } else { + } + else + { roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); } return roles; @@ -48,21 +52,29 @@ public class SysPermissionService { * @param user 用户信息 * @return 菜单权限信息 */ - public Set getMenuPermission(SysUser user) { + public Set getMenuPermission(SysUser user) + { Set perms = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) { + if (user.isAdmin()) + { perms.add("*:*:*"); - } else { + } + else + { List roles = user.getRoles(); - if (!CollectionUtils.isEmpty(roles)) { + if (!CollectionUtils.isEmpty(roles)) + { // 多角色设置permissions属性,以便数据权限匹配权限 - for (SysRole role : roles) { + for (SysRole role : roles) + { Set rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId()); role.setPermissions(rolePerms); perms.addAll(rolePerms); } - } else { + } + else + { perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); } } diff --git a/bs-framework/src/main/java/com/bs/framework/web/service/TokenService.java b/bs-framework/src/main/java/com/bs/framework/web/service/TokenService.java index 9404668..78194b8 100644 --- a/bs-framework/src/main/java/com/bs/framework/web/service/TokenService.java +++ b/bs-framework/src/main/java/com/bs/framework/web/service/TokenService.java @@ -1,5 +1,12 @@ package com.bs.framework.web.service; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import com.bs.common.constant.CacheConstants; import com.bs.common.constant.Constants; import com.bs.common.core.domain.model.LoginUser; @@ -13,14 +20,6 @@ import eu.bitwalker.useragentutils.UserAgent; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; /** * token验证处理 diff --git a/bs-generator/pom.xml b/bs-generator/pom.xml index 0704787..8ce4732 100644 --- a/bs-generator/pom.xml +++ b/bs-generator/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - my-base + bs-jxc com.bs 3.8.6 @@ -34,11 +34,7 @@ com.bs bs-common - - - com.baomidou - mybatis-plus-generator - + diff --git a/bs-generator/src/main/java/com/bs/generator/service/GenTableServiceImpl.java b/bs-generator/src/main/java/com/bs/generator/service/GenTableServiceImpl.java index a7c7d56..7726dca 100644 --- a/bs-generator/src/main/java/com/bs/generator/service/GenTableServiceImpl.java +++ b/bs-generator/src/main/java/com/bs/generator/service/GenTableServiceImpl.java @@ -1,45 +1,41 @@ package com.bs.generator.service; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; import com.bs.common.constant.Constants; import com.bs.common.constant.GenConstants; import com.bs.common.core.text.CharsetKit; import com.bs.common.exception.ServiceException; import com.bs.common.utils.SecurityUtils; import com.bs.common.utils.StringUtils; -import com.bs.common.utils.collection.CollectionUtils; import com.bs.generator.domain.GenTable; import com.bs.generator.domain.GenTableColumn; import com.bs.generator.mapper.GenTableColumnMapper; import com.bs.generator.mapper.GenTableMapper; -import com.bs.generator.util.GenTableUtils; import com.bs.generator.util.GenUtils; import com.bs.generator.util.VelocityInitializer; import com.bs.generator.util.VelocityUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; /** * 业务 服务层实现 @@ -92,23 +88,7 @@ public class GenTableServiceImpl implements IGenTableService @Override public List selectDbTableList(GenTable genTable) { - List tableList = GenTableUtils.getTableList(genTable.getTableName(), genTable.getTableComment()); - // 移除置顶前缀的表名 - tableList.removeIf(table -> table.getName().toUpperCase().startsWith("QRTZ_")); - tableList.removeIf(table -> table.getName().toUpperCase().startsWith("ACT_")); - tableList.removeIf(table -> table.getName().toUpperCase().startsWith("FLW_")); - // 移除已经生成的表 - // 移除在 Codegen 中,已经存在的 - List genTables = genTableMapper.selectGenTableList(new GenTable()); - Set existsTables = CollectionUtils.convertSet(genTables, GenTable::getTableName); - tableList.removeIf(table -> existsTables.contains(table.getName())); - List result = tableList.stream().map(tmp -> { - GenTable data = new GenTable(); - data.setTableName(tmp.getName()); - data.setTableComment(tmp.getComment()); - return data; - }).collect(Collectors.toList()); - return result; + return genTableMapper.selectDbTableList(genTable); } /** @@ -120,15 +100,7 @@ public class GenTableServiceImpl implements IGenTableService @Override public List selectDbTableListByNames(String[] tableNames) { - List result = new ArrayList<>(tableNames.length); - for (String tableName : tableNames) { - TableInfo table = GenTableUtils.getTable(tableName); - GenTable data = new GenTable(); - data.setTableName(table.getName()); - data.setTableComment(table.getComment()); - result.add(data); - } - return result; + return genTableMapper.selectDbTableListByNames(tableNames); } /** @@ -188,35 +160,27 @@ public class GenTableServiceImpl implements IGenTableService public void importGenTable(List tableList) { Long operName = SecurityUtils.getUsername(); - try { - for (GenTable table : tableList) { + try + { + for (GenTable table : tableList) + { String tableName = table.getTableName(); GenUtils.initTable(table, operName); int row = genTableMapper.insertGenTable(table); - if (row > 0) { + if (row > 0) + { // 保存列信息 - TableInfo tableInfo = GenTableUtils.getTable(tableName); - List fields = tableInfo.getFields(); - AtomicInteger index = new AtomicInteger(1); - List genTableColumns = fields.stream().map(tmp -> { - GenTableColumn data = new GenTableColumn(); - data.setColumnName(tmp.getColumnName()); - data.setColumnComment(tmp.getComment()); - data.setIsRequired(tmp.getMetaInfo().isNullable() ? "1" : "0"); - data.setIsPk(tmp.isKeyFlag() ? "1" : "0"); - data.setSort(index.getAndIncrement()); - data.setIsIncrement(tmp.isKeyIdentityFlag() ? "1" : "0"); - data.setColumnType(tmp.getType()); - return data; - }).collect(Collectors.toList()); - //List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); - for (GenTableColumn column : genTableColumns) { + List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + for (GenTableColumn column : genTableColumns) + { GenUtils.initColumnField(column, table); genTableColumnMapper.insertGenTableColumn(column); } } } - } catch (Exception e) { + } + catch (Exception e) + { throw new ServiceException("导入失败:" + e.getMessage()); } } diff --git a/bs-generator/src/main/java/com/bs/generator/util/GenTableUtils.java b/bs-generator/src/main/java/com/bs/generator/util/GenTableUtils.java deleted file mode 100644 index 3581cb9..0000000 --- a/bs-generator/src/main/java/com/bs/generator/util/GenTableUtils.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.bs.generator.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.generator.config.DataSourceConfig; -import com.baomidou.mybatisplus.generator.config.GlobalConfig; -import com.baomidou.mybatisplus.generator.config.StrategyConfig; -import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.config.rules.DateType; -import com.bs.common.utils.spring.SpringUtils; -import org.springframework.core.env.Environment; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class GenTableUtils { - - private static final String DATASOURCE_DYNAMIC_KEY = "spring.datasource.druid.master"; - - public static Environment environment = SpringUtils.getBean(Environment.class); - - public static List getTableList(String nameLike, String commentLike) { - List tables = getTableList0(null); - return tables.stream().filter(tableInfo -> (StrUtil.isEmpty(nameLike) || tableInfo.getName().contains(nameLike)) - && (StrUtil.isEmpty(commentLike) || tableInfo.getComment().contains(commentLike))) - .collect(Collectors.toList()); - } - - public static TableInfo getTable(String name) { - return CollUtil.getFirst(getTableList0(name)); - } - - public static List getTableList0(String name) { - String url = environment.getProperty(DATASOURCE_DYNAMIC_KEY + ".url"); - String username = environment.getProperty(DATASOURCE_DYNAMIC_KEY + ".username"); - String password = environment.getProperty(DATASOURCE_DYNAMIC_KEY + ".password"); - // 使用 MyBatis Plus Generator 解析表结构 - DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(url, username, - password).build(); - StrategyConfig.Builder strategyConfig = new StrategyConfig.Builder(); - if (StrUtil.isNotEmpty(name)) { - strategyConfig.addInclude(name); - } - // 只使用 Date 类型,不使用 LocalDate - GlobalConfig globalConfig = new GlobalConfig.Builder().dateType(DateType.ONLY_DATE).build(); - ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, strategyConfig.build(), - null, globalConfig, null); - // 按照名字排序 - List tables = builder.getTableInfoList(); - tables.sort(Comparator.comparing(TableInfo::getName)); - return tables; - } - -} diff --git a/bs-generator/src/main/java/com/bs/generator/util/GenUtils.java b/bs-generator/src/main/java/com/bs/generator/util/GenUtils.java index b307735..8163ccd 100644 --- a/bs-generator/src/main/java/com/bs/generator/util/GenUtils.java +++ b/bs-generator/src/main/java/com/bs/generator/util/GenUtils.java @@ -1,13 +1,12 @@ package com.bs.generator.util; +import java.util.Arrays; +import org.apache.commons.lang3.RegExUtils; import com.bs.common.constant.GenConstants; import com.bs.common.utils.StringUtils; import com.bs.generator.config.GenConfig; import com.bs.generator.domain.GenTable; import com.bs.generator.domain.GenTableColumn; -import org.apache.commons.lang3.RegExUtils; - -import java.util.Arrays; /** * 代码生成器 工具类 diff --git a/bs-generator/src/main/java/com/bs/generator/util/VelocityUtils.java b/bs-generator/src/main/java/com/bs/generator/util/VelocityUtils.java index 0939777..9b7d3d3 100644 --- a/bs-generator/src/main/java/com/bs/generator/util/VelocityUtils.java +++ b/bs-generator/src/main/java/com/bs/generator/util/VelocityUtils.java @@ -1,5 +1,10 @@ package com.bs.generator.util; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.velocity.VelocityContext; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.bs.common.constant.GenConstants; @@ -7,12 +12,6 @@ import com.bs.common.utils.DateUtils; import com.bs.common.utils.StringUtils; import com.bs.generator.domain.GenTable; import com.bs.generator.domain.GenTableColumn; -import org.apache.velocity.VelocityContext; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; /** * 模板处理工具类 diff --git a/bs-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/bs-generator/src/main/resources/mapper/generator/GenTableMapper.xml index 53a7c90..0839c83 100644 --- a/bs-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/bs-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -97,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + where notice_id = #{noticeId} + + + + + + insert into sys_notice ( + notice_title, + notice_type, + notice_content, + status, + remark, + create_by, + create_time + )values( + #{noticeTitle}, + #{noticeType}, + #{noticeContent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update sys_notice + + notice_title = #{noticeTitle}, + notice_type = #{noticeType}, + notice_content = #{noticeContent}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where notice_id = #{noticeId} + + + + delete from sys_notice where notice_id = #{noticeId} + + + + delete from sys_notice where notice_id in + + #{noticeId} + + + diff --git a/bs-system/src/main/resources/mapper/system/SysUserMapper.xml b/bs-system/src/main/resources/mapper/system/SysUserMapper.xml index 4178a23..fe99a4b 100644 --- a/bs-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/bs-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -120,11 +120,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.dataScope} - -