|
|
@@ -1,6 +1,7 @@
|
|
|
package com.cyksj.web.controller.manage.account;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -102,6 +103,15 @@ public class CmsAccountController {
|
|
|
accountView.setUnInvited(unInvited);
|
|
|
accountView.setInvited(invited);
|
|
|
accountView.setTotal(total);
|
|
|
+ List<AccountUpdatePasswordRecord> recordList = beanSearcher.searchList(AccountUpdatePasswordRecord.class,
|
|
|
+ MapUtils.builder().field(AccountUpdatePasswordRecord::getAccountId, accountView.getId())
|
|
|
+ .onlySelect(AccountUpdatePasswordRecord::getCreatedTime)
|
|
|
+ .orderBy(AccountUpdatePasswordRecord::getId)
|
|
|
+ .build());
|
|
|
+ accountView.setUpdatePwdNum(recordList.size());
|
|
|
+ if (recordList.size() > 0) {
|
|
|
+ accountView.setLastUpdatePwdDate(recordList.get(0).getCreatedTime());
|
|
|
+ }
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
@@ -146,6 +156,7 @@ public class CmsAccountController {
|
|
|
*/
|
|
|
@PostMapping("/import/account")
|
|
|
public Result<String> importAccount(Long goodsId, MultipartFile file) throws Exception {
|
|
|
+ long userId = StpUtil.getLoginIdAsLong();
|
|
|
EasyExcel.read(file.getInputStream(), ExcelImportAccountData.class, new AnalysisEventListener<ExcelImportAccountData>() {
|
|
|
@SneakyThrows
|
|
|
@Override
|
|
|
@@ -157,6 +168,7 @@ public class CmsAccountController {
|
|
|
Boolean flag = false;
|
|
|
Boolean isUpdatePwd = false;
|
|
|
if (account != null) {
|
|
|
+ String oldPwd = account.getPassword();
|
|
|
if (StrUtil.isNotBlank(data.getStartTime())) {
|
|
|
account.setStartTime(DateUtil.parse(data.getStartTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
flag = true;
|
|
|
@@ -179,6 +191,7 @@ public class CmsAccountController {
|
|
|
userTicketClearedRecordMapper.update(null, Wrappers.lambdaUpdate(UserTicketClearedRecord.class)
|
|
|
.set(UserTicketClearedRecord::getDeleted, false)
|
|
|
.eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
+ accountService.saveRecord(userId, account.getId(), oldPwd, account.getPassword(), "上传文件修改密码");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -284,7 +297,15 @@ public class CmsAccountController {
|
|
|
@SaCheckPermission("account:update")
|
|
|
@Log(module = "平台管理/编辑账号", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
public Result<String> update(@RequestBody Account account){
|
|
|
- if (StrUtil.isNotBlank(account.getAccount())){
|
|
|
+ Account db = accountService.getById(account.getId());
|
|
|
+ if (db == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该账号不存在");
|
|
|
+ }
|
|
|
+ long userId = StpUtil.getLoginIdAsLong();
|
|
|
+ if (!db.getPassword().equals(account.getPassword())) {
|
|
|
+ accountService.saveRecord(userId, account.getId(), db.getPassword(), account.getPassword(), "操作编辑");
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(account.getAccount())){
|
|
|
account.setAccount(account.getAccount().trim());
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(account.getPassword())){
|
|
|
@@ -300,21 +321,27 @@ public class CmsAccountController {
|
|
|
@PutMapping("/update/pwd")
|
|
|
@Log(module = "平台管理/批量修改密码", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
public Result<String> updatePwdAndSendMsg(@RequestBody List<Account> accounts) throws Exception {
|
|
|
+ long userId = StpUtil.getLoginIdAsLong();
|
|
|
accounts.forEach(account -> {
|
|
|
Account db = accountService.getById(account.getId());
|
|
|
- String updatePWd = account.getPassword().trim();
|
|
|
- if (!db.getPassword().equals(updatePWd)) {
|
|
|
- db.setPassword(updatePWd);
|
|
|
- accountService.updateById(db);
|
|
|
- //清空过期账号 逻辑删除
|
|
|
- userTicketClearedRecordMapper.update(null, Wrappers.lambdaUpdate(UserTicketClearedRecord.class)
|
|
|
- .set(UserTicketClearedRecord::getDeleted, false)
|
|
|
- .eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
- //发放模板消息
|
|
|
- try {
|
|
|
- templateCommonService.sendAccountTemplateMsg(account);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("发送账号{}修改密码消息模板错误", account.getId());
|
|
|
+ if (db != null) {
|
|
|
+ String oldPwd = db.getPassword();
|
|
|
+ String updatePWd = account.getPassword().trim();
|
|
|
+ if (!oldPwd.equals(updatePWd)) {
|
|
|
+ db.setPassword(updatePWd);
|
|
|
+ accountService.updateById(db);
|
|
|
+ //记录
|
|
|
+ accountService.saveRecord(userId, account.getId(), oldPwd, updatePWd, "多选修改密码");
|
|
|
+ //清空过期账号 逻辑删除
|
|
|
+ userTicketClearedRecordMapper.update(null, Wrappers.lambdaUpdate(UserTicketClearedRecord.class)
|
|
|
+ .set(UserTicketClearedRecord::getDeleted, false)
|
|
|
+ .eq(UserTicketClearedRecord::getAccountId, account.getId()));
|
|
|
+ //发放模板消息
|
|
|
+ try {
|
|
|
+ templateCommonService.sendAccountTemplateMsg(account);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发送账号{}修改密码消息模板错误", account.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -375,4 +402,13 @@ public class CmsAccountController {
|
|
|
String platForms = platFormSet.stream().collect(Collectors.joining("、"));
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(platForms);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 账号修改密码记录详情列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/updatePwd/record")
|
|
|
+ public Result<SearchResult<AccountUpdatePasswordRecord>> getUpdatePwdRecord() {
|
|
|
+ SearchResult<AccountUpdatePasswordRecord> search = beanSearcher.search(AccountUpdatePasswordRecord.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
}
|