更新(批量)系统用户信息
This commit is contained in:
parent
e1375c03f0
commit
d612c906e2
@ -36,6 +36,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/global/configuration/**").permitAll()
|
||||
.antMatchers("/push/**").permitAll()
|
||||
.antMatchers("/queryFirePoint").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/selectGlobalConfigValue").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/selectGlobalConfig").permitAll()
|
||||
|
@ -17,6 +17,7 @@ import com.xkrs.service.RedisService;
|
||||
import com.xkrs.service.SysUserService;
|
||||
import com.xkrs.sms.SMSHelper;
|
||||
import com.xkrs.utils.FirePointCodeUtils;
|
||||
import com.xkrs.utils.ListUtils;
|
||||
import com.xkrs.utils.RandomUtil;
|
||||
import org.apache.hc.core5.util.TextUtils;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
@ -37,14 +38,11 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256;
|
||||
|
||||
/**
|
||||
* 系统用户Controller
|
||||
*
|
||||
* @author tajocehn
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/user")
|
||||
public class SysUserController {
|
||||
|
||||
// 获取区域信息
|
||||
private final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
@Resource
|
||||
@ -62,6 +60,56 @@ public class SysUserController {
|
||||
@Resource
|
||||
private SMSHelper smsHelper;
|
||||
|
||||
/**
|
||||
* 更新(批量)系统用户信息
|
||||
*
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequestMapping(value = "/updateSysUser", method = RequestMethod.POST)
|
||||
public String updateSysUser(@RequestBody Map<String, String> paramMap) {
|
||||
String userIdArray = paramMap.get("userIdArray");
|
||||
String overTime = paramMap.get("overTime");
|
||||
String remark = paramMap.get("remark");
|
||||
List<String> userIdList = ListUtils.toStringList(userIdArray, ",");//解析的ID集合
|
||||
if (userIdList.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "修改失败,请输入正确的ID", locale);
|
||||
}
|
||||
List<String> successIdList = new ArrayList<>();//操作成功的ID集合
|
||||
List<String> failureIdList = new ArrayList<>();//操作失败的ID集合
|
||||
for (String userId : userIdList) {
|
||||
try {
|
||||
Optional<SysUserEntity> targetEntityOptional = sysUserDao.findById(Integer.parseInt(userId));
|
||||
if (targetEntityOptional.isPresent()) {
|
||||
SysUserEntity targetEntity = targetEntityOptional.get();
|
||||
if (!TextUtils.isEmpty(overTime)) {
|
||||
targetEntity.setOverTime(overTime);
|
||||
}
|
||||
if (!TextUtils.isEmpty(remark)) {
|
||||
targetEntity.setRemark(remark);
|
||||
}
|
||||
sysUserDao.save(targetEntity);
|
||||
successIdList.add(userId);
|
||||
} else {
|
||||
failureIdList.add(userId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
failureIdList.add(userId);
|
||||
}
|
||||
}
|
||||
if (userIdList.size() == successIdList.size()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (successIdList.size() > 0) {
|
||||
builder.append("ID:").append(ListUtils.fromStringList(successIdList, "、")).append("修改成功,");
|
||||
}
|
||||
builder.append("ID:").append(ListUtils.fromStringList(failureIdList, "、")).append("修改失败");
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "修改失败," + builder, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改vip等级
|
||||
*/
|
||||
|
@ -16,10 +16,13 @@ public class ListUtils {
|
||||
* @return
|
||||
*/
|
||||
public static List<String> toStringList(String content, String splitRegex) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
return list;
|
||||
}
|
||||
if (TextUtils.isEmpty(splitRegex)) {
|
||||
throw new RuntimeException("splitRegex == null");
|
||||
}
|
||||
List<String> list = new ArrayList<>();
|
||||
if (content.contains(splitRegex)) {
|
||||
String[] splitArray = content.split(splitRegex);
|
||||
if (splitArray.length > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user