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 b9db3b9..fb7d35b 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 @@ -18,6 +18,7 @@ import com.ruoyi.system.service.ISysUserService; import com.ruoyi.tc.entity.*; import com.ruoyi.tc.entity.po.*; import com.ruoyi.tc.entity.request.UnitRequest; +import com.ruoyi.tc.entity.response.AssetSysUserExport; import com.ruoyi.tc.regular.AssetCurrentChange; import com.ruoyi.tc.regular.UnitChange; import com.ruoyi.tc.service.*; @@ -169,6 +170,25 @@ public class UnitController { util.exportExcel(response, list, "单位数据"); } + /** + * 所有单位生成随机密码并导出 + */ + @ApiOperation(value = "所有单位生成随机密码并导出") + @PostMapping("/exportAllPassword") + public void exportAllPassword(HttpServletResponse response) { + List list = unitService.exportAllPassword(); + list.forEach(x->{ + String ps = PasswordGenerator.password(); + x.setPassword(ps); + AssetSysUserExport as = new AssetSysUserExport(); + as.setUserId(x.getUserId()); + as.setPassword(SecurityUtils.encryptPassword(ps)); + unitService.updatePasswordUser(as); + }); + ExcelUtil util = new ExcelUtil<>(AssetSysUserExport.class); + util.exportExcel(response, list, "单位密码数据"); + } + /** * 单位导入 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/response/AssetSysUserExport.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/response/AssetSysUserExport.java new file mode 100644 index 0000000..622b43e --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/response/AssetSysUserExport.java @@ -0,0 +1,42 @@ +package com.ruoyi.tc.entity.response; + +import com.ruoyi.common.annotation.Excel; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author du + * @since 2024/12/29 18:36 + */ +@Data +@ApiModel("单位密码导出") +public class AssetSysUserExport { + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private String userId; + + /** + * 统一社会信用代码 + */ + @Excel(name = "统一社会信用代码") + @ApiModelProperty("统一社会信用代码") + private String userName; + + + /** + * 单位名称 + */ + @Excel(name = "单位名称") + @ApiModelProperty("单位名称") + private String nickName; + + /** + * 密码 + */ + @Excel(name = "密码") + private String password; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java index 6f56a2e..c29f55f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java @@ -3,10 +3,12 @@ package com.ruoyi.tc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; import com.ruoyi.tc.entity.request.UnitRequest; +import com.ruoyi.tc.entity.response.AssetSysUserExport; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -119,4 +121,14 @@ public interface UnitMapper extends BaseMapper { * web资产的单位组织架构不为空的部门 */ List getWebSchema(); + + /** + * 查询所有单位 + */ + List exportAllPassword(); + + /** + * 单位生成随机密码 + */ + int updatePasswordUser(@Param("req") AssetSysUserExport x); } 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 6ace952..e81bb21 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 @@ -4,10 +4,12 @@ package com.ruoyi.tc.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; import com.ruoyi.tc.entity.request.UnitRequest; +import com.ruoyi.tc.entity.response.AssetSysUserExport; import java.util.List; @@ -100,4 +102,15 @@ public interface UnitService extends IService { * 根据资产类型返回组织架构 */ List getSchema(String type); + + /** + * 查询所有单位 + */ + List exportAllPassword(); + + + /** + * 单位生成随机密码 + */ + int updatePasswordUser(AssetSysUserExport x); } 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 7ef14d5..e89ea3e 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 @@ -15,12 +15,14 @@ import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; import com.ruoyi.tc.entity.request.UnitRequest; +import com.ruoyi.tc.entity.response.AssetSysUserExport; import com.ruoyi.tc.mapper.UnitMapper; import com.ruoyi.tc.service.UnitService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -187,4 +189,20 @@ public class UnitServiceImpl extends ServiceImpl implements Un return iSysDeptService.buildDeptTreeSelect(appSchema); } + /** + * 查询所有单位 + */ + @Override + public List exportAllPassword() { + return baseMapper.exportAllPassword(); + } + + /** + * 单位生成随机密码 + */ + @Override + public int updatePasswordUser(AssetSysUserExport x) { + return baseMapper.updatePasswordUser(x); + } + } diff --git a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml index b0d428d..5d568b6 100644 --- a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml @@ -95,6 +95,14 @@ + + update sys_user + + password = #{req.password}, + update_time = sysdate() + + where user_id = #{req.userId} + +