| | |
| | | @PostMapping(value = "/user/addOrUpdate") |
| | | @Log(title = "【用户列表】添加编辑用户", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | public R addOrUpdate(@RequestBody TAppUser tAppUser) { |
| | | partnerAppUserAccessService.assertWritable(); |
| | | if (tAppUser.getId() != null){ |
| | | AuthUtil.checkPermi("/appUser/update"); |
| | | partnerAppUserAccessService.assertUserVisible(tAppUser.getId()); |
| | | //为编辑操作,要进行vip的逻辑处理 |
| | | TAppUser nowUser = appUserService.getById(tAppUser.getId()); |
| | | //会员结束时间不为空 |
| | |
| | | } |
| | | |
| | | }else { |
| | | AuthUtil.checkPermi("/appUser/add"); |
| | | List<TAppUser> list = appUserService.lambdaQuery().eq(TAppUser::getPhone, tAppUser.getPhone()).list(); |
| | | if (!list.isEmpty()){ |
| | | return R.fail("该手机号已注册"); |
| | |
| | | @PostMapping(value = "/user/status/change") |
| | | @Log(title = "【用户列表】冻结解冻用户", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | public R pointsDetail(@RequestBody UserChangeDto userChangeDto) { |
| | | partnerAppUserAccessService.assertWritable(); |
| | | partnerAppUserAccessService.assertUserVisible(userChangeDto.getUserId()); |
| | | TAppUser appUser = appUserService.getById(userChangeDto.getUserId()); |
| | | appUser.setStatus(userChangeDto.getStatus()); |
| | | appUser.setRemark(userChangeDto.getRemark()); |
| | |
| | | @PostMapping(value = "/user/unit/change") |
| | | @Log(title = "【用户列表】修改用户单位", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | public R unitChange(@RequestBody UnitChangeDto unitChangeDto) { |
| | | partnerAppUserAccessService.assertWritable(); |
| | | for (String s : unitChangeDto.getIds().split(",")) { |
| | | TAppUser byId = appUserService.getById(s); |
| | | List<Long> userIds = parseUserIds(unitChangeDto.getIds()); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | TAppUser byId = appUserService.getById(userId); |
| | | byId.setCompanyId(unitChangeDto.getUnitId()); |
| | | appUserService.updateById(byId); |
| | | } |
| | |
| | | @DeleteMapping(value = "/user/delete") |
| | | @Log(title = "【用户列表】删除用户", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | public R userDelete(String ids) { |
| | | partnerAppUserAccessService.assertWritable(); |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | appUserService.removeById(s); |
| | | List<Long> userIds = parseUserIds(ids); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | appUserService.removeById(userId); |
| | | } |
| | | return R.ok(); |
| | | |
| | |
| | | @PostMapping(value = "/user/give/vip") |
| | | @Log(title = "【用户列表】赠送会员", businessType = BusinessType.OTHER,operatorType = OperatorType.MANAGE) |
| | | public R giveVip(@RequestBody GiveVipDto giveVipDto) { |
| | | partnerAppUserAccessService.assertWritable(); |
| | | String[] split = giveVipDto.getUserIds().split(","); |
| | | for (String s : split) { |
| | | TAppUser nowUser = appUserService.getById(s); |
| | | List<Long> userIds = parseUserIds(giveVipDto.getUserIds()); |
| | | partnerAppUserAccessService.assertUsersVisible(userIds); |
| | | for (Long userId : userIds) { |
| | | TAppUser nowUser = appUserService.getById(userId); |
| | | int plusDay = 0; |
| | | if (giveVipDto.getType() == 1) { |
| | | plusDay = 1; |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private List<Long> parseUserIds(String ids) { |
| | | if (StringUtils.isBlank(ids)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return Arrays.stream(ids.split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::isNotBlank) |
| | | .map(Long::valueOf) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | |