|
@@ -31,6 +31,7 @@ import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -47,8 +48,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/company/user")
|
|
|
-public class CompanyUserController extends BaseController
|
|
|
-{
|
|
|
+public class CompanyUserController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private ICompanyRoleService roleService;
|
|
@@ -73,8 +73,7 @@ public class CompanyUserController extends BaseController
|
|
|
* 获取用户列表
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(CompanyUser user)
|
|
|
- {
|
|
|
+ public TableDataInfo list(CompanyUser user) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
startPage();
|
|
@@ -83,8 +82,7 @@ public class CompanyUserController extends BaseController
|
|
|
}
|
|
|
|
|
|
@GetMapping("/qwList")
|
|
|
- public TableDataInfo qwList(CompanyUserQwParam user)
|
|
|
- {
|
|
|
+ public TableDataInfo qwList(CompanyUserQwParam user) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
startPage();
|
|
@@ -94,50 +92,48 @@ public class CompanyUserController extends BaseController
|
|
|
|
|
|
@PostMapping("/common/uploadOSS")
|
|
|
public R uploadOSS(@RequestParam("file") MultipartFile file,
|
|
|
- @RequestParam("userId") String userId) throws Exception
|
|
|
- {
|
|
|
+ @RequestParam("userId") String userId) throws Exception {
|
|
|
String url = companyUserService.uploadQrCode(file, userId);
|
|
|
- return R.ok().put("url",url);
|
|
|
+ return R.ok().put("url", url);
|
|
|
}
|
|
|
+
|
|
|
@GetMapping("/getUserList")
|
|
|
- public R getUserList()
|
|
|
- {
|
|
|
+ public R getUserList() {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- CompanyUser map=new CompanyUser();
|
|
|
+ CompanyUser map = new CompanyUser();
|
|
|
map.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
List<CompanyUser> list = companyUserService.selectCompanyUserList(map);
|
|
|
- return R.ok().put("data",list);
|
|
|
+ return R.ok().put("data", list);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getQwUserList")
|
|
|
- public R getQwUserList()
|
|
|
- {
|
|
|
+ public R getQwUserList() {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
List<CompanyUser> list = companyUserService.selectCompanyNoQwUserList(loginUser.getCompany().getCompanyId());
|
|
|
- return R.ok().put("data",list);
|
|
|
+ return R.ok().put("data", list);
|
|
|
}
|
|
|
+
|
|
|
@GetMapping("/getQwAllUserList/{id}")
|
|
|
- public R getQwAllUserList(@PathVariable("id") String corpId)
|
|
|
- {
|
|
|
+ public R getQwAllUserList(@PathVariable("id") String corpId) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
|
- List<QwUserVO> list = companyUserService.selectCompanyQwUserList(corpId,loginUser.getCompany().getCompanyId());
|
|
|
- return R.ok().put("data",list);
|
|
|
+ List<QwUserVO> list = companyUserService.selectCompanyQwUserList(corpId, loginUser.getCompany().getCompanyId());
|
|
|
+ return R.ok().put("data", list);
|
|
|
}
|
|
|
+
|
|
|
@GetMapping("/getList")
|
|
|
- public TableDataInfo getList(CompanyUser user)
|
|
|
- {
|
|
|
+ public TableDataInfo getList(CompanyUser user) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
startPage();
|
|
|
List<CompanyUser> list = companyUserService.selectCompanyUserList(user);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
+
|
|
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:export')")
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(CompanyUser user)
|
|
|
- {
|
|
|
+ public AjaxResult export(CompanyUser user) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
List<CompanyUser> list = companyUserService.selectCompanyUserList(user);
|
|
@@ -146,28 +142,25 @@ public class CompanyUserController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 根据用户编号获取详细信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:query')")
|
|
|
- @GetMapping(value = { "/", "/{userId}" })
|
|
|
- public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
|
|
- {
|
|
|
+ @GetMapping(value = {"/", "/{userId}"})
|
|
|
+ public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
- CompanyRole companyRoleMap=new CompanyRole();
|
|
|
+ CompanyRole companyRoleMap = new CompanyRole();
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
companyRoleMap.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
List<CompanyRole> roles = roleService.selectCompanyRoleList(companyRoleMap);
|
|
|
|
|
|
- ajax.put("roles", CompanyUser.isAdmin(loginUser.getUser().getUserType()) ? roles : roles.stream().filter(r -> r.getRoleKey()!="admin").collect(Collectors.toList()));
|
|
|
+ ajax.put("roles", CompanyUser.isAdmin(loginUser.getUser().getUserType()) ? roles : roles.stream().filter(r -> r.getRoleKey() != "admin").collect(Collectors.toList()));
|
|
|
|
|
|
- CompanyPost postMap=new CompanyPost();
|
|
|
+ CompanyPost postMap = new CompanyPost();
|
|
|
postMap.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
ajax.put("posts", postService.selectCompanyPostList(postMap));
|
|
|
- if (StringUtils.isNotNull(userId))
|
|
|
- {
|
|
|
- CompanyUser companyUser=companyUserService.selectCompanyUserById(userId);
|
|
|
+ if (StringUtils.isNotNull(userId)) {
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserById(userId);
|
|
|
ajax.put(AjaxResult.DATA_TAG, companyUser);
|
|
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
|
|
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
|
@@ -183,22 +176,20 @@ public class CompanyUserController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:add')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@Validated @RequestBody CompanyUser user)
|
|
|
- {
|
|
|
+ public AjaxResult add(@Validated @RequestBody CompanyUser user) {
|
|
|
if (!PatternUtils.checkPassword(user.getPassword())) {
|
|
|
return AjaxResult.error("密码格式不正确,需包含字母、数字和特殊字符,长度为 8-20 位");
|
|
|
}
|
|
|
|
|
|
//判断用户数量是否已达到上线
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- Integer count=companyUserService.selectCompanyUserCountByCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- Company company=companyService.selectCompanyById(loginUser.getCompany().getCompanyId());
|
|
|
- if(count>company.getLimitUserCount()){
|
|
|
+ Integer count = companyUserService.selectCompanyUserCountByCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ Company company = companyService.selectCompanyById(loginUser.getCompany().getCompanyId());
|
|
|
+ if (count > company.getLimitUserCount()) {
|
|
|
return AjaxResult.error("用户数量已达到上限");
|
|
|
}
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- if (UserConstants.NOT_UNIQUE.equals(String.valueOf(companyUserService.checkUserName(user.getUserName()))))
|
|
|
- {
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(String.valueOf(companyUserService.checkUserName(user.getUserName())))) {
|
|
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
|
|
}
|
|
|
user.setCreateBy(SecurityUtils.getUsername());
|
|
@@ -214,8 +205,7 @@ public class CompanyUserController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@Validated @RequestBody CompanyUser user)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@Validated @RequestBody CompanyUser user) {
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
|
return toAjax(companyUserService.updateUser(user));
|
|
|
}
|
|
@@ -228,7 +218,7 @@ public class CompanyUserController extends BaseController
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
|
|
// 生成二级域名
|
|
|
- String subDomain = "http://"+DomainUtil.generateSubDomain(config.getCourseDomainName(), 6, String.valueOf(SecurityUtils.getLoginUser().getUser().getUserId()));
|
|
|
+ String subDomain = "http://" + DomainUtil.generateSubDomain(config.getCourseDomainName(), 6, String.valueOf(SecurityUtils.getLoginUser().getUser().getUserId()));
|
|
|
|
|
|
AjaxResult result = AjaxResult.success();
|
|
|
result.put("data", subDomain);
|
|
@@ -241,8 +231,7 @@ public class CompanyUserController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:remove')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{userIds}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] userIds)
|
|
|
- {
|
|
|
+ public AjaxResult remove(@PathVariable Long[] userIds) {
|
|
|
return toAjax(companyUserService.deleteCompanyUserByIds(userIds));
|
|
|
}
|
|
|
|
|
@@ -252,8 +241,7 @@ public class CompanyUserController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/resetPwd")
|
|
|
- public AjaxResult resetPwd(@RequestBody CompanyUser user)
|
|
|
- {
|
|
|
+ public AjaxResult resetPwd(@RequestBody CompanyUser user) {
|
|
|
if (!PatternUtils.checkPassword(user.getPassword())) {
|
|
|
return AjaxResult.error("密码格式不正确,需包含字母、数字和特殊字符,长度为 8-20 位");
|
|
|
}
|
|
@@ -266,22 +254,25 @@ public class CompanyUserController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/changeStatus")
|
|
|
- public AjaxResult changeStatus(@RequestBody CompanyUser user)
|
|
|
- {
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult changeStatus(@RequestBody CompanyUser user) {
|
|
|
//管理员的状态不能修改
|
|
|
- CompanyUser companyUser=companyUserService.selectCompanyUserById(user.getUserId());
|
|
|
- if(companyUser.isAdmin()){
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserById(user.getUserId());
|
|
|
+ if (companyUser.isAdmin()) {
|
|
|
return AjaxResult.error("不能修改管理员状态");
|
|
|
}
|
|
|
- if ("1".equals(user.getStatus())){
|
|
|
- CompanyVoiceCaller caller = callerService.selectCompanyVoiceCallerByUserId(companyUser.getCompanyId(),companyUser.getUserId());
|
|
|
- if(caller != null){
|
|
|
- caller.setCompanyId(0l);
|
|
|
- caller.setCompanyUserId(0l);
|
|
|
- caller.setMobile("");
|
|
|
- caller.setStatus(1);
|
|
|
- callerService.updateCompanyVoiceCaller(caller);
|
|
|
+ if ("1".equals(user.getStatus())) {
|
|
|
+ List<CompanyVoiceCaller> callers = callerService.selectCompanyVoiceCallerByUserId(companyUser.getCompanyId(), companyUser.getUserId(), null);
|
|
|
+ if (callers != null && !callers.isEmpty()) {
|
|
|
+ callers.forEach(caller -> {
|
|
|
+ caller.setCompanyId(0L);
|
|
|
+ caller.setCompanyUserId(0L);
|
|
|
+ caller.setMobile("");
|
|
|
+ caller.setStatus(1);
|
|
|
+ callerService.updateCompanyVoiceCaller(caller);
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
|
return toAjax(companyUserService.updateCompanyUser(user));
|
|
@@ -290,12 +281,12 @@ public class CompanyUserController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 获取通讯录
|
|
|
+ *
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getAddressBookList")
|
|
|
- public TableDataInfo getAddressBookList(CompanyUser user)
|
|
|
- {
|
|
|
+ public TableDataInfo getAddressBookList(CompanyUser user) {
|
|
|
startPage();
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
@@ -315,18 +306,16 @@ public class CompanyUserController extends BaseController
|
|
|
// }
|
|
|
|
|
|
@GetMapping("/getUserListByDeptId")
|
|
|
- public R getUserListByDeptId(CompanyUser user)
|
|
|
- {
|
|
|
+ public R getUserListByDeptId(CompanyUser user) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
user.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
|
|
|
List<CompanyUser> list = companyUserService.getUserListByDeptId(user);
|
|
|
- return R.ok().put("data",list);
|
|
|
+ return R.ok().put("data", list);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getSelectUserList")
|
|
|
- public TableDataInfo getSelectUserList(CompanyUser map)
|
|
|
- {
|
|
|
+ public TableDataInfo getSelectUserList(CompanyUser map) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
map.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
startPage();
|
|
@@ -336,36 +325,33 @@ public class CompanyUserController extends BaseController
|
|
|
|
|
|
|
|
|
@GetMapping("/getSalesman")
|
|
|
- public R getSalesman()
|
|
|
- {
|
|
|
+ public R getSalesman() {
|
|
|
//查询所有业务员
|
|
|
List<OptionsVO> list = companyUserService.selectCompanyUserBySalesman();
|
|
|
- return R.ok().put("data",list);
|
|
|
+ return R.ok().put("data", list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取区域
|
|
|
*/
|
|
|
@GetMapping("/getCitysAreaList")
|
|
|
- public R getCitysAreaList(){
|
|
|
- return R.ok().put("data",companyUserService.getCitysAreaList());
|
|
|
+ public R getCitysAreaList() {
|
|
|
+ return R.ok().put("data", companyUserService.getCitysAreaList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量修改 销售的所属区域(临时的)
|
|
|
*/
|
|
|
@PostMapping("/updateCompanyUserAreaList")
|
|
|
- public R updateCompanyUserAreaList(@RequestBody CompanyUserAreaParam param)
|
|
|
- {
|
|
|
+ public R updateCompanyUserAreaList(@RequestBody CompanyUserAreaParam param) {
|
|
|
return companyUserService.updateCompanyUserAreaList(param);
|
|
|
}
|
|
|
|
|
|
@Log(title = "设置是否需要单独注册会员", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/setRegister")
|
|
|
- public AjaxResult setIsRegisterMember(@RequestParam Boolean status, @RequestBody List<Long> userIds)
|
|
|
- {
|
|
|
+ public AjaxResult setIsRegisterMember(@RequestParam Boolean status, @RequestBody List<Long> userIds) {
|
|
|
Boolean r = companyUserService.setIsRegisterMember(status, userIds);
|
|
|
- if(r){
|
|
|
+ if (r) {
|
|
|
return AjaxResult.success();
|
|
|
} else {
|
|
|
return AjaxResult.error("操作失败");
|