修改了部门、角色、职位、组人员选择方式
This commit is contained in:
parent
cc99dc920e
commit
7e5bb16657
@ -177,4 +177,37 @@ public interface IDepartmentUserBaseService {
|
||||
*/
|
||||
List<String> listSameDepartmentUserIdByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 不在组织中的用户列表
|
||||
*
|
||||
* @param excludeDepartmentId 排除的部门
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUserByExcludeDepartmentId(String excludeDepartmentId);
|
||||
|
||||
/**
|
||||
* 不在组织中的用户列表
|
||||
*
|
||||
* @param excludeDepartmentIds 排除的部门ID列表
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUserByExcludeDepartmentIds(List<String> excludeDepartmentIds);
|
||||
|
||||
/**
|
||||
* 不在组织中的用户分页列表
|
||||
*
|
||||
* @param excludeDepartmentId 排除的组织部门ID
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(String excludeDepartmentId, ListPage page);
|
||||
|
||||
/**
|
||||
* 不在组织中的用户分页列表
|
||||
*
|
||||
* @param excludeDepartmentIds 排除的组织部门ID列表
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(List<String> excludeDepartmentIds, ListPage page);
|
||||
}
|
||||
|
@ -12,33 +12,42 @@ package ink.wgink.properties.sms;
|
||||
**/
|
||||
public class SmsTencentProperties {
|
||||
|
||||
private String appId;
|
||||
private String appKey;
|
||||
private String smsSign;
|
||||
private String secretId;
|
||||
private String secretKey;
|
||||
private String sdkAppId;
|
||||
private String signName;
|
||||
private String verificationCodeTemplateId;
|
||||
|
||||
public String getAppId() {
|
||||
return appId == null ? "" : appId.trim();
|
||||
public String getSecretId() {
|
||||
return secretId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
public void setSecretId(String secretId) {
|
||||
this.secretId = secretId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey == null ? "" : appKey.trim();
|
||||
public String getSecretKey() {
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
public void setSecretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
}
|
||||
|
||||
public String getSmsSign() {
|
||||
return smsSign == null ? "" : smsSign.trim();
|
||||
public String getSdkAppId() {
|
||||
return sdkAppId;
|
||||
}
|
||||
|
||||
public void setSmsSign(String smsSign) {
|
||||
this.smsSign = smsSign;
|
||||
public void setSdkAppId(String sdkAppId) {
|
||||
this.sdkAppId = sdkAppId;
|
||||
}
|
||||
|
||||
public String getSignName() {
|
||||
return signName == null ? "" : signName.trim();
|
||||
}
|
||||
|
||||
public void setSignName(String signName) {
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
public String getVerificationCodeTemplateId() {
|
||||
@ -48,19 +57,4 @@ public class SmsTencentProperties {
|
||||
public void setVerificationCodeTemplateId(String verificationCodeTemplateId) {
|
||||
this.verificationCodeTemplateId = verificationCodeTemplateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"appId\":")
|
||||
.append("\"").append(appId).append("\"");
|
||||
sb.append(",\"appKey\":")
|
||||
.append("\"").append(appKey).append("\"");
|
||||
sb.append(",\"smsSign\":")
|
||||
.append("\"").append(smsSign).append("\"");
|
||||
sb.append(",\"verificationCodeTemplateId\":")
|
||||
.append("\"").append(verificationCodeTemplateId).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +74,15 @@ public interface IDepartmentUserRemoteService {
|
||||
@RemotePostMethod("/list-save-department-user-ids/user-ids")
|
||||
List<String> listSameDepartmentUserIdByUserIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
|
||||
@RemotePostMethod("/list-user/exclude-department-id/{departmentId}")
|
||||
List<UserDTO> listUserByExcludeDepartmentId(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemotePathParams("departmentId") String departmentId);
|
||||
|
||||
@RemotePostMethod("/list-user/exclude-department-ids")
|
||||
List<UserDTO> listUserByExcludeDepartmentIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
|
||||
@RemotePostMethod("/listpage-user/exclude-department-id/{departmentId}")
|
||||
SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemotePathParams("departmentId") String departmentId, @RemoteQueryParams("page") int page, @RemoteQueryParams("rows") int rows, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
||||
@RemotePostMethod("/listpage-user/exclude-department-ids")
|
||||
SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentIds(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO, @RemoteQueryParams("page") int page, @RemoteQueryParams("rows") int rows, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
}
|
||||
|
@ -184,4 +184,40 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
return departmentUserRemoteService.listSameDepartmentUserIdByUserIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUserByExcludeDepartmentId(String excludeDepartmentId) {
|
||||
if (StringUtils.isBlank(excludeDepartmentId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return departmentUserRemoteService.listUserByExcludeDepartmentId(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), excludeDepartmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUserByExcludeDepartmentIds(List<String> excludeDepartmentIds) {
|
||||
if (excludeDepartmentIds == null || excludeDepartmentIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(excludeDepartmentIds);
|
||||
return departmentUserRemoteService.listUserByExcludeDepartmentIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(String excludeDepartmentId, ListPage page) {
|
||||
if (StringUtils.isBlank(excludeDepartmentId)) {
|
||||
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||
}
|
||||
return departmentUserRemoteService.listPageUserByExcludeDepartmentId(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), excludeDepartmentId, page.getPage(), page.getRows(), page.getParams());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(List<String> excludeDepartmentIds, ListPage page) {
|
||||
if (excludeDepartmentIds == null || excludeDepartmentIds.isEmpty()) {
|
||||
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||
}
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(excludeDepartmentIds);
|
||||
return departmentUserRemoteService.listPageUserByExcludeDepartmentIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO, page.getPage(), page.getRows(), page.getParams());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package ink.wgink.service.department.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.vos.IdsVO;
|
||||
import ink.wgink.pojo.vos.SaveAndDeleteIdsVO;
|
||||
import ink.wgink.service.department.pojo.vos.DepartmentUserSortVO;
|
||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||
@ -36,6 +39,21 @@ public class DepartmentUserController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private IDepartmentUserService departmentUserService;
|
||||
|
||||
@ApiOperation(value = "保存组织部门用户列表", notes = "保存组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save/{departmentId}")
|
||||
public synchronized SuccessResult save(@PathVariable("departmentId") String departmentId,
|
||||
@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("用户ID列表不能为空");
|
||||
}
|
||||
departmentUserService.save(departmentId, idsVO.getIds());
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新组织部门用户列表", notes = "更新组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
@ -122,4 +140,54 @@ public class DepartmentUserController extends DefaultBaseController {
|
||||
return departmentUserService.listUserId(departmentId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/department-id/{departmentId}")
|
||||
public List<UserDTO> listUserByDepartmentId(@PathVariable("departmentId") String departmentId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("departmentId", departmentId);
|
||||
return departmentUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/exclude-department-id/{departmentId}")
|
||||
public List<UserDTO> listUserByExcludeDepartmentId(@PathVariable("departmentId") String departmentId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeDepartmentId", departmentId);
|
||||
return departmentUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/department-id/{departmentId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByDepartmentId(@PathVariable("departmentId") String departmentId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("departmentId", departmentId);
|
||||
page.setParams(requestParams);
|
||||
return departmentUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不在组织部门的用户列表", notes = "不在组织部门的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/exclude-department-id/{departmentId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(@PathVariable("departmentId") String departmentId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeDepartmentId", departmentId);
|
||||
page.setParams(requestParams);
|
||||
return departmentUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class DepartmentUserResourceController extends DefaultBaseController {
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/department-id/{departmentId}")
|
||||
public List<UserDTO> listUserByRoleId(@PathVariable("departmentId") String departmentId) {
|
||||
public List<UserDTO> listUserByDepartmentId(@PathVariable("departmentId") String departmentId) {
|
||||
return departmentUserService.listUserByDepartmentId(departmentId);
|
||||
}
|
||||
|
||||
@ -197,4 +197,29 @@ public class DepartmentUserResourceController extends DefaultBaseController {
|
||||
return departmentUserService.listSameDepartmentUserIdByUserIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组织部门用户列表", notes = "组织部门用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/exclude-department-id/{departmentId}")
|
||||
public List<UserDTO> listUserByExcludeDepartmentId(@PathVariable("departmentId") String departmentId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeDepartmentId", departmentId);
|
||||
return departmentUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不在组织部门的用户列表", notes = "不在组织部门的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/exclude-department-id/{departmentId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(@PathVariable("departmentId") String departmentId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeDepartmentId", departmentId);
|
||||
page.setParams(requestParams);
|
||||
return departmentUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,11 @@ public class DepartmentUserRouteController {
|
||||
return new ModelAndView("department/user/list");
|
||||
}
|
||||
|
||||
@GetMapping("save-exclude")
|
||||
public ModelAndView saveExclude() {
|
||||
return new ModelAndView("department/user/save-exclude");
|
||||
}
|
||||
|
||||
@GetMapping("select-user")
|
||||
public ModelAndView selectUser() {
|
||||
ModelAndView modelAndView = new ModelAndView("department/user/select-user");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.service.department.service;
|
||||
|
||||
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentSimpleDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
@ -41,6 +42,15 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
*/
|
||||
void save(String departmentId, String departmentName, List<String> departmentUserIds);
|
||||
|
||||
/**
|
||||
* 新增用户ID
|
||||
*
|
||||
* @param departmentId 部门ID
|
||||
* @param userIds 新增的用户ID列表
|
||||
*/
|
||||
void save(String departmentId, List<String> userIds);
|
||||
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
@ -130,4 +140,14 @@ public interface IDepartmentUserService extends IDepartmentUserBaseService {
|
||||
*/
|
||||
SuccessResultList<List<DepartmentUserDTO>> listPageDepartmentUser(SuccessResultList<List<UserDTO>> successResultList, List<DepartmentUserDTO> hasDepartmentUsers);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams);
|
||||
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
|
||||
}
|
||||
|
@ -82,6 +82,16 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String departmentId, List<String> userIds) {
|
||||
DepartmentPO departmentPO = departmentService.getPO(departmentId);
|
||||
if (departmentPO == null) {
|
||||
throw new SearchException("部门不存在");
|
||||
}
|
||||
save(departmentId, departmentPO.getDepartmentName(), userIds);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String departmentId, String departmentName, List<String> userIds) {
|
||||
String adjustmentDepartmentName = departmentName;
|
||||
@ -486,4 +496,44 @@ public class DepartmentUserServiceImpl extends DefaultBaseService implements IDe
|
||||
params.put("userIds", userIds);
|
||||
return departmentUserDao.listSameDepartmentUserId(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
return departmentUserDao.listUser(requestParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = listUser(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
return new SuccessResultList<>(userDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUserByExcludeDepartmentId(String excludeDepartmentId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("excludeDepartmentId", excludeDepartmentId);
|
||||
return listUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUserByExcludeDepartmentIds(List<String> excludeDepartmentIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("excludeDepartmentIds", excludeDepartmentIds);
|
||||
return listUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(String excludeDepartmentId, ListPage page) {
|
||||
page.getParams().put("excludeDepartmentId", excludeDepartmentId);
|
||||
return listPageUser(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeDepartmentId(List<String> excludeDepartmentIds, ListPage page) {
|
||||
page.getParams().put("excludeDepartmentIds", excludeDepartmentIds);
|
||||
return listPageUser(page);
|
||||
}
|
||||
}
|
||||
|
@ -198,10 +198,25 @@
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
<if test="userType != null and userType != ''">
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
user_username LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="userType != null">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
AND
|
||||
t1.user_state = #{userState}
|
||||
</if>
|
||||
<if test="excludeUserType != null and excludeUserType != ''">
|
||||
AND
|
||||
t1.user_type != #{excludeUserType}
|
||||
@ -217,6 +232,45 @@
|
||||
st1.department_id = #{departmentId}
|
||||
)
|
||||
</if>
|
||||
<if test="departmentIds != null and departmentIds.size > 0">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
WHERE
|
||||
st1.department_id IN
|
||||
<foreach collection="departmentIds" index="index" open="(" separator="," close=")">
|
||||
#{departmentIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="excludeDepartmentId != null and excludeDepartmentId != ''">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
WHERE
|
||||
st1.department_id = #{excludeDepartmentId}
|
||||
)
|
||||
</if>
|
||||
<if test="excludeDepartmentIds != null and excludeDepartmentIds.size > 0">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
WHERE
|
||||
st1.department_id IN
|
||||
<foreach collection="excludeDepartmentIds" index="index" open="(" separator="," close=")">
|
||||
#{excludeDepartmentIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 同部门用户ID列表 -->
|
||||
|
@ -97,18 +97,33 @@
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', align:'center',
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '冻结';
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case 2:
|
||||
value = '锁定';
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '正常';
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -126,6 +141,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
@ -165,28 +182,6 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// 初始化职位用户ID列表
|
||||
function initSelectUserIds() {
|
||||
var layIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/department/user/listuserid/{departmentId}', [departmentId]), {}, null, function(code, data) {
|
||||
var selectedUserIds = '';
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
if('' != selectedUserIds) {
|
||||
selectedUserIds += '_';
|
||||
}
|
||||
selectedUserIds += item;
|
||||
}
|
||||
$('#selectedUserIds').val(selectedUserIds);
|
||||
initTable();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
initSelectUserIds();
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
@ -205,50 +200,16 @@
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
url: top.restAjax.path('route/department/user/save-exclude?departmentId={departmentId}', [departmentId]),
|
||||
title: '添加部门用户',
|
||||
width: '800px',
|
||||
height: '500px',
|
||||
closeBtn: 0,
|
||||
onClose: function() {
|
||||
top.dialog.dialogData.selectedDepartmentUsers = null;
|
||||
var insertUsers = top.dialog.dialogData.saveDepartmentUsers;
|
||||
var deleteUsers = top.dialog.dialogData.deleteDepartmentUsers;
|
||||
if(insertUsers && insertUsers.length > 0 || deleteUsers && deleteUsers.length > 0) {
|
||||
var ids = [];
|
||||
for (var i = 0, item; item = insertUsers[i++];) {
|
||||
ids.push(item.userId);
|
||||
}
|
||||
top.dialog.msg(top.dataMessage.update, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/department/user/update/{departmentId}', [departmentId]), {
|
||||
saveIds: ids,
|
||||
deleteIds: deleteUsers
|
||||
}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.updated);
|
||||
initSelectUserIds();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
|
||||
icon: 16,
|
||||
time: 0,
|
||||
shade: 0.3
|
||||
});
|
||||
}, function () {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
|
@ -0,0 +1,234 @@
|
||||
<!doctype html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userType" name="userType" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="1">系统用户</option>
|
||||
<option value="2">普通用户</option>
|
||||
<option value="3">公共用户</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userState" name="userState" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="0">正常</option>
|
||||
<option value="1">锁定</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="saveBtn" class="layui-btn layui-btn-sm" style="float: right;">保存选择</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input id="selectedUserIds" type="hidden"/>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var common = layui.common;
|
||||
var departmentId = top.restAjax.params(window.location.href).departmentId;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/department/user/listpage-user/exclude-department-id/{departmentId}';
|
||||
var selectUserIdObj = {};
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, [departmentId]),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: false,
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field:'userUsername', width:140, title: '用户名', align:'center'},
|
||||
{field:'userName', width:140, title: '昵称', align:'center'},
|
||||
{field:'userPhone', width:140, title: '手机', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userPhone) {
|
||||
return '-';
|
||||
}
|
||||
return item.userPhone;
|
||||
}
|
||||
},
|
||||
{field:'userEmail', width: 160, title: '邮箱', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userEmail) {
|
||||
return '-';
|
||||
}
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(selectUserIdObj[item.userId]) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, [departmentId]),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
userType: $('#userType').val(),
|
||||
userState: $('#userState').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
$(document).on('click', '#saveBtn', function() {
|
||||
var selectUserIdArray = [];
|
||||
for(var k in selectUserIdObj) {
|
||||
selectUserIdArray.push(k);
|
||||
}
|
||||
if(selectUserIdArray.length === 0) {
|
||||
top.dialog.msg('请选择用户');
|
||||
return;
|
||||
}
|
||||
top.dialog.confirm('确定保存吗?', function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/department/user/save/{departmentId}', [departmentId]), {
|
||||
ids: selectUserIdArray
|
||||
}, null, function(code, data) {
|
||||
top.dialog.msg('提交成功');
|
||||
reloadTable(1);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg('正在提交...', {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
})
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'one') {
|
||||
if(obj.checked) {
|
||||
selectUserIdObj[obj.data.userId] = obj.data;
|
||||
|
||||
} else {
|
||||
delete selectUserIdObj[obj.data.userId];
|
||||
}
|
||||
} else {
|
||||
var datas = table.cache.dataTable;
|
||||
if(obj.checked) {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
selectUserIdObj[item.userId] = item;
|
||||
}
|
||||
} else {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
delete selectUserIdObj[item.userId];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,12 +1,15 @@
|
||||
package ink.wgink.service.group.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.group.GroupUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.vos.IdsVO;
|
||||
import ink.wgink.pojo.vos.SaveAndDeleteIdsVO;
|
||||
import ink.wgink.service.group.service.IGroupUserService;
|
||||
import io.swagger.annotations.*;
|
||||
@ -35,6 +38,21 @@ public class GroupUserController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private IGroupUserService groupUserService;
|
||||
|
||||
@ApiOperation(value = "保存组用户列表", notes = "保存组用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save/{groupId}")
|
||||
public synchronized SuccessResult save(@PathVariable("groupId") String groupId,
|
||||
@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("用户ID列表不能为空");
|
||||
}
|
||||
groupUserService.save(groupId, idsVO.getIds());
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新组用户列表", notes = "更新组用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
@ -85,4 +103,54 @@ public class GroupUserController extends DefaultBaseController {
|
||||
return groupUserService.listUserId(groupId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组用户列表", notes = "组用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/group-id/{groupId}")
|
||||
public List<UserDTO> listUserByGroupId(@PathVariable("groupId") String groupId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("groupId", groupId);
|
||||
return groupUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组用户列表", notes = "组用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/exclude-group-id/{groupId}")
|
||||
public List<UserDTO> listUserByExcludeGroupId(@PathVariable("groupId") String groupId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeGroupId", groupId);
|
||||
return groupUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "组用户列表", notes = "组用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/group-id/{groupId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByGroupId(@PathVariable("groupId") String groupId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("groupId", groupId);
|
||||
page.setParams(requestParams);
|
||||
return groupUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不在组的用户列表", notes = "不在组的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "groupId", value = "组ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/exclude-group-id/{groupId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeGroupId(@PathVariable("groupId") String groupId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeGroupId", groupId);
|
||||
page.setParams(requestParams);
|
||||
return groupUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ public class GroupUserRouteController {
|
||||
return new ModelAndView("group/user/list");
|
||||
}
|
||||
|
||||
@GetMapping("save-exclude")
|
||||
public ModelAndView saveExclude() {
|
||||
return new ModelAndView("group/user/save-exclude");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -64,4 +65,13 @@ public interface IGroupUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<String> listGroupId(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams) throws SearchException;
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package ink.wgink.service.group.service;
|
||||
|
||||
import ink.wgink.interfaces.group.IGroupUserBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -16,6 +20,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface IGroupUserService extends IGroupUserBaseService {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param groupId
|
||||
* @param saveUserIds
|
||||
*/
|
||||
void save(String groupId, List<String> saveUserIds);
|
||||
|
||||
/**
|
||||
* 更新用户组人员列表
|
||||
*
|
||||
@ -32,4 +44,20 @@ public interface IGroupUserService extends IGroupUserBaseService {
|
||||
* @param userIds 用户ID列表
|
||||
*/
|
||||
void delete(String groupId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams);
|
||||
|
||||
/**
|
||||
* 用户分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package ink.wgink.service.group.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
@ -41,6 +43,32 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
@Autowired
|
||||
private IGroupService groupService;
|
||||
|
||||
@Override
|
||||
public void save(String groupId, List<String> saveUserIds) {
|
||||
// 判断是否已经添加
|
||||
List<String> existUserIds = listUserIdByGroupIdAndUserIds(groupId, saveUserIds);
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
for (int i = 0; i < saveUserIds.size(); i++) {
|
||||
String saveUserId = saveUserIds.get(i);
|
||||
boolean isExist = false;
|
||||
for (String existUserId : existUserIds) {
|
||||
if (StringUtils.equals(saveUserId, existUserId)) {
|
||||
isExist = true;
|
||||
existUserIds.remove(existUserId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
params.put("groupId", groupId);
|
||||
params.put("userId", saveUserId);
|
||||
groupUserDao.save(params);
|
||||
} else {
|
||||
saveUserIds.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String groupId, List<String> saveUserIds, List<String> deleteUserIds) {
|
||||
if (deleteUserIds != null && !deleteUserIds.isEmpty()) {
|
||||
@ -64,6 +92,20 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
groupUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
return groupUserDao.listUser(requestParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = listUser(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
return new SuccessResultList<>(userDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listUserId(String groupId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
@ -154,4 +196,18 @@ public class GroupUserServiceImpl extends DefaultBaseService implements IGroupUs
|
||||
return userBaseService.listPageByIds(userIds, page);
|
||||
}
|
||||
|
||||
private List<String> listUserIdByGroupIdAndUserIds(String groupId, List<String> userIds) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("groupId", groupId);
|
||||
params.put("userIds", userIds);
|
||||
return groupUserDao.listUserId(params);
|
||||
}
|
||||
|
||||
private List<String> listUserIdByPositionIdsAndUserIds(List<String> groupIds, List<String> userIds) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("groupIds", groupIds);
|
||||
params.put("userIds", userIds);
|
||||
return groupUserDao.listUserId(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,5 +100,95 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<select id="listUser" parameterType="map" resultMap="ink.wgink.service.user.dao.IUserDao.userDTO" useCache="false">
|
||||
SELECT
|
||||
user_id,
|
||||
user_username,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_type,
|
||||
user_state
|
||||
FROM
|
||||
sys_user t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
user_username LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="userType != null">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
AND
|
||||
t1.user_state = #{userState}
|
||||
</if>
|
||||
<if test="excludeUserType != null and excludeUserType != ''">
|
||||
AND
|
||||
t1.user_type != #{excludeUserType}
|
||||
</if>
|
||||
<if test="groupId != null and groupId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_group_user st1
|
||||
WHERE
|
||||
st1.group_id = #{groupId}
|
||||
)
|
||||
</if>
|
||||
<if test="groupIds != null and groupIds.size > 0">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_group_user st1
|
||||
WHERE
|
||||
st1.group_id IN
|
||||
<foreach collection="groupIds" index="index" open="(" separator="," close=")">
|
||||
#{groupIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="excludeGroupId != null and excludeGroupId != ''">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_group_user st1
|
||||
WHERE
|
||||
st1.group_id = #{excludeGroupId}
|
||||
)
|
||||
</if>
|
||||
<if test="excludeGroupIds != null and excludeGroupIds.size > 0">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_group_user st1
|
||||
WHERE
|
||||
st1.group_id IN
|
||||
<foreach collection="excludeGroupIds" index="index" open="(" separator="," close=")">
|
||||
#{excludeGroupIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -96,18 +96,33 @@
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', align:'center',
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '冻结';
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case 2:
|
||||
value = '锁定';
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '正常';
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -125,6 +140,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
@ -164,28 +181,6 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// 初始化用户组用户ID列表
|
||||
function initSelectUserIds() {
|
||||
var layIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/group/user/listuserid/{groupId}', [groupId]), {}, null, function(code, data) {
|
||||
var selectedUserIds = '';
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
if(selectedUserIds.length > 0) {
|
||||
selectedUserIds += '_';
|
||||
}
|
||||
selectedUserIds += item;
|
||||
}
|
||||
$('#selectedUserIds').val(selectedUserIds);
|
||||
initTable();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
initSelectUserIds();
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
@ -204,50 +199,16 @@
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
url: top.restAjax.path('route/group/user/save-exclude?groupId={groupId}', [groupId]),
|
||||
title: '添加组用户',
|
||||
width: '800px',
|
||||
height: '500px',
|
||||
closeBtn: 0,
|
||||
onClose: function() {
|
||||
top.dialog.dialogData.selectedDepartmentUsers = null;
|
||||
var insertUsers = top.dialog.dialogData.saveDepartmentUsers;
|
||||
var deleteUsers = top.dialog.dialogData.deleteDepartmentUsers;
|
||||
if(insertUsers && insertUsers.length > 0 || deleteUsers && deleteUsers.length > 0) {
|
||||
var ids = [];
|
||||
for (var i = 0, item; item = insertUsers[i++];) {
|
||||
ids.push(item.userId);
|
||||
}
|
||||
top.dialog.msg(top.dataMessage.update, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/group/user/update/{groupId}', [groupId]), {
|
||||
saveIds: ids,
|
||||
deleteIds: deleteUsers
|
||||
}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.updated);
|
||||
initSelectUserIds();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
|
||||
icon: 16,
|
||||
time: 0,
|
||||
shade: 0.3
|
||||
});
|
||||
}, function () {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
|
@ -0,0 +1,234 @@
|
||||
<!doctype html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userType" name="userType" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="1">系统用户</option>
|
||||
<option value="2">普通用户</option>
|
||||
<option value="3">公共用户</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userState" name="userState" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="0">正常</option>
|
||||
<option value="1">锁定</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="saveBtn" class="layui-btn layui-btn-sm" style="float: right;">保存选择</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input id="selectedUserIds" type="hidden"/>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var common = layui.common;
|
||||
var groupId = top.restAjax.params(window.location.href).groupId;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/group/user/listpage-user/exclude-group-id/{groupId}';
|
||||
var selectUserIdObj = {};
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, [groupId]),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: false,
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field:'userUsername', width:140, title: '用户名', align:'center'},
|
||||
{field:'userName', width:140, title: '昵称', align:'center'},
|
||||
{field:'userPhone', width:140, title: '手机', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userPhone) {
|
||||
return '-';
|
||||
}
|
||||
return item.userPhone;
|
||||
}
|
||||
},
|
||||
{field:'userEmail', width: 160, title: '邮箱', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userEmail) {
|
||||
return '-';
|
||||
}
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(selectUserIdObj[item.userId]) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, [groupId]),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
userType: $('#userType').val(),
|
||||
userState: $('#userState').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
$(document).on('click', '#saveBtn', function() {
|
||||
var selectUserIdArray = [];
|
||||
for(var k in selectUserIdObj) {
|
||||
selectUserIdArray.push(k);
|
||||
}
|
||||
if(selectUserIdArray.length === 0) {
|
||||
top.dialog.msg('请选择用户');
|
||||
return;
|
||||
}
|
||||
top.dialog.confirm('确定保存吗?', function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/group/user/save/{groupId}', [groupId]), {
|
||||
ids: selectUserIdArray
|
||||
}, null, function(code, data) {
|
||||
top.dialog.msg('提交成功');
|
||||
reloadTable(1);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg('正在提交...', {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
})
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'one') {
|
||||
if(obj.checked) {
|
||||
selectUserIdObj[obj.data.userId] = obj.data;
|
||||
|
||||
} else {
|
||||
delete selectUserIdObj[obj.data.userId];
|
||||
}
|
||||
} else {
|
||||
var datas = table.cache.dataTable;
|
||||
if(obj.checked) {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
selectUserIdObj[item.userId] = item;
|
||||
}
|
||||
} else {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
delete selectUserIdObj[item.userId];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,12 +1,15 @@
|
||||
package ink.wgink.service.position.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.position.PositionUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.vos.IdsVO;
|
||||
import ink.wgink.pojo.vos.SaveAndDeleteIdsVO;
|
||||
import ink.wgink.service.position.service.IPositionUserService;
|
||||
import io.swagger.annotations.*;
|
||||
@ -35,9 +38,24 @@ public class PositionUserController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private IPositionUserService positionUserService;
|
||||
|
||||
@ApiOperation(value = "保存职位用户列表", notes = "保存职位用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save/{positionId}")
|
||||
public synchronized SuccessResult save(@PathVariable("positionId") String positionId,
|
||||
@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("用户ID列表不能为空");
|
||||
}
|
||||
positionUserService.save(positionId, idsVO.getIds());
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新职位人员列表", notes = "更新职位人员列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
@ApiImplicitParam(name = "departmentId", value = "职位ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{positionId}")
|
||||
@ -49,7 +67,7 @@ public class PositionUserController extends DefaultBaseController {
|
||||
|
||||
@ApiOperation(value = "职位人员删除", notes = "职位人员删除接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "ids", value = "人员ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@ -85,4 +103,54 @@ public class PositionUserController extends DefaultBaseController {
|
||||
return positionUserService.listUserId(positionId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "职位用户列表", notes = "职位用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/position-id/{positionId}")
|
||||
public List<UserDTO> listUserByPositionId(@PathVariable("positionId") String positionId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("positionId", positionId);
|
||||
return positionUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "职位用户列表", notes = "职位用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/exclude-position-id/{positionId}")
|
||||
public List<UserDTO> listUserByExcludePositionId(@PathVariable("positionId") String positionId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludePositionId", positionId);
|
||||
return positionUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "职位用户列表", notes = "职位用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/position-id/{positionId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByPositionId(@PathVariable("positionId") String positionId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("positionId", positionId);
|
||||
page.setParams(requestParams);
|
||||
return positionUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不在职位的用户列表", notes = "不在职位的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "positionId", value = "职位ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/exclude-position-id/{positionId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludePositionId(@PathVariable("positionId") String positionId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludePositionId", positionId);
|
||||
page.setParams(requestParams);
|
||||
return positionUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ public class PositionUserRouteController {
|
||||
return new ModelAndView("position/user/list");
|
||||
}
|
||||
|
||||
@GetMapping("save-exclude")
|
||||
public ModelAndView saveExclude() {
|
||||
return new ModelAndView("position/user/save-exclude");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -64,4 +65,13 @@ public interface IPositionUserDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<String> listPositionId(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams) throws SearchException;
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package ink.wgink.service.position.service;
|
||||
|
||||
import ink.wgink.interfaces.position.IPositionUserBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -16,6 +20,14 @@ import java.util.List;
|
||||
**/
|
||||
public interface IPositionUserService extends IPositionUserBaseService {
|
||||
|
||||
/**
|
||||
* 保存职位人员
|
||||
*
|
||||
* @param positionId
|
||||
* @param ids
|
||||
*/
|
||||
void save(String positionId, List<String> ids);
|
||||
|
||||
/**
|
||||
* 更新职位人员列表
|
||||
*
|
||||
@ -33,4 +45,19 @@ public interface IPositionUserService extends IPositionUserBaseService {
|
||||
*/
|
||||
void delete(String positionId, List<String> userIds);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams);
|
||||
|
||||
/**
|
||||
* 用户分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package ink.wgink.service.position.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
@ -41,6 +43,32 @@ public class PositionUserServiceImpl extends DefaultBaseService implements IPosi
|
||||
@Autowired
|
||||
private IPositionService positionService;
|
||||
|
||||
@Override
|
||||
public void save(String positionId, List<String> saveUserIds) {
|
||||
// 判断是否已经添加
|
||||
List<String> existUserIds = listUserIdByPositionIdAndUserIds(positionId, saveUserIds);
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
for (int i = 0; i < saveUserIds.size(); i++) {
|
||||
String saveUserId = saveUserIds.get(i);
|
||||
boolean isExist = false;
|
||||
for (String existUserId : existUserIds) {
|
||||
if (StringUtils.equals(saveUserId, existUserId)) {
|
||||
isExist = true;
|
||||
existUserIds.remove(existUserId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
params.put("positionId", positionId);
|
||||
params.put("userId", saveUserId);
|
||||
positionUserDao.save(params);
|
||||
} else {
|
||||
saveUserIds.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String positionId, List<String> saveUserIds, List<String> deleteUserIds) {
|
||||
if (deleteUserIds != null && !deleteUserIds.isEmpty()) {
|
||||
@ -64,6 +92,20 @@ public class PositionUserServiceImpl extends DefaultBaseService implements IPosi
|
||||
positionUserDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
return positionUserDao.listUser(requestParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = listUser(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
return new SuccessResultList<>(userDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listUserId(String positionId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
|
@ -109,4 +109,95 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<select id="listUser" parameterType="map" resultMap="ink.wgink.service.user.dao.IUserDao.userDTO" useCache="false">
|
||||
SELECT
|
||||
user_id,
|
||||
user_username,
|
||||
user_name,
|
||||
user_phone,
|
||||
user_email,
|
||||
user_type,
|
||||
user_state
|
||||
FROM
|
||||
sys_user t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
user_username LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="userType != null">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
AND
|
||||
t1.user_state = #{userState}
|
||||
</if>
|
||||
<if test="excludeUserType != null and excludeUserType != ''">
|
||||
AND
|
||||
t1.user_type != #{excludeUserType}
|
||||
</if>
|
||||
<if test="positionId != null and positionId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_position_user st1
|
||||
WHERE
|
||||
st1.position_id = #{positionId}
|
||||
)
|
||||
</if>
|
||||
<if test="positionIds != null and positionIds.size > 0">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_position_user st1
|
||||
WHERE
|
||||
st1.position_id IN
|
||||
<foreach collection="positionIds" index="index" open="(" separator="," close=")">
|
||||
#{positionIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="excludePositionId != null and excludePositionId != ''">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_position_user st1
|
||||
WHERE
|
||||
st1.position_id = #{excludePositionId}
|
||||
)
|
||||
</if>
|
||||
<if test="excludePositionIds != null and excludePositionIds.size > 0">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_position_user st1
|
||||
WHERE
|
||||
st1.position_id IN
|
||||
<foreach collection="excludePositionIds" index="index" open="(" separator="," close=")">
|
||||
#{excludePositionIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -96,18 +96,33 @@
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', align:'center',
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '冻结';
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case 2:
|
||||
value = '锁定';
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '正常';
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -125,6 +140,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
@ -164,28 +181,6 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// 初始化职位用户ID列表
|
||||
function initSelectUserIds() {
|
||||
var layIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/position/user/listuserid/{positionId}', [positionId]), {}, null, function(code, data) {
|
||||
var selectedUserIds = '';
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
if(selectedUserIds.length > 0) {
|
||||
selectedUserIds += '_';
|
||||
}
|
||||
selectedUserIds += item;
|
||||
}
|
||||
$('#selectedUserIds').val(selectedUserIds);
|
||||
initTable();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
initSelectUserIds();
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
@ -204,52 +199,16 @@
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
url: top.restAjax.path('route/position/user/save-exclude?positionId={positionId}', [positionId]),
|
||||
title: '添加职位用户',
|
||||
width: '800px',
|
||||
height: '500px',
|
||||
closeBtn: 0,
|
||||
onClose: function() {
|
||||
top.dialog.dialogData.selectedDepartmentUsers = null;
|
||||
var insertUsers = top.dialog.dialogData.saveDepartmentUsers;
|
||||
var deleteUsers = top.dialog.dialogData.deleteDepartmentUsers;
|
||||
|
||||
if(insertUsers && insertUsers.length > 0 || deleteUsers && deleteUsers.length > 0) {
|
||||
var ids = [];
|
||||
for (var i = 0, item; item = insertUsers[i++];) {
|
||||
ids.push(item.userId);
|
||||
}
|
||||
top.dialog.msg(top.dataMessage.update, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/position/user/update/{positionId}', [positionId]), {
|
||||
saveIds: ids,
|
||||
deleteIds: deleteUsers
|
||||
}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.updated);
|
||||
$('#selectedUserIds').val(ids.toString().replaceAll(',', '\_'));
|
||||
initSelectUserIds();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
|
||||
icon: 16,
|
||||
time: 0,
|
||||
shade: 0.3
|
||||
});
|
||||
}, function () {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
|
@ -0,0 +1,234 @@
|
||||
<!doctype html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userType" name="userType" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="1">系统用户</option>
|
||||
<option value="2">普通用户</option>
|
||||
<option value="3">公共用户</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userState" name="userState" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="0">正常</option>
|
||||
<option value="1">锁定</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="saveBtn" class="layui-btn layui-btn-sm" style="float: right;">保存选择</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input id="selectedUserIds" type="hidden"/>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var common = layui.common;
|
||||
var positionId = top.restAjax.params(window.location.href).positionId;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/position/user/listpage-user/exclude-position-id/{positionId}';
|
||||
var selectUserIdObj = {};
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, [positionId]),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: false,
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field:'userUsername', width:140, title: '用户名', align:'center'},
|
||||
{field:'userName', width:140, title: '昵称', align:'center'},
|
||||
{field:'userPhone', width:140, title: '手机', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userPhone) {
|
||||
return '-';
|
||||
}
|
||||
return item.userPhone;
|
||||
}
|
||||
},
|
||||
{field:'userEmail', width: 160, title: '邮箱', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userEmail) {
|
||||
return '-';
|
||||
}
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(selectUserIdObj[item.userId]) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, [positionId]),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
userType: $('#userType').val(),
|
||||
userState: $('#userState').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
$(document).on('click', '#saveBtn', function() {
|
||||
var selectUserIdArray = [];
|
||||
for(var k in selectUserIdObj) {
|
||||
selectUserIdArray.push(k);
|
||||
}
|
||||
if(selectUserIdArray.length === 0) {
|
||||
top.dialog.msg('请选择用户');
|
||||
return;
|
||||
}
|
||||
top.dialog.confirm('确定保存吗?', function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/position/user/save/{positionId}', [positionId]), {
|
||||
ids: selectUserIdArray
|
||||
}, null, function(code, data) {
|
||||
top.dialog.msg('提交成功');
|
||||
reloadTable(1);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg('正在提交...', {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
})
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'one') {
|
||||
if(obj.checked) {
|
||||
selectUserIdObj[obj.data.userId] = obj.data;
|
||||
|
||||
} else {
|
||||
delete selectUserIdObj[obj.data.userId];
|
||||
}
|
||||
} else {
|
||||
var datas = table.cache.dataTable;
|
||||
if(obj.checked) {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
selectUserIdObj[item.userId] = item;
|
||||
}
|
||||
} else {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
delete selectUserIdObj[item.userId];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.service.role.controller.api;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.role.RoleUserDTO;
|
||||
@ -8,6 +9,7 @@ import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.vos.IdsVO;
|
||||
import ink.wgink.pojo.vos.SaveAndDeleteIdsVO;
|
||||
import ink.wgink.service.role.service.IRoleUserService;
|
||||
import io.swagger.annotations.*;
|
||||
@ -36,9 +38,24 @@ public class RoleUserController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private IRoleUserService roleUserService;
|
||||
|
||||
@ApiOperation(value = "保存角色用户列表", notes = "保存角色用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save/{roleId}")
|
||||
public synchronized SuccessResult save(@PathVariable("roleId") String roleId,
|
||||
@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("用户ID列表不能为空");
|
||||
}
|
||||
roleUserService.save(roleId, idsVO.getIds());
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新角色用户列表", notes = "更新角色用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{roleId}")
|
||||
@ -50,7 +67,7 @@ public class RoleUserController extends DefaultBaseController {
|
||||
|
||||
@ApiOperation(value = "删除角色用户", notes = "删除角色用户接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "部门ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "ids", value = "人员ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@ -86,25 +103,54 @@ public class RoleUserController extends DefaultBaseController {
|
||||
return roleUserService.listUserId(roleId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户列表", notes = "通过角色ID获取用户列表接口")
|
||||
@ApiOperation(value = "角色用户列表", notes = "角色用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "用户角色ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/role-id/{roleId}")
|
||||
public List<UserDTO> listUserByRoleId(@PathVariable("roleId") String roleId) {
|
||||
return roleUserService.listUserByRoleId(roleId);
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("roleId", roleId);
|
||||
return roleUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户分页列表", notes = "通过角色ID获取用户分页列表接口")
|
||||
@ApiOperation(value = "角色用户列表", notes = "角色用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "用户角色ID", paramType = "path"),
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-user/exclude-role-id/{roleId}")
|
||||
public List<UserDTO> listUserByExcludeRoleId(@PathVariable("roleId") String roleId) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeRoleId", roleId);
|
||||
return roleUserService.listUser(requestParams);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色用户列表", notes = "角色用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/role-id/{roleId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByRoleId(@PathVariable("roleId") String roleId, ListPage page) {
|
||||
return roleUserService.listPageUserByRoleId(roleId, page);
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("roleId", roleId);
|
||||
page.setParams(requestParams);
|
||||
return roleUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "不在角色的用户列表", notes = "不在角色的用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-user/exclude-role-id/{roleId}")
|
||||
public SuccessResultList<List<UserDTO>> listPageUserByExcludeRoleId(@PathVariable("roleId") String roleId, ListPage page) {
|
||||
Map<String, Object> requestParams = requestParams();
|
||||
requestParams.put("excludeRoleId", roleId);
|
||||
page.setParams(requestParams);
|
||||
return roleUserService.listPageUser(page);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ public class RoleUserRouteController {
|
||||
return new ModelAndView("role/user/list");
|
||||
}
|
||||
|
||||
@GetMapping("save-exclude")
|
||||
public ModelAndView saveExclude() {
|
||||
return new ModelAndView("role/user/save-exclude");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package ink.wgink.service.role.service;
|
||||
|
||||
import ink.wgink.interfaces.role.IRoleUserBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -58,4 +61,20 @@ public interface IRoleUserService extends IRoleUserBaseService {
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentUserDTO> listDepartmentUser(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @param requestParams
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUser(Map<String, Object> requestParams);
|
||||
|
||||
/**
|
||||
* 用户分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<UserDTO>> listPageUser(ListPage page);
|
||||
}
|
||||
|
@ -119,6 +119,20 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
return roleUserDao.listDepartmentUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUser(Map<String, Object> requestParams) {
|
||||
requestParams = requestParams == null ? getHashMap(0) : requestParams;
|
||||
return roleUserDao.listUser(requestParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<UserDTO>> listPageUser(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<UserDTO> userDTOs = listUser(page.getParams());
|
||||
PageInfo<UserDTO> pageInfo = new PageInfo<>(userDTOs);
|
||||
return new SuccessResultList<>(userDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listUserId(String roleId) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
|
@ -4,6 +4,12 @@
|
||||
|
||||
<cache flushInterval="3600000"/>
|
||||
|
||||
<resultMap id="roleUserDTO" type="ink.wgink.pojo.dtos.role.RoleUserDTO" extends="ink.wgink.service.user.dao.IUserDao.userDTO">
|
||||
<result column="role_id" property="roleId"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="user_sort" property="userSort"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 建表 -->
|
||||
<update id="createTable">
|
||||
CREATE TABLE IF NOT EXISTS `sys_role_user` (
|
||||
@ -124,6 +130,113 @@
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
<if test="userType != null">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
</if>
|
||||
<if test="userState != null">
|
||||
AND
|
||||
t1.user_state = #{userState}
|
||||
</if>
|
||||
<if test="excludeUserType != null and excludeUserType != ''">
|
||||
AND
|
||||
t1.user_type != #{excludeUserType}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
user_username LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
st1.user_id
|
||||
FROM
|
||||
sys_role_user st1
|
||||
WHERE
|
||||
role_id = #{roleId}
|
||||
)
|
||||
</if>
|
||||
<if test="roleIds != null and roleIds.size > 0">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_role_user st1
|
||||
WHERE
|
||||
st1.role_id IN
|
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")">
|
||||
#{roleIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="noRole != null and noRole == true">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
st3.user_id
|
||||
FROM
|
||||
sys_role_user st3
|
||||
)
|
||||
</if>
|
||||
<if test="excludeRoleId != null and excludeRoleId != ''">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_role_user st1
|
||||
WHERE
|
||||
st1.role_id = #{excludeRoleId}
|
||||
)
|
||||
</if>
|
||||
<if test="excludeRoleIds != null and excludeRoleIds.size > 0">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
sys_role_user st1
|
||||
WHERE
|
||||
st1.role_id IN
|
||||
<foreach collection="excludeRoleIds" index="index" open="(" separator="," close=")">
|
||||
#{excludeRoleIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 部门用户列表 -->
|
||||
<select id="listRoleUser" parameterType="map" resultMap="roleUserDTO" useCache="false">
|
||||
SELECT
|
||||
t1.user_id,
|
||||
t1.user_username,
|
||||
t1.user_name,
|
||||
t1.user_phone,
|
||||
t1.user_email,
|
||||
t1.user_type,
|
||||
t1.user_state,
|
||||
jt1.role_id,
|
||||
jt1.user_sort
|
||||
FROM
|
||||
sys_user t1
|
||||
LEFT JOIN
|
||||
sys_role_user jt1
|
||||
ON
|
||||
t1.user_id = jt1.user_id
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
|
||||
<if test="userType != null and userType != ''">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
@ -141,17 +254,17 @@
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
<if test="roleId != null and roleId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
st1.user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
sys_role_user st1
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
role_id = #{roleId}
|
||||
)
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
@ -165,16 +278,16 @@
|
||||
role_id = #{roleId}
|
||||
)
|
||||
</if>
|
||||
<if test="noDepartment != null and noDepartment = true">
|
||||
<if test="noRole != null and noRole">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
st3.user_id
|
||||
FROM
|
||||
sys_department_user st3
|
||||
sys_role_user st3
|
||||
)
|
||||
</if>
|
||||
<if test="noRole != null and noRole = true">
|
||||
<if test="noRole != null and noRole">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
@ -207,7 +320,6 @@
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.user_username != 'admin'
|
||||
|
||||
<if test="userType != null and userType != ''">
|
||||
AND
|
||||
t1.user_type = #{userType}
|
||||
@ -225,49 +337,48 @@
|
||||
user_phone LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
user_email LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
st1.user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
SELECT
|
||||
st1.user_id
|
||||
FROM
|
||||
sys_department_user st1
|
||||
WHERE
|
||||
department_id = #{departmentId}
|
||||
)
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
AND
|
||||
t1.user_id IN (
|
||||
SELECT
|
||||
st2.user_id
|
||||
FROM
|
||||
sys_role_user st2
|
||||
WHERE
|
||||
role_id = #{roleId}
|
||||
SELECT
|
||||
st2.user_id
|
||||
FROM
|
||||
sys_role_user st2
|
||||
WHERE
|
||||
role_id = #{roleId}
|
||||
)
|
||||
</if>
|
||||
<if test="noDepartment != null and noDepartment">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
st3.user_id
|
||||
FROM
|
||||
sys_department_user st3
|
||||
SELECT
|
||||
st3.user_id
|
||||
FROM
|
||||
sys_department_user st3
|
||||
)
|
||||
</if>
|
||||
<if test="noRole != null and noRole">
|
||||
AND
|
||||
t1.user_id NOT IN (
|
||||
SELECT
|
||||
st4.user_id
|
||||
FROM
|
||||
sys_role_user st4
|
||||
SELECT
|
||||
st4.user_id
|
||||
FROM
|
||||
sys_role_user st4
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -96,30 +96,37 @@
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', align:'center',
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '冻结';
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case 2:
|
||||
value = '锁定';
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '正常';
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
// {field:'roleName', width:200, title: '角色', align:'center',
|
||||
// templet: function(item) {
|
||||
// if(!item.roleName) {
|
||||
// return '-';
|
||||
// }
|
||||
// return item.roleName;
|
||||
// }
|
||||
// },
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
@ -133,6 +140,8 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
@ -172,28 +181,6 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
// 初始化角色用户ID列表
|
||||
function initSelectUserIds() {
|
||||
var layIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/role/user/listuserid/{roleId}', [roleId]), {}, null, function(code, data) {
|
||||
var selectedUserIds = '';
|
||||
for(var i = 0, item; item = data[i++]; ) {
|
||||
if('' != selectedUserIds) {
|
||||
selectedUserIds += '_';
|
||||
}
|
||||
selectedUserIds += item;
|
||||
}
|
||||
$('#selectedUserIds').val(selectedUserIds);
|
||||
initTable();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
initSelectUserIds();
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
@ -212,51 +199,16 @@
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
url: top.restAjax.path('route/role/user/save-exclude?roleId={roleId}', [roleId]),
|
||||
title: '添加角色用户',
|
||||
width: '800px',
|
||||
height: '500px',
|
||||
closeBtn: 0,
|
||||
onClose: function() {
|
||||
top.dialog.dialogData.selectedDepartmentUsers = null;
|
||||
var insertUsers = top.dialog.dialogData.saveDepartmentUsers;
|
||||
var deleteUsers = top.dialog.dialogData.deleteDepartmentUsers;
|
||||
|
||||
if(insertUsers && insertUsers.length > 0 || deleteUsers && deleteUsers.length > 0) {
|
||||
var ids = [];
|
||||
for (var i = 0, item; item = insertUsers[i++];) {
|
||||
ids.push(item.userId);
|
||||
}
|
||||
top.dialog.msg(top.dataMessage.update, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/role/user/update/{roleId}', [roleId]), {
|
||||
saveIds: ids,
|
||||
deleteIds: deleteUsers
|
||||
}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.updated);
|
||||
initSelectUserIds();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
|
||||
icon: 16,
|
||||
time: 0,
|
||||
shade: 0.3
|
||||
});
|
||||
}, function () {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
|
@ -0,0 +1,234 @@
|
||||
<!doctype html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userType" name="userType" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="1">系统用户</option>
|
||||
<option value="2">普通用户</option>
|
||||
<option value="3">公共用户</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="userState" name="userState" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="0">正常</option>
|
||||
<option value="1">锁定</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="saveBtn" class="layui-btn layui-btn-sm" style="float: right;">保存选择</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input id="selectedUserIds" type="hidden"/>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var common = layui.common;
|
||||
var roleId = top.restAjax.params(window.location.href).roleId;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/role/user/listpage-user/exclude-role-id/{roleId}';
|
||||
var selectUserIdObj = {};
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, [roleId]),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: false,
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field:'userUsername', width:140, title: '用户名', align:'center'},
|
||||
{field:'userName', width:140, title: '昵称', align:'center'},
|
||||
{field:'userPhone', width:140, title: '手机', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userPhone) {
|
||||
return '-';
|
||||
}
|
||||
return item.userPhone;
|
||||
}
|
||||
},
|
||||
{field:'userEmail', width: 160, title: '邮箱', align:'center',
|
||||
templet: function(item) {
|
||||
if(!item.userEmail) {
|
||||
return '-';
|
||||
}
|
||||
return item.userEmail;
|
||||
}
|
||||
},
|
||||
{field:'userType', width:90, title: '类型', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
if(item.userType == 1) {
|
||||
return '<span class="layui-badge layui-bg-green">系统用户</span>';
|
||||
} else if(item.userType == 2) {
|
||||
return '<span class="layui-badge layui-bg-orange">普通用户</span>';
|
||||
} else if(item.userType == 3) {
|
||||
return '<span class="layui-badge layui-bg-gray">公共用户</span>';
|
||||
}
|
||||
return '<span class="layui-badge">类型错误</span>';
|
||||
}
|
||||
},
|
||||
{field:'userState', width:80, title: '状态', sort: true, align:'center',
|
||||
templet: function(item) {
|
||||
var value;
|
||||
switch (item.userState) {
|
||||
case 1:
|
||||
value = '<span class="layui-badge layui-bg-blue">锁定</span>';
|
||||
break;
|
||||
case -1:
|
||||
value = '<span class="layui-badge layui-bg-gray">未审核</span>';
|
||||
break;
|
||||
case -2:
|
||||
value = '<span class="layui-badge">审核不通过</span>';
|
||||
break;
|
||||
default:
|
||||
value = '<span class="layui-badge layui-bg-green">正常</span>';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(selectUserIdObj[item.userId]) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, [roleId]),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
userType: $('#userType').val(),
|
||||
userState: $('#userState').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
$(document).on('click', '#saveBtn', function() {
|
||||
var selectUserIdArray = [];
|
||||
for(var k in selectUserIdObj) {
|
||||
selectUserIdArray.push(k);
|
||||
}
|
||||
if(selectUserIdArray.length === 0) {
|
||||
top.dialog.msg('请选择用户');
|
||||
return;
|
||||
}
|
||||
top.dialog.confirm('确定保存吗?', function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/role/user/save/{roleId}', [roleId]), {
|
||||
ids: selectUserIdArray
|
||||
}, null, function(code, data) {
|
||||
top.dialog.msg('提交成功');
|
||||
reloadTable(1);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg('正在提交...', {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
})
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'one') {
|
||||
if(obj.checked) {
|
||||
selectUserIdObj[obj.data.userId] = obj.data;
|
||||
|
||||
} else {
|
||||
delete selectUserIdObj[obj.data.userId];
|
||||
}
|
||||
} else {
|
||||
var datas = table.cache.dataTable;
|
||||
if(obj.checked) {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
selectUserIdObj[item.userId] = item;
|
||||
}
|
||||
} else {
|
||||
for(var i = 0, item; item = datas[i++];) {
|
||||
delete selectUserIdObj[item.userId];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user