Merge remote-tracking branch 'origin/main'
commit
6362099bd2
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');
|
@ -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,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,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,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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue