新增批量添加用户接口
This commit is contained in:
@@ -28,10 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +90,40 @@ public class UserController extends BaseController {
|
|||||||
return fail("添加失败");
|
return fail("添加失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAuthority('sys:user:save')")
|
||||||
|
@ApiOperation("批量添加用户")
|
||||||
|
@PostMapping("/batch")
|
||||||
|
public ApiResult<?> saveBatch(@RequestBody List<User> userList) {
|
||||||
|
userList.forEach(d -> {
|
||||||
|
d.setStatus(0);
|
||||||
|
d.setPassword(userService.encodePassword(d.getPassword()));
|
||||||
|
});
|
||||||
|
if (userService.saveBatch(userList)) {
|
||||||
|
return success("添加成功");
|
||||||
|
}
|
||||||
|
return fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAuthority('sys:user:save')")
|
||||||
|
@ApiOperation("批量添加用户并返回userId")
|
||||||
|
@PostMapping("/batchBackUserId")
|
||||||
|
public ApiResult<?> saveBatchBackUserId(@RequestBody List<User> userList) {
|
||||||
|
userList.forEach(d -> {
|
||||||
|
d.setStatus(0);
|
||||||
|
d.setPassword(userService.encodePassword(d.getPassword()));
|
||||||
|
});
|
||||||
|
final Set<String> phones = userList.stream().map(User::getPhone).collect(Collectors.toSet());
|
||||||
|
if (userService.saveBatch(userList)) {
|
||||||
|
final UserParam userParam = new UserParam();
|
||||||
|
userParam.setPhones(phones);
|
||||||
|
userParam.setLimit(500L);
|
||||||
|
final PageResult<User> result = userService.pageRel(userParam);
|
||||||
|
final Set<Integer> collect = result.getList().stream().map(User::getUserId).collect(Collectors.toSet());
|
||||||
|
return success("添加成功",collect);
|
||||||
|
}
|
||||||
|
return fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('sys:user:update')")
|
@PreAuthorize("hasAuthority('sys:user:update')")
|
||||||
@OperationLog
|
@OperationLog
|
||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<!-- 关联查询sql -->
|
<!-- 关联查询sql -->
|
||||||
<sql id="selectSql">
|
<sql id="selectSql">
|
||||||
SELECT a.*,b.company_name,b.company_logo
|
SELECT a.*,b.company_name,b.company_logo as logo
|
||||||
FROM sys_tenant a
|
FROM sys_tenant a
|
||||||
LEFT JOIN sys_company b ON a.tenant_id = b.tenant_id
|
LEFT JOIN sys_company b ON a.tenant_id = b.tenant_id
|
||||||
<where>
|
<where>
|
||||||
|
|||||||
@@ -124,6 +124,12 @@
|
|||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.phones != null">
|
||||||
|
AND a.phones IN
|
||||||
|
<foreach collection="param.phones" item="item" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="param.province != null">
|
<if test="param.province != null">
|
||||||
AND a.province LIKE CONCAT('%', #{param.province}, '%')
|
AND a.province LIKE CONCAT('%', #{param.province}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ public class UserParam extends BaseParam {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Set<Integer> userIds;
|
private Set<Integer> userIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户手机号码集合")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Set<String> phones;
|
||||||
|
|
||||||
@ApiModelProperty("是否查询用户详细资料表")
|
@ApiModelProperty("是否查询用户详细资料表")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Boolean showProfile;
|
private Boolean showProfile;
|
||||||
|
|||||||
Reference in New Issue
Block a user