--数据密码,通过设置MD5密码下载

--引入积木报表,归档统计报表,借阅统计报表
new
JilingLee 1 year ago
parent 1bd28f657f
commit 9522691720

@ -18,7 +18,7 @@
<module>yudao-module-infra</module> <module>yudao-module-infra</module>
<!-- <module>yudao-module-pay</module>--> <!-- <module>yudao-module-pay</module>-->
<module>yudao-module-bpm</module> <module>yudao-module-bpm</module>
<!-- <module>yudao-module-report</module>--> <module>yudao-module-report</module>
<!-- <module>yudao-module-mp</module>--> <!-- <module>yudao-module-mp</module>-->
<!-- <module>yudao-module-mall</module>--> <!-- <module>yudao-module-mall</module>-->
<!-- 示例项目 --> <!-- 示例项目 -->

File diff suppressed because one or more lines are too long

@ -0,0 +1,40 @@
-- ----------------------------
-- for setting_password
-- ----------------------------
DROP TABLE IF EXISTS `setting_password`;
CREATE TABLE `setting_password` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`password_value` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`enable_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '1',
`attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '2',
`attr3` int(11) NULL DEFAULT NULL COMMENT '3',
`attr4` int(11) NULL DEFAULT NULL COMMENT '4',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`updater` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`dept_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`company_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`user_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`deleted` bit(1) NULL DEFAULT b'0' COMMENT '',
`company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`tenant_id` bigint(20) NOT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
--
SELECT * FROM system_menu WHERE name='';
SET @menuId = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('', '', 2, 0, @menuId, 'passwords', '', 'setting/passwords/index', 'Passwords', 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');
SET @menuId2 = LAST_INSERT_ID();
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'setting:passwords:query', 3, 1, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'setting:passwords:create', 3, 2, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'setting:passwords:update', 3, 3, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'setting:passwords:delete', 3, 4, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');
INSERT INTO `lyr-one`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, '', 'setting:passwords:export', 3, 5, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-18 13:52:08', '', '2023-09-18 13:52:08', b'0');

@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import javax.annotation.security.PermitAll;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.*; import javax.validation.*;
import javax.servlet.http.*; import javax.servlet.http.*;
@ -16,6 +17,8 @@ import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@ -41,6 +44,10 @@ public class PackagesController {
@Operation(summary = "创建装册") @Operation(summary = "创建装册")
@PreAuthorize("@ss.hasPermission('archives:packages:create')") @PreAuthorize("@ss.hasPermission('archives:packages:create')")
public CommonResult<Long> createPackages(@Valid @RequestBody PackagesCreateReqVO createReqVO) { public CommonResult<Long> createPackages(@Valid @RequestBody PackagesCreateReqVO createReqVO) {
PackagesDO packages = packagesService.getByCodeValue(createReqVO.getCodeValue());
if (packages != null){
return error("该全宗号-目录号-案卷号已存在!请勿重复装册!");
}
return success(packagesService.createPackages(createReqVO)); return success(packagesService.createPackages(createReqVO));
} }
@ -72,7 +79,9 @@ public class PackagesController {
@GetMapping("/getByCodeValue") @GetMapping("/getByCodeValue")
@Operation(summary = "获得装册") @Operation(summary = "获得装册")
@PermitAll
@Parameter(name = "id", description = "条码值", required = true, example = "1-2-3") @Parameter(name = "id", description = "条码值", required = true, example = "1-2-3")
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
public CommonResult<PackagesRespVO> getByCodeValue(@RequestParam("codeValue") String codeValue) { public CommonResult<PackagesRespVO> getByCodeValue(@RequestParam("codeValue") String codeValue) {
PackagesDO packages = packagesService.getByCodeValue(codeValue); PackagesDO packages = packagesService.getByCodeValue(codeValue);
return success(PackagesConvert.INSTANCE.convert(packages)); return success(PackagesConvert.INSTANCE.convert(packages));

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.FileUtils;
import cn.iocoder.yudao.framework.common.util.barcode.BarcodeUtil; import cn.iocoder.yudao.framework.common.util.barcode.BarcodeUtil;
import cn.iocoder.yudao.module.infra.service.file.FileService; import cn.iocoder.yudao.module.infra.service.file.FileService;
import me.zhyd.oauth.log.Log; import me.zhyd.oauth.log.Log;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -36,21 +37,15 @@ public class PackagesServiceImpl implements PackagesService {
private PackagesMapper packagesMapper; private PackagesMapper packagesMapper;
@Resource @Resource
private FileService fileService; private FileService fileService;
@Value("${yudao.web.admin-ui.url}")
private String webUrl;
@Override @Override
public Long createPackages(PackagesCreateReqVO createReqVO) { public Long createPackages(PackagesCreateReqVO createReqVO) {
// 插入 // 插入
PackagesDO packages = PackagesConvert.INSTANCE.convert(createReqVO); PackagesDO packages = PackagesConvert.INSTANCE.convert(createReqVO);
File buf = BarcodeUtil.generateBarCode(packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum(), "QR_CODE", String url = getUrl(packages);
"./tmp/Packages/" + packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum() + ".png");
MultipartFile file = FileUtils.getMultipartFile(buf);
String url="";
try {
url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
} catch (IOException e) {
Log.error(e.toString());
}
packages.setCodeUrl(url); packages.setCodeUrl(url);
packages.setCodeValue(packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum()); packages.setCodeValue(packages.getCaseNum()+"-"+packages.getCatalogNum()+"-"+packages.getFilesNum());
packagesMapper.insert(packages); packagesMapper.insert(packages);
@ -67,15 +62,7 @@ public class PackagesServiceImpl implements PackagesService {
PackagesDO packagesDO = packagesMapper.selectById(updateReqVO.getId()); PackagesDO packagesDO = packagesMapper.selectById(updateReqVO.getId());
boolean b = packagesDO.getCaseNum().equals(updateObj.getCaseNum()) && packagesDO.getCatalogNum().equals(updateObj.getCatalogNum()) && packagesDO.getFilesNum().equals(updateObj.getFilesNum()); boolean b = packagesDO.getCaseNum().equals(updateObj.getCaseNum()) && packagesDO.getCatalogNum().equals(updateObj.getCatalogNum()) && packagesDO.getFilesNum().equals(updateObj.getFilesNum());
if (!b){ if (!b){
File buf = BarcodeUtil.generateBarCode(updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum(), "QR_CODE", String url = getUrl(updateObj);
"./tmp/Packages/" + updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum() + ".png");
MultipartFile file = FileUtils.getMultipartFile(buf);
String url="";
try {
url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
} catch (IOException e) {
Log.error(e.toString());
}
updateObj.setCodeUrl(url); updateObj.setCodeUrl(url);
updateObj.setCodeValue(updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum()); updateObj.setCodeValue(updateObj.getCaseNum()+"-"+updateObj.getCatalogNum()+"-"+updateObj.getFilesNum());
} }
@ -121,4 +108,30 @@ public class PackagesServiceImpl implements PackagesService {
return packagesMapper.selectList(exportReqVO); return packagesMapper.selectList(exportReqVO);
} }
/**
*
* @param packages
* @return
*/
private String getUrl(PackagesDO packages){
try {
// InetAddress address = InetAddress.getLocalHost();//获取的是本地的IP地址
// String hostAddress = address.getHostAddress();
File buf = BarcodeUtil.generateBarCode(webUrl+"/info?codeValue="+packages.getCaseNum()+"-"+ packages.getCatalogNum()+"-"+ packages.getFilesNum(), "QR_CODE",
"./tmp/Packages/" + packages.getCaseNum()+"-"+ packages.getCatalogNum()+"-"+ packages.getFilesNum() + ".png");
MultipartFile file = FileUtils.getMultipartFile(buf);
String url="";
url = fileService.createFile(null, null, IoUtil.readBytes(file.getInputStream()));
return url;
} catch (IOException e) {
Log.error(e.toString());
return "";
}
}
} }

@ -3,12 +3,11 @@ package cn.iocoder.yudao.module.archives.service.turnover;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.archives.convert.record.RecordConvert;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.module.archives.enums.ArchivesStatusEnum; import cn.iocoder.yudao.module.archives.enums.ArchivesStatusEnum;
import cn.iocoder.yudao.module.archives.enums.BillTypeEnum; import cn.iocoder.yudao.module.archives.enums.BillTypeEnum;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
@ -59,6 +58,7 @@ public class TurnOverServiceImpl extends MPJBaseServiceImpl<TurnOverMapper, Turn
turnOver.setBillType("DAYJ"); turnOver.setBillType("DAYJ");
//添加数据userid //添加数据userid
turnOver.setUserId(loginUser.getId()); turnOver.setUserId(loginUser.getId());
turnOver.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult().toString());
turnOverMapper.insert(turnOver); turnOverMapper.insert(turnOver);
if (turnOver.getStatus().equals(ArchivesStatusEnum.PROCESS.getValue())) { if (turnOver.getStatus().equals(ArchivesStatusEnum.PROCESS.getValue())) {

@ -5,6 +5,7 @@ public interface ErrorCodeConstants {
ErrorCode ORGANIZATION_NOT_EXISTS = new ErrorCode(200100, "立档单位不存在"); ErrorCode ORGANIZATION_NOT_EXISTS = new ErrorCode(200100, "立档单位不存在");
ErrorCode DEPOT_CABINET_NOT_EXISTS = new ErrorCode(300100, "档案柜管理不存在"); ErrorCode DEPOT_CABINET_NOT_EXISTS = new ErrorCode(300100, "档案柜管理不存在");
ErrorCode DEPOT_NOT_EXISTS = new ErrorCode(400100, "库房管理不存在"); ErrorCode DEPOT_NOT_EXISTS = new ErrorCode(400100, "库房管理不存在");
ErrorCode PASSWORDS_NOT_EXISTS = new ErrorCode(500100, "数据密码不存在");
ErrorCode FILE_CATEGORY_NOT_EXISTS = new ErrorCode(400200, "档案分类不存在"); ErrorCode FILE_CATEGORY_NOT_EXISTS = new ErrorCode(400200, "档案分类不存在");

@ -0,0 +1,117 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords;
import me.zhyd.oauth.log.Log;
import org.apache.http.HttpResponse;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
import cn.iocoder.yudao.module.setting.convert.passwords.PasswordsConvert;
import cn.iocoder.yudao.module.setting.service.passwords.PasswordsService;
@Tag(name = "管理后台 - 数据密码")
@RestController
@RequestMapping("/setting/passwords")
@Validated
public class PasswordsController {
@Resource
private PasswordsService passwordsService;
@PostMapping("/create")
@Operation(summary = "创建数据密码")
@PreAuthorize("@ss.hasPermission('setting:passwords:create')")
public CommonResult<Long> createPasswords(@Valid @RequestBody PasswordsCreateReqVO createReqVO) {
return success(passwordsService.createPasswords(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新数据密码")
@PreAuthorize("@ss.hasPermission('setting:passwords:update')")
public CommonResult<Boolean> updatePasswords(@Valid @RequestBody PasswordsUpdateReqVO updateReqVO) {
passwordsService.updatePasswords(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除数据密码")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('setting:passwords:delete')")
public CommonResult<Boolean> deletePasswords(@RequestParam("id") Long id) {
passwordsService.deletePasswords(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得数据密码")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('setting:passwords:query')")
public CommonResult<PasswordsRespVO> getPasswords(@RequestParam("id") Long id) {
PasswordsDO passwords = passwordsService.getPasswords(id);
return success(PasswordsConvert.INSTANCE.convert(passwords));
}
@GetMapping("/jsonToXmlConverter")
@Operation(summary = "json带密码转xml")
@PreAuthorize("@ss.hasPermission('setting:passwords:query')")
public void jsonToXmlConverter(@RequestParam("inputPassword") String inputPassword,@RequestParam("json") String json,HttpServletResponse httpResponse) {
try {
String xml = passwordsService.jsonToXmlConverter(httpResponse, inputPassword, json);
} catch (IOException e) {
Log.error(e.getMessage());
}
}
@GetMapping("/list")
@Operation(summary = "获得数据密码列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('setting:passwords:query')")
public CommonResult<List<PasswordsRespVO>> getPasswordsList(@RequestParam("ids") Collection<Long> ids) {
List<PasswordsDO> list = passwordsService.getPasswordsList(ids);
return success(PasswordsConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得数据密码分页")
@PreAuthorize("@ss.hasPermission('setting:passwords:query')")
public CommonResult<PageResult<PasswordsRespVO>> getPasswordsPage(@Valid PasswordsPageReqVO pageVO) {
PageResult<PasswordsDO> pageResult = passwordsService.getPasswordsPage(pageVO);
return success(PasswordsConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出数据密码 Excel")
@PreAuthorize("@ss.hasPermission('setting:passwords:export')")
@OperateLog(type = EXPORT)
public void exportPasswordsExcel(@Valid PasswordsExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<PasswordsDO> list = passwordsService.getPasswordsList(exportReqVO);
// 导出 Excel
List<PasswordsExcelVO> datas = PasswordsConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "数据密码.xls", "数据", PasswordsExcelVO.class, datas);
}
}

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class PasswordsBaseVO {
@Schema(description = "密码值")
private String passwordValue;
@Schema(description = "是否启用")
private String enableFlag;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "所属部门id", example = "6115")
private Long deptId;
@Schema(description = "所属部门", example = "芋艿")
private String deptName;
@Schema(description = "业务实体id", example = "24194")
private Long companyId;
@Schema(description = "用户id", example = "22963")
private Long userId;
@Schema(description = "业务实体")
private String company;
}

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 数据密码创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PasswordsCreateReqVO extends PasswordsBaseVO {
/**
*
*/
@NotNull(message = "密码值不能为空")
private String passwordValue;
}

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author
*/
@Data
public class PasswordsExcelVO {
@ExcelProperty("密码id")
private Long id;
@ExcelProperty("密码值")
private String passwordValue;
@ExcelProperty("是否启用")
private String enableFlag;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("制单人")
private String createBy;
@ExcelProperty("所属部门id")
private Long deptId;
@ExcelProperty("所属部门")
private String deptName;
@ExcelProperty("业务实体id")
private Long companyId;
@ExcelProperty("用户id")
private Long userId;
@ExcelProperty("业务实体")
private String company;
}

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 数据密码 Excel 导出 Request VO参数和 PasswordsPageReqVO 是一致的")
@Data
public class PasswordsExportReqVO {
@Schema(description = "密码值")
private String passwordValue;
@Schema(description = "是否启用")
private String enableFlag;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "预留字段3")
private Integer attr3;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "所属部门id", example = "6115")
private Long deptId;
@Schema(description = "所属部门", example = "芋艿")
private String deptName;
@Schema(description = "业务实体id", example = "24194")
private Long companyId;
@Schema(description = "用户id", example = "22963")
private Long userId;
@Schema(description = "业务实体")
private String company;
}

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 数据密码分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PasswordsPageReqVO extends PageParam {
@Schema(description = "密码值")
private String passwordValue;
@Schema(description = "是否启用")
private String enableFlag;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "预留字段3")
private Integer attr3;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "制单人")
private String createBy;
@Schema(description = "所属部门id", example = "6115")
private Long deptId;
@Schema(description = "所属部门", example = "芋艿")
private String deptName;
@Schema(description = "业务实体id", example = "24194")
private Long companyId;
@Schema(description = "用户id", example = "22963")
private Long userId;
@Schema(description = "业务实体")
private String company;
}

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 数据密码 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PasswordsRespVO extends PasswordsBaseVO {
@Schema(description = "密码id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21763")
private Long id;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.setting.controller.admin.passwords.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 数据密码更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PasswordsUpdateReqVO extends PasswordsBaseVO {
@Schema(description = "密码id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21763")
@NotNull(message = "密码id不能为空")
private Long id;
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.setting.convert.passwords;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
/**
* Convert
*
* @author
*/
@Mapper
public interface PasswordsConvert {
PasswordsConvert INSTANCE = Mappers.getMapper(PasswordsConvert.class);
PasswordsDO convert(PasswordsCreateReqVO bean);
PasswordsDO convert(PasswordsUpdateReqVO bean);
PasswordsRespVO convert(PasswordsDO bean);
List<PasswordsRespVO> convertList(List<PasswordsDO> list);
PageResult<PasswordsRespVO> convertPage(PageResult<PasswordsDO> page);
List<PasswordsExcelVO> convertList02(List<PasswordsDO> list);
}

@ -0,0 +1,83 @@
package cn.iocoder.yudao.module.setting.dal.dataobject.passwords;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("setting_password")
@KeySequence("setting_password_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PasswordsDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private String passwordValue;
/**
*
*/
private String enableFlag;
/**
*
*/
private String remark;
/**
* 1
*/
private String attr1;
/**
* 2
*/
private String attr2;
/**
* 3
*/
private Integer attr3;
/**
* 4
*/
private Integer attr4;
/**
*
*/
private String createBy;
/**
* id
*/
private Long deptId;
/**
*
*/
private String deptName;
/**
* id
*/
private Long companyId;
/**
* id
*/
private Long userId;
/**
*
*/
private String company;
}

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.setting.dal.mysql.passwords;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
/**
* Mapper
*
* @author
*/
@Mapper
public interface PasswordsMapper extends BaseMapperX<PasswordsDO> {
default PageResult<PasswordsDO> selectPage(PasswordsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PasswordsDO>()
.eqIfPresent(PasswordsDO::getPasswordValue, reqVO.getPasswordValue())
.eqIfPresent(PasswordsDO::getEnableFlag, reqVO.getEnableFlag())
.eqIfPresent(PasswordsDO::getRemark, reqVO.getRemark())
.eqIfPresent(PasswordsDO::getAttr3, reqVO.getAttr3())
.betweenIfPresent(PasswordsDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PasswordsDO::getCreateBy, reqVO.getCreateBy())
.eqIfPresent(PasswordsDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(PasswordsDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(PasswordsDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(PasswordsDO::getUserId, reqVO.getUserId())
.eqIfPresent(PasswordsDO::getCompany, reqVO.getCompany())
.orderByDesc(PasswordsDO::getId));
}
default List<PasswordsDO> selectList(PasswordsExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PasswordsDO>()
.eqIfPresent(PasswordsDO::getPasswordValue, reqVO.getPasswordValue())
.eqIfPresent(PasswordsDO::getEnableFlag, reqVO.getEnableFlag())
.eqIfPresent(PasswordsDO::getRemark, reqVO.getRemark())
.eqIfPresent(PasswordsDO::getAttr3, reqVO.getAttr3())
.betweenIfPresent(PasswordsDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PasswordsDO::getCreateBy, reqVO.getCreateBy())
.eqIfPresent(PasswordsDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(PasswordsDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(PasswordsDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(PasswordsDO::getUserId, reqVO.getUserId())
.eqIfPresent(PasswordsDO::getCompany, reqVO.getCompany())
.orderByDesc(PasswordsDO::getId));
}
}

@ -0,0 +1,87 @@
package cn.iocoder.yudao.module.setting.service.passwords;
import java.io.IOException;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.*;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.apache.http.HttpResponse;
/**
* Service
*
* @author
*/
public interface PasswordsService {
/**
* md
* @param inputPassword
* @param storedHash
* @return
*/
boolean isPasswordValid(String inputPassword, String storedHash);
/**
* xml
* @param inputPassword
* @param json
* @return
*/
String jsonToXmlConverter(HttpServletResponse httpResponse, String inputPassword, String json) throws IOException;
/**
*
*
* @param createReqVO
* @return
*/
Long createPasswords(@Valid PasswordsCreateReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updatePasswords(@Valid PasswordsUpdateReqVO updateReqVO);
/**
*
*
* @param id
*/
void deletePasswords(Long id);
/**
*
*
* @param id
* @return
*/
PasswordsDO getPasswords(Long id);
/**
*
*
* @param ids
* @return
*/
List<PasswordsDO> getPasswordsList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<PasswordsDO> getPasswordsPage(PasswordsPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<PasswordsDO> getPasswordsList(PasswordsExportReqVO exportReqVO);
}

@ -0,0 +1,177 @@
package cn.iocoder.yudao.module.setting.service.passwords;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhyd.oauth.log.Log;
import org.apache.http.HttpResponse;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.json.JSONObject;
import org.json.XML;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.*;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.setting.convert.passwords.PasswordsConvert;
import cn.iocoder.yudao.module.setting.dal.mysql.passwords.PasswordsMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author
*/
@Service
@Validated
public class PasswordsServiceImpl implements PasswordsService {
@Resource
private PasswordsMapper passwordsMapper;
@Override
public boolean isPasswordValid(String inputPassword, String storedHash) {
String inputHash = getMD5Hash(inputPassword);
// 比较用户输入的哈希值与存储的哈希值
return inputHash.equals(storedHash);
}
@Override
public String jsonToXmlConverter(HttpServletResponse httpResponse, String inputPassword, String json) throws IOException {
QueryWrapper<PasswordsDO> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("create_time").last("LIMIT 1");
PasswordsDO passwordsDO = passwordsMapper.selectOne(wrapper);
String passwordValueMD5 = passwordsDO.getPasswordValue();
// 获取PrintWriter对象
PrintWriter out = httpResponse.getWriter();
httpResponse.setCharacterEncoding("UTF-8");
httpResponse.setContentType("application/json");
if (passwordValueMD5 == null) {
JSONObject json2 = new JSONObject();
json2.put("code", "500");
json2.put("msg", "password is null");
httpResponse.setStatus(500);
out.println(json2.toString());
out.flush();
return null; // 返回XML字符串
} else {
boolean passwordValid = this.isPasswordValid(inputPassword, passwordValueMD5);
if (passwordValid) {//将json字符串转化为JSONObject对象
JSONObject jsonObject = new JSONObject(json);
//将JSONObject对象转化为xml字符串
String xml = XML.toString(jsonObject);
httpResponse.setStatus(200); // 设置响应状态码为200
httpResponse.setHeader("Content-Type", ContentType.APPLICATION_XML.toString());
out.println(xml);
return xml; // 返回XML字符串
} else {
JSONObject json2 = new JSONObject();
json2.put("code", "500");
json2.put("msg", "passwordError!");
httpResponse.setStatus(500);
out.println(json2.toString());
out.flush();
return null;
}
}
}
@Override
public Long createPasswords(PasswordsCreateReqVO createReqVO) {
// 插入
PasswordsDO passwords = PasswordsConvert.INSTANCE.convert(createReqVO);
String passwordValue = passwords.getPasswordValue();
String md5Hash = getMD5Hash(passwordValue);
passwords.setPasswordValue(md5Hash);
passwordsMapper.insert(passwords);
// 返回
return passwords.getId();
}
public static String getMD5Hash(String password) {
try {
// 创建 MessageDigest 对象,并指定使用 MD5 算法
MessageDigest md = MessageDigest.getInstance("MD5");
// 将密码转换为字节数组
byte[] passwordBytes = password.getBytes();
// 使用字节数组更新摘要
md.update(passwordBytes);
// 获取摘要的字节数组
byte[] digest = md.digest();
// 将摘要字节数组转换为十六进制字符串
StringBuilder hexString = new StringBuilder();
for (byte b : digest) {
hexString.append(String.format("%02x", b));
}
return hexString.toString();
} catch (Exception e) {
Log.error(e.getMessage());
}
return null;
}
@Override
public void updatePasswords(PasswordsUpdateReqVO updateReqVO) {
// 校验存在
validatePasswordsExists(updateReqVO.getId());
// 更新
PasswordsDO updateObj = PasswordsConvert.INSTANCE.convert(updateReqVO);
passwordsMapper.updateById(updateObj);
}
@Override
public void deletePasswords(Long id) {
// 校验存在
validatePasswordsExists(id);
// 删除
passwordsMapper.deleteById(id);
}
private void validatePasswordsExists(Long id) {
if (passwordsMapper.selectById(id) == null) {
throw exception(PASSWORDS_NOT_EXISTS);
}
}
@Override
public PasswordsDO getPasswords(Long id) {
return passwordsMapper.selectById(id);
}
@Override
public List<PasswordsDO> getPasswordsList(Collection<Long> ids) {
return passwordsMapper.selectBatchIds(ids);
}
@Override
public PageResult<PasswordsDO> getPasswordsPage(PasswordsPageReqVO pageReqVO) {
return passwordsMapper.selectPage(pageReqVO);
}
@Override
public List<PasswordsDO> getPasswordsList(PasswordsExportReqVO exportReqVO) {
return passwordsMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.setting.dal.mysql.passwords.PasswordsMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,231 @@
package cn.iocoder.yudao.module.setting.service.passwords;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.setting.controller.admin.passwords.vo.*;
import cn.iocoder.yudao.module.setting.dal.dataobject.passwords.PasswordsDO;
import cn.iocoder.yudao.module.setting.dal.mysql.passwords.PasswordsMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.setting.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link PasswordsServiceImpl}
*
* @author
*/
@Import(PasswordsServiceImpl.class)
public class PasswordsServiceImplTest extends BaseDbUnitTest {
@Resource
private PasswordsServiceImpl passwordsService;
@Resource
private PasswordsMapper passwordsMapper;
@Test
public void testCreatePasswords_success() {
// 准备参数
PasswordsCreateReqVO reqVO = randomPojo(PasswordsCreateReqVO.class);
// 调用
Long passwordsId = passwordsService.createPasswords(reqVO);
// 断言
assertNotNull(passwordsId);
// 校验记录的属性是否正确
PasswordsDO passwords = passwordsMapper.selectById(passwordsId);
assertPojoEquals(reqVO, passwords);
}
@Test
public void testUpdatePasswords_success() {
// mock 数据
PasswordsDO dbPasswords = randomPojo(PasswordsDO.class);
passwordsMapper.insert(dbPasswords);// @Sql: 先插入出一条存在的数据
// 准备参数
PasswordsUpdateReqVO reqVO = randomPojo(PasswordsUpdateReqVO.class, o -> {
o.setId(dbPasswords.getId()); // 设置更新的 ID
});
// 调用
passwordsService.updatePasswords(reqVO);
// 校验是否更新正确
PasswordsDO passwords = passwordsMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, passwords);
}
@Test
public void testUpdatePasswords_notExists() {
// 准备参数
PasswordsUpdateReqVO reqVO = randomPojo(PasswordsUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> passwordsService.updatePasswords(reqVO), PASSWORDS_NOT_EXISTS);
}
@Test
public void testDeletePasswords_success() {
// mock 数据
PasswordsDO dbPasswords = randomPojo(PasswordsDO.class);
passwordsMapper.insert(dbPasswords);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbPasswords.getId();
// 调用
passwordsService.deletePasswords(id);
// 校验数据不存在了
assertNull(passwordsMapper.selectById(id));
}
@Test
public void testDeletePasswords_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> passwordsService.deletePasswords(id), PASSWORDS_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetPasswordsPage() {
// mock 数据
PasswordsDO dbPasswords = randomPojo(PasswordsDO.class, o -> { // 等会查询到
o.setPasswordValue(null);
o.setEnableFlag(null);
o.setRemark(null);
o.setAttr3(null);
o.setCreateTime(null);
o.setCreateBy(null);
o.setDeptId(null);
o.setDeptName(null);
o.setCompanyId(null);
o.setUserId(null);
o.setCompany(null);
});
passwordsMapper.insert(dbPasswords);
// 测试 passwordValue 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setPasswordValue(null)));
// 测试 enableFlag 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setEnableFlag(null)));
// 测试 remark 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setRemark(null)));
// 测试 attr3 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setAttr3(null)));
// 测试 createTime 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCreateTime(null)));
// 测试 createBy 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCreateBy(null)));
// 测试 deptId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setDeptId(null)));
// 测试 deptName 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setDeptName(null)));
// 测试 companyId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCompanyId(null)));
// 测试 userId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setUserId(null)));
// 测试 company 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCompany(null)));
// 准备参数
PasswordsPageReqVO reqVO = new PasswordsPageReqVO();
reqVO.setPasswordValue(null);
reqVO.setEnableFlag(null);
reqVO.setRemark(null);
reqVO.setAttr3(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setCreateBy(null);
reqVO.setDeptId(null);
reqVO.setDeptName(null);
reqVO.setCompanyId(null);
reqVO.setUserId(null);
reqVO.setCompany(null);
// 调用
PageResult<PasswordsDO> pageResult = passwordsService.getPasswordsPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbPasswords, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetPasswordsList() {
// mock 数据
PasswordsDO dbPasswords = randomPojo(PasswordsDO.class, o -> { // 等会查询到
o.setPasswordValue(null);
o.setEnableFlag(null);
o.setRemark(null);
o.setAttr3(null);
o.setCreateTime(null);
o.setCreateBy(null);
o.setDeptId(null);
o.setDeptName(null);
o.setCompanyId(null);
o.setUserId(null);
o.setCompany(null);
});
passwordsMapper.insert(dbPasswords);
// 测试 passwordValue 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setPasswordValue(null)));
// 测试 enableFlag 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setEnableFlag(null)));
// 测试 remark 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setRemark(null)));
// 测试 attr3 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setAttr3(null)));
// 测试 createTime 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCreateTime(null)));
// 测试 createBy 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCreateBy(null)));
// 测试 deptId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setDeptId(null)));
// 测试 deptName 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setDeptName(null)));
// 测试 companyId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCompanyId(null)));
// 测试 userId 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setUserId(null)));
// 测试 company 不匹配
passwordsMapper.insert(cloneIgnoreId(dbPasswords, o -> o.setCompany(null)));
// 准备参数
PasswordsExportReqVO reqVO = new PasswordsExportReqVO();
reqVO.setPasswordValue(null);
reqVO.setEnableFlag(null);
reqVO.setRemark(null);
reqVO.setAttr3(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setCreateBy(null);
reqVO.setDeptId(null);
reqVO.setDeptName(null);
reqVO.setCompanyId(null);
reqVO.setUserId(null);
reqVO.setCompany(null);
// 调用
List<PasswordsDO> list = passwordsService.getPasswordsList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbPasswords, list.get(0));
}
}

@ -60,11 +60,11 @@
</dependency> </dependency>
<!-- 数据报表--> <!-- 数据报表-->
<!-- <dependency>--> <dependency>
<!-- <groupId>cn.iocoder.boot</groupId>--> <groupId>cn.iocoder.boot</groupId>
<!-- <artifactId>yudao-module-report-biz</artifactId>--> <artifactId>yudao-module-report-biz</artifactId>
<!-- <version>${revision}</version>--> <version>${revision}</version>
<!-- </dependency>--> </dependency>
<!-- 工作流 --> <!-- 工作流 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>

@ -103,7 +103,7 @@ yudao:
base-package: cn.iocoder.yudao base-package: cn.iocoder.yudao
web: web:
admin-ui: admin-ui:
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 url: http://192.168.3.172:81 # Admin 管理后台 UI 的地址,本项目扫码查看装册详情有调用
security: security:
permit-all_urls: permit-all_urls:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录

Loading…
Cancel
Save