导出单位密码

main
杜函宇 2 weeks ago
parent c265650ddc
commit 3b0284aa21

@ -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<AssetSysUserExport> 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<AssetSysUserExport> util = new ExcelUtil<>(AssetSysUserExport.class);
util.exportExcel(response, list, "单位密码数据");
}
/**
*
*/

@ -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;
}

@ -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<Unit> {
* web
*/
List<SysDept> getWebSchema();
/**
*
*/
List<AssetSysUserExport> exportAllPassword();
/**
*
*/
int updatePasswordUser(@Param("req") AssetSysUserExport x);
}

@ -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<Unit> {
*
*/
List<TreeSelect> getSchema(String type);
/**
*
*/
List<AssetSysUserExport> exportAllPassword();
/**
*
*/
int updatePasswordUser(AssetSysUserExport x);
}

@ -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<UnitMapper, Unit> implements Un
return iSysDeptService.buildDeptTreeSelect(appSchema);
}
/**
*
*/
@Override
public List<AssetSysUserExport> exportAllPassword() {
return baseMapper.exportAllPassword();
}
/**
*
*/
@Override
public int updatePasswordUser(AssetSysUserExport x) {
return baseMapper.updatePasswordUser(x);
}
}

@ -95,6 +95,14 @@
<result property="remark" column="remark"/>
</collection>
</resultMap>
<update id="updatePasswordUser" parameterType="AssetSysUserExport">
update sys_user
<set>
<if test="req.password != null and req.password != ''">password = #{req.password},</if>
update_time = sysdate()
</set>
where user_id = #{req.userId}
</update>
<select id="selectUnitList" parameterType="unit" resultMap="unitResult">
select a.*,b.dept_name as deptName from unit_info a
@ -490,6 +498,21 @@
update_time
ORDER BY dept_id desc
</select>
<select id="exportAllPassword" resultType="com.ruoyi.tc.entity.response.AssetSysUserExport">
SELECT
b.user_id as userId,
b.user_name as userName,
b.nick_name as nickName,
b.password
FROM
unit_info a
LEFT JOIN sys_user b ON a.user_name = b.user_name
GROUP BY
b.user_id,
b.user_name,
b.nick_name,
b.password
</select>
<delete id="deleteUnits">

Loading…
Cancel
Save