From bf40277f7ffebfb42dab34ed22a05a4e2fe50d44 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Tue, 26 Nov 2024 14:01:19 +0800 Subject: [PATCH] bugfix --- .../tc/controller/AssetCurrentController.java | 8 +- .../ruoyi/tc/controller/UnitController.java | 34 +++-- .../com/ruoyi/tc/entity/AssetCurrent.java | 118 ++++++++++-------- .../main/java/com/ruoyi/tc/entity/Unit.java | 3 + .../request/AssetCurrentPageRequest.java | 6 + .../ruoyi/tc/mapper/AssetCurrentMapper.java | 12 ++ .../ruoyi/tc/service/AssetCurrentService.java | 4 +- .../com/ruoyi/tc/service/UnitService.java | 2 +- .../service/impl/AssetCurrentServiceImpl.java | 4 +- .../tc/service/impl/UnitServiceImpl.java | 24 ++-- .../ruoyi/common/utils/PasswordGenerator.java | 26 ++++ 11 files changed, 158 insertions(+), 83 deletions(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/PasswordGenerator.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java index 741604e..b6ac4e5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetCurrentController.java @@ -21,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.Serializable; import java.util.List; @@ -73,6 +74,7 @@ public class AssetCurrentController extends BaseController { return success(assetCurrentService.page(page, as)); } + /** * 查询所有数据(带子表) * @@ -114,7 +116,7 @@ public class AssetCurrentController extends BaseController { @PostMapping @PreAuthorize("@ss.hasAnyRoles('admin,common')") @Transactional(rollbackFor = Exception.class) - public AjaxResult insert(@RequestBody AssetCurrent assetCurrent) { + public AjaxResult insert(@RequestBody @Valid AssetCurrent assetCurrent) { StringBuilder a = new StringBuilder(); if (!assetCurrent.getGlymList().isEmpty()) { assetCurrent.getGlymList().forEach(x -> { @@ -170,7 +172,7 @@ public class AssetCurrentController extends BaseController { @ApiOperation(value = "修改数据") @PreAuthorize("@ss.hasAnyRoles('admin,common')") @PutMapping - public AjaxResult update(@RequestBody AssetCurrent assetCurrent) { + public AjaxResult update(@RequestBody @Valid AssetCurrent assetCurrent) { StringBuilder a = new StringBuilder(); if (!assetCurrent.getGlymList().isEmpty()) { assetCurrent.getGlymList().forEach(x -> { @@ -266,7 +268,7 @@ public class AssetCurrentController extends BaseController { } catch (Exception e) { throw new ServiceException("获取用户信息异常"); } - List list = assetCurrentService.page(as); + List list = assetCurrentService.page1(as); ExcelUtil util = new ExcelUtil<>(AssetExport.class); util.exportExcel(response, list, "现有资产记录"); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java index 8656f5f..d24aaf1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java @@ -24,7 +24,9 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 单位(unit)表控制层 @@ -34,7 +36,7 @@ import java.util.List; */ @Api(tags = "单位表控制层") @RestController -//@PreAuthorize("@ss.hasAnyRoles('admin,common')") +@PreAuthorize("@ss.hasAnyRoles('admin,common')") @RequestMapping("/tc/unit") public class UnitController { @@ -62,6 +64,15 @@ public class UnitController { return AjaxResult.success(unitService.page(page, unit)); } + /** + * 获取所有单位列表 + */ + @ApiOperation(value = "获取所有单位列表", response = Unit.class) + @GetMapping("/allList") + public AjaxResult allList(UnitRequest unit) { + return AjaxResult.success(unitService.selectUnitList( unit)); + } + /** * 单位导出 */ @@ -85,11 +96,13 @@ public class UnitController { ExcelUtil util = new ExcelUtil<>(Unit.class); List list = util.importExcel(file.getInputStream()); unitService.saveBatch(list); + Map a1 = new HashMap<>(); for (Unit x : list) { //查询用户表是否存在该用户 - unitService.validUser(x); + String s = unitService.validUser(x); + a1.put(x.getUserName(),s); } - return AjaxResult.success(); + return AjaxResult.success(a1); } @PostMapping("/importTemplate") @@ -115,7 +128,7 @@ public class UnitController { @Log(title = "新增单位", businessType = BusinessType.INSERT) @PostMapping @Transactional(rollbackFor = Exception.class) - public AjaxResult add( @RequestBody Unit unit) { + public AjaxResult add(@Valid @RequestBody Unit unit) { if (!unitService.lambdaQuery().eq(Unit::getUserName, unit.getUserName()).eq(Unit::getDelFlag, "0").list().isEmpty()) { throw new ServiceException(unit.getUserName() + "'已存在单位!"); } @@ -135,9 +148,8 @@ public class UnitController { }); examineInfoService.saveBatch(unit.getJcxxList()); } - //查询用户表是否存在该用户 - unitService.validUser(unit); - return AjaxResult.success(); + String s = unitService.validUser(unit); + return AjaxResult.success(s); } /** @@ -147,9 +159,11 @@ public class UnitController { @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping @Transactional(rollbackFor = Exception.class) - public AjaxResult edit(@RequestBody Unit x) { - //查询用户表是否存在该用户 - unitService.validUser(x); + public AjaxResult edit(@Valid @RequestBody Unit x) { + Unit byId = unitService.getById(x.getId()); + if(!byId.getUserName().equals(x.getUserName()) || !byId.getNickName().equals(x.getNickName())){ + throw new ServiceException("单位名称和社会信用代码不允许修改!"); + } unitService.updateById(x); //先删除 unitOtherConcatService.deleteByUnitIds(x.getId()); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java index 48edb67..4026a3e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java @@ -38,14 +38,22 @@ public class AssetCurrent extends BaseClass implements Serializable { @NotBlank @Size(max= 100,message="系统名称长度不能超过100") @ApiModelProperty("系统名称") + @Excel(name = "*系统名称",sort = 2,width = 40,required = true) private String xtmc; + +// /** +// * 资产类型 +// */ +// @ApiModelProperty("资产类型") +// private String zclx; + /** * 单位名称 */ @NotBlank @Size(max= 50,message="单位名称长度不能超过50") @ApiModelProperty("单位名称") - @Excel(name = "*单位名称",sort = 1,width = 40) + @Excel(name = "*单位名称",sort = 1,width = 40,required = true) private String dwmc; /** * 系统域名 @@ -69,7 +77,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * IPport-IP地址 */ - @NotBlank + //@NotBlank @Size(max= 50,message="IPport-IP地址长度不能超过50") @ApiModelProperty("IPport-IP地址") @Excel(name = "*ipv4",sort = 4) @@ -77,7 +85,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * IPport-端口 */ - @NotBlank + //@NotBlank @Excel(name = "*端口",sort = 5) @Size(max= 50,message="IPport-端口不能超过50") @ApiModelProperty("IPport-端口") @@ -129,7 +137,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统类型(字典) */ @Excel(name = "*系统类型",dictType="zc_xtlx",comboReadDict = true,sort =8) - @NotNull + //@NotNull @ApiModelProperty("系统类型(字典)") private String xtlx; /** @@ -141,7 +149,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 是否关基系统(字典) */ - @NotNull + //@NotNull // @Excel(name = "是否关基系统",dictType = "is_no",comboReadDict = true,sort = 10) @Excel(name = "*是否关基系统",dictType = "is_no",comboReadDict = true,sort = 10) @ApiModelProperty("是否关基系统(字典)") @@ -156,7 +164,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 机房信息 */ - @NotBlank + //@NotBlank @Excel(name = "*机房信息",sort = 58) @Size(max= 500,message="机房信息长度不能超过500") @ApiModelProperty("机房信息") @@ -164,7 +172,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 使用时间 */ - @NotBlank + //@NotBlank @Size(max= 50,message="使用时间长度不能超过50") @ApiModelProperty("使用时间") @Excel(name = "使用时间",sort = 116) @@ -172,7 +180,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 是否是互联网系统(字典) */ - @NotNull + //@NotNull @Excel(name = "*是否是互联网系统",dictType = "is_no",comboReadDict = true,sort = 117 ) @ApiModelProperty("是否是互联网系统(字典)") private String hlwxt; @@ -188,7 +196,7 @@ public class AssetCurrent extends BaseClass implements Serializable { */ // @Excel(name = "系统状态",dictType = "zc_xtzt",comboReadDict = true,sort = 36) @Excel(name = "*系统状态",dictType = "zc_xtzt",comboReadDict = true,sort = 36) - @NotNull + //@NotNull @ApiModelProperty("系统状态(字典)") private String xtzt; /** @@ -254,13 +262,13 @@ public class AssetCurrent extends BaseClass implements Serializable { * 用户规模 */ @Excel(name = "*用户规模",dictType ="zc_yhgm",comboReadDict = true,sort = 53) - @NotNull + //@NotNull @ApiModelProperty("用户规模") private String yhgm; /** * 互联网接入运营商 */ - @NotBlank + //@NotBlank @Excel(name = "*互联网接入运营商",sort = 54) @Size(max= 50,message="互联网接入运营商长度不能超过50") @ApiModelProperty("互联网接入运营商") @@ -275,14 +283,14 @@ public class AssetCurrent extends BaseClass implements Serializable { * 资产物理接入地址 */ @Excel(name = "*资产物理接入地址",sort = 118,width = 28) - @NotBlank + //@NotBlank @Size(max= 50,message="资产物理接入地址长度不能超过50") @ApiModelProperty("资产物理接入地址") private String zcwljrdz; /** * 是否部署云平台(字典) */ - @NotNull + //@NotNull @Excel(name = "*是否部署云平台",sort = 56,dictType = "is_no",comboReadDict = true) @ApiModelProperty("是否部署云平台(字典)") private String bsypt; @@ -304,7 +312,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统部署方式 */ @Excel(name = "*系统部署方式",dictType = "zc_xtbsfs",comboReadDict = true,sort = 59) - @NotNull + //@NotNull @ApiModelProperty("系统部署方式") private String xtbsfs; /** @@ -325,13 +333,13 @@ public class AssetCurrent extends BaseClass implements Serializable { * 是否对公众开放(字典) */ @Excel(name = "*是否对公众开放",dictType = "is_no",comboReadDict = true,sort = 62,width = 22) - @NotNull + //@NotNull @ApiModelProperty("是否对公众开放(字典)") private String dgzkf; /** * 互联网开放用途(字典) */ - @NotNull + //@NotNull @Excel(name = "*互联网开放用途",dictType = "zc_hlwkfyt",comboReadDict = true,sort = 63,width = 22) @ApiModelProperty("互联网开放用途(字典)") private String hlwkfyt; @@ -388,7 +396,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 相关业务-业务描述 */ - @NotNull + //@NotNull @Size(max= 500,message="相关业务-业务描述长度不能超过255") @ApiModelProperty("相关业务-业务描述") private String xgywYwms; @@ -401,7 +409,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 分管负责人姓名 */ @Excel(name = "*分管负责人",sort = 15) - @NotBlank + //@NotBlank @Size(max= 50,message="分管负责人姓名长度不能超过50") @ApiModelProperty("分管负责人姓名") private String fgfzrxm; @@ -409,7 +417,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 分管负责人联系方式 */ @Excel(name = "*分管负责人电话",sort = 16,width = 24) - @NotBlank + //@NotBlank @Size(max= 50,message="分管负责人联系方式长度不能超过50") @ApiModelProperty("分管负责人联系方式") private String fgfzrlxfs; @@ -424,7 +432,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 部门负责人姓名 */ @Excel(name = "*部门负责人",sort = 18) - @NotBlank + //@NotBlank @Size(max= 50,message="部门负责人姓名长度不能超过50") @ApiModelProperty("部门负责人姓名") private String bmfzrxm; @@ -432,7 +440,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 部门负责人联系方式 */ @Excel(name = "*部门负责人电话",sort = 19,width = 24) - @NotBlank + //@NotBlank @Size(max= 50,message="部门负责人联系方式长度不能超过50") @ApiModelProperty("部门负责人联系方式") private String bmfzrlxfs; @@ -447,14 +455,14 @@ public class AssetCurrent extends BaseClass implements Serializable { * 第一联系人姓名 */ @Excel(name = "*第一联系人",sort = 21) - @NotBlank + //@NotBlank @Size(max= 50,message="第一联系人姓名长度不能超过50") @ApiModelProperty("第一联系人姓名") private String dylxrxm; /** * 第一联系人联系方式 */ - @NotBlank + //@NotBlank @Excel(name = "*第一联系人电话",sort = 22,width = 24) @Size(max= 50,message="第一联系人联系方式长度不能超过50") @ApiModelProperty("第一联系人联系方式") @@ -475,7 +483,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * ICP备案信息-是否备案 */ @Excel(name = "*ICP备案状态",dictType = "is_no",comboReadDict = true,sort = 24) - @NotNull + //@NotNull @ApiModelProperty("ICP备案信息-是否备案") private String ipcSfba; /** @@ -500,7 +508,7 @@ public class AssetCurrent extends BaseClass implements Serializable { */ // @Excel(name = "ICP备案编号",sort = 25,width = 46) @Excel(name = "ICP备案编号(ICP备案状态选择为是则必填)",sort = 25,width = 46) - @NotBlank + //@NotBlank @Size(max= 50,message="ICP备案信息-ICP备案编号长度不能超过50") @ApiModelProperty("ICP备案信息-ICP备案编号") private String ipcIpcbabh; @@ -508,7 +516,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * ICP备案信息-备案域名 */ @Excel(name = "*备案域名",sort = 26) - @NotBlank + //@NotBlank @Size(max= 50,message="ICP备案信息-备案域名长度不能超过50") @ApiModelProperty("ICP备案信息-备案域名") private String ipcBaym; @@ -544,7 +552,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 公安机关备案信息-是否备案 */ - @NotNull + //@NotNull @Excel(name = "*公安机关备案状态",dictType = "is_no",comboReadDict = true,sort = 27,width = 24) @ApiModelProperty("公安机关备案信息-是否备案") private String gajgSfba; @@ -560,7 +568,7 @@ public class AssetCurrent extends BaseClass implements Serializable { @Excel(name = "*公安机关备案号",sort = 28,width = 22) @Size(max= 50,message="公安机关备案信息-公安机关备案号长度不能超过50") @ApiModelProperty("公安机关备案信息-公安机关备案号") - @NotBlank + //@NotBlank private String gajgBah; /** * 公安机关备案信息-备案日期 @@ -571,7 +579,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 系统架构-开发商 */ - @NotBlank + //@NotBlank @Excel(name = "*开发商",sort = 29) @Size(max= 50,message="系统架构-开发商长度不能超过50") @ApiModelProperty("系统架构-开发商") @@ -580,7 +588,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-系统版本 */ @Excel(name = "*系统版本",sort = 30) - @NotBlank + //@NotBlank @Size(max= 50,message="系统架构-系统版本长度不能超过50") @ApiModelProperty("系统架构-系统版本") private String xtjgXtbb; @@ -588,7 +596,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-技术架构 */ @Excel(name = "*技术架构",sort = 31) - @NotBlank + //@NotBlank @Size(max= 50,message="系统架构-技术架构长度不能超过50") @ApiModelProperty("系统架构-技术架构") private String xtjgJsjg; @@ -596,7 +604,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-服务组件 */ @Excel(name = "*服务组件",sort = 32) - @NotBlank + //@NotBlank @Size(max= 50,message="系统架构-服务组件长度不能超过50") @ApiModelProperty("系统架构-服务组件") private String xtjgFwzj; @@ -604,7 +612,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-web容器名称 */ @Excel(name = "*Web容器版本",sort = 33) - @NotBlank + //@NotBlank @Size(max= 50,message="系统架构-web容器名称长度不能超过50") @ApiModelProperty("系统架构-web容器名称") private String xtjgWebMc; @@ -612,7 +620,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-web容器版本 */ @Excel(name = "*Web容器名称",sort = 34) - @NotBlank + //@NotBlank @Size(max= 50,message="系统架构-web容器版本长度不能超过50") @ApiModelProperty("系统架构-web容器版本") private String xtjgWebBb; @@ -620,14 +628,14 @@ public class AssetCurrent extends BaseClass implements Serializable { * 系统架构-是否国产化系统 */ @Excel(name = "*是否国产化系统",dictType = "is_no",comboReadDict = true,sort = 35,width = 22) - @NotNull + //@NotNull @ApiModelProperty("系统架构-是否国产化系统") private String xtjgGcxt; /** * 系统架构-是否有国产设备 */ @Excel(name = "*是否有国产设备",dictType = "is_no",comboReadDict = true,sort = 35,width = 22) - @NotNull + //@NotNull @ApiModelProperty("系统架构-是否有国产设备") private String xtjgGcsb; /** @@ -640,13 +648,13 @@ public class AssetCurrent extends BaseClass implements Serializable { * 等保信息-是否等保系统 */ @Excel(name = "*是否是等保系统",dictType = "is_no",comboReadDict = true,sort = 42) - @NotNull + //@NotNull @ApiModelProperty("等保信息-是否等保系统") private String dbxxSfdbxt; /** * 等保信息-等保测评备案号 */ - @NotBlank + //@NotBlank @Excel(name = "*等保测评备案号",sort = 43,width = 22) @Size(max= 50,message="等保信息-等保测评备案号长度不能超过50") @ApiModelProperty("等保信息-等保测评备案号") @@ -654,7 +662,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 等保信息-等保等级 */ - @NotNull + //@NotNull @Excel(name = "*等保等级",dictType = "dbxx_dbdj",comboReadDict = true,sort = 44) @ApiModelProperty("等保信息-等保等级") private String dbxxDbdj; @@ -677,7 +685,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 等保信息-定级时间 */ - @NotBlank + //@NotBlank @Excel(name = "定级时间(是否是等保系统是则必填,样式如2024-11-02)",sort = 119,width = 40) @Size(max= 50,message="等保信息-定级时间长度不能超过50") @ApiModelProperty("等保信息-定级时间") @@ -687,7 +695,7 @@ public class AssetCurrent extends BaseClass implements Serializable { */ // @Excel(name = "是否有第三方测评",width = 45,dictType = "is_no",comboReadDict = true,sort = 45) @ApiModelProperty("等保信息-是否有第三方测评") - @NotNull + //@NotNull @Excel(name = "是否有第三方测评(是否是等保系统选择是则必填)",width = 45,dictType = "is_no",comboReadDict = true,sort = 45) private String dbxxSfydsfcp; @@ -705,7 +713,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 等保信息-测评得分 */ - @NotBlank + //@NotBlank @Excel(name = "*测评得分",sort = 49) @Size(max= 50,message="等保信息-测评得分长度不能超过50") @ApiModelProperty("等保信息-测评得分") @@ -901,7 +909,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 数据资产-数据库类型 */ - @NotBlank + //@NotBlank @Excel(name = "*数据库类型",sort = 99) @Size(max= 50,message="数据资产-数据库类型长度不能超过50") @ApiModelProperty("数据资产-数据库类型") @@ -910,7 +918,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 数据资产-端口 */ @Excel(name = "*数据库端口",sort = 100) - @NotBlank + //@NotBlank @Size(max= 50,message="数据资产-端口长度不能超过50") @ApiModelProperty("数据资产-端口") private String sjzcDk; @@ -918,7 +926,7 @@ public class AssetCurrent extends BaseClass implements Serializable { * 数据资产-数据库版本 */ @Excel(name = "*数据库版本",sort = 101) - @NotBlank + //@NotBlank @Size(max= 50,message="数据资产-数据库版本长度不能超过255") @ApiModelProperty("数据资产-数据库版本") private String sjzcSjkbb; @@ -932,7 +940,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 数据资产-共享属性 */ - @NotNull + //@NotNull @Excel(name = "*共享属性",dictType = "sjzc_gxsx",comboReadDict = true,sort = 103) @ApiModelProperty("数据资产-共享属性") private String sjzcGxsx; @@ -940,27 +948,27 @@ public class AssetCurrent extends BaseClass implements Serializable { * 数据资产-开放属性 */ @Excel(name = "*开放属性",dictType = "sjzc_kfsx",comboReadDict = true,sort = 104) - @NotNull + //@NotNull @ApiModelProperty("数据资产-开放属性") private String sjzcKfsx; /** * 数据资产-数据领域 */ - @NotNull + //@NotNull @Excel(name = "*数据领域",dictType = "sjzc_sjly",comboReadDict = true,sort = 105) @ApiModelProperty("数据资产-数据领域") private String sjzcSjly; /** * 数据资产-更新周期 */ - @NotNull + //@NotNull @Excel(name = "*更新周期",dictType = "sjzc_gxzq",comboReadDict = true,sort = 106) @ApiModelProperty("数据资产-更新周期") private String sjzcGxzq; /** * 数据资产-数据类型 */ - @NotBlank + //@NotBlank @Excel(name = "*数据类型",sort = 107) @Size(max= 255,message="数据资产-数据类型长度不能超过255") @ApiModelProperty("数据资产-数据类型") @@ -968,7 +976,7 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 数据资产-数据量 */ - @NotBlank + //@NotBlank @Excel(name = "*数据量",sort = 108) @Size(max= 255,message="数据资产-数据量长度不能超过255") @ApiModelProperty("数据资产-数据量") @@ -981,28 +989,28 @@ public class AssetCurrent extends BaseClass implements Serializable { /** * 数据资产-是否为涉密数据 */ - @NotNull + //@NotNull @Excel(name = "*是否为涉密数据",dictType = "is_no",comboReadDict = true,sort = 110) @ApiModelProperty("数据资产-是否为涉密数据") private String sjzcSmsj; /** * 数据资产-数据是否出境 */ - @NotNull + //@NotNull @Excel(name = "*数据是否出境",dictType = "is_no",comboReadDict = true,sort = 111) @ApiModelProperty("数据资产-数据是否出境") private String sjzcCj; /** * 数据资产-数据分级分类 */ - @NotNull + //@NotNull @Excel(name = "*数据分级分类",dictType = "sjzc_sjfjfl",comboReadDict = true,sort = 112) @ApiModelProperty("数据资产-数据分级分类") private String sjzcSjfjfl; /** * 数据资产-数据重要程度 */ - @NotNull + //@NotNull @Excel(name = "数据重要程度",dictType = "zc_xtzyx",comboReadDict = true,sort = 113) @ApiModelProperty("数据资产-数据重要程度") private String sjzcSjzycd; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java index acda13a..c5b0eac 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java @@ -10,6 +10,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.Valid; +import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -28,6 +29,7 @@ public class Unit implements Serializable { @TableId(type = IdType.AUTO,value = "id") private Long id; + @NotBlank @ApiModelProperty("单位名称/用户昵称") @Excel(name = "单位名称*",required = true) private String nickName; @@ -75,6 +77,7 @@ public class Unit implements Serializable { @Excel(name = "单位角色",dictType="dwjs",comboReadDict = true) private String dwjs; + @NotBlank @ApiModelProperty("统一社会信用代码/用户账号") @Excel(name = "统一社会信用代码",required = true) private String userName; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/AssetCurrentPageRequest.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/AssetCurrentPageRequest.java index 962c1b4..6975ddb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/AssetCurrentPageRequest.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/request/AssetCurrentPageRequest.java @@ -15,6 +15,12 @@ import java.util.Date; @Data public class AssetCurrentPageRequest { +// /** +// * 资产类型 +// */ +// @ApiModelProperty("资产类型") +// private String zclx; + /** * 系统名称 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java index 6e57afd..e3fd7ed 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/AssetCurrentMapper.java @@ -26,6 +26,18 @@ public interface AssetCurrentMapper extends BaseMapper { */ Page page(Page page,@Param("req") AssetCurrentPageRequest as); + /** + * 查询所有数据 + * + * @param as 查询实体 + * @return 所有数据 + */ + List page(@Param("req") AssetCurrentPageRequest as); + + + /** + * 导出查询所有数据 + */ List page1(@Param("req") AssetCurrentPageRequest as); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java index 00acdd8..dc0b311 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/AssetCurrentService.java @@ -27,12 +27,12 @@ public interface AssetCurrentService extends IService { Page page(Page page, AssetCurrentPageRequest as); /** - * 查询所有数据 + * 导出查询所有数据 * * @param as 查询实体 * @return 所有数据 */ - List page(AssetCurrentPageRequest as); + List page1(AssetCurrentPageRequest as); /** * 通过主键查询单条数据 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java index ea95e15..11a3d27 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java @@ -40,7 +40,7 @@ public interface UnitService extends IService { /** * 检查用户表是否存在该用户 */ - void validUser(Unit unit); + String validUser(Unit unit); /** * 根据id列表查询单位 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java index d9a5f8c..3cd7205 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java @@ -48,13 +48,13 @@ public class AssetCurrentServiceImpl extends ServiceImpl page(AssetCurrentPageRequest as) { + public List page1(AssetCurrentPageRequest as) { return baseMapper.page1(as); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java index 8309910..2e44aba 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java @@ -3,8 +3,8 @@ package com.ruoyi.tc.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.entity.SysUser; - import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.PasswordGenerator; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.service.ISysUserService; @@ -19,6 +19,7 @@ import java.util.List; /** * 单位信息(unit_info)表业务处理层 + * * @author du * @since 2024/11/13 15:02 */ @@ -27,6 +28,7 @@ public class UnitServiceImpl extends ServiceImpl implements Un @Resource private ISysUserService userService; + /** * 分页条件查询所有单位列表 * @@ -35,7 +37,7 @@ public class UnitServiceImpl extends ServiceImpl implements Un */ @Override public Page page(Page page, UnitRequest unit) { - return baseMapper.selectUnitList(page,unit); + return baseMapper.selectUnitList(page, unit); } /** @@ -62,21 +64,22 @@ public class UnitServiceImpl extends ServiceImpl implements Un * 检查用户表是否存在该用户,并做新增和修改 */ @Override - public void validUser(Unit x) { - if(x.getUserName()!=null && x.getUserName().length()>6){ + public String validUser(Unit x) { + if (x.getUserName() != null) { + String password = PasswordGenerator.password(); SysUser user = new SysUser(); user.setUserName(x.getUserName()); - user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6))); + user.setPassword(SecurityUtils.encryptPassword(password)); user.setNickName(x.getNickName()); SysUser u = userService.selectUserByUserName(x.getUserName()); if (StringUtils.isNull(u)) { userService.insertUser(user); Long[] roles = new Long[]{100L}; userService.insertUserAuth(user.getUserId(), roles); - }else { - //只修改用户账号,密码,单位名称 - userService.updateUserProfile(user); } + return password; + } else { + throw new ServiceException("统一社会信用代码/用户账号不能为空"); } } @@ -87,6 +90,7 @@ public class UnitServiceImpl extends ServiceImpl implements Un public List selectByIds(Long id) { return baseMapper.selectByIds(id); } + /** * 逻辑删除用户 */ @@ -99,13 +103,13 @@ public class UnitServiceImpl extends ServiceImpl implements Un * 逻辑删除单位 */ @Override - public void deleteUnits(Long id) { + public void deleteUnits(Long id) { baseMapper.deleteUnits(id); } @Override public Page dwList(Page page, UnitRequest unit) { - return baseMapper.dwList(page,unit); + return baseMapper.dwList(page, unit); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PasswordGenerator.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PasswordGenerator.java new file mode 100644 index 0000000..41f042f --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PasswordGenerator.java @@ -0,0 +1,26 @@ +package com.ruoyi.common.utils; + +import java.security.SecureRandom; + +/** + * @author du + * @since 2024/11/26 10:04 + */ +public class PasswordGenerator { + public static String password() { + //定义字符池 + String upperCase = "ABCDEFGHIJKLMNOPORSTUVWXYZ"; + String lowercase = "abcdefghijklmnopqrstuvwxyz"; + String numbers = "0123456789"; + String specialcharacters = "!@#$%^&*"; + String allcharacters = upperCase + lowercase + numbers + specialcharacters; + //创建随机数生成器 + SecureRandom random = new SecureRandom();// 使用 SecureRandom 以增加安全性 + StringBuilder password = new StringBuilder(16);// 使用 stringBuilder 来构建字符串 + for (int i = 0; i < 16; i++) { + int index = random.nextInt(allcharacters.length());// 随机选择字符下标 + password.append(allcharacters.charAt(index));//将字符添加到密码中 + } + return password.toString(); + } +}