| | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | |
| | | @RequestMapping(value = "/cstmr/followers/table/auth") |
| | | @ManagerAuth |
| | | public R get(@RequestParam("cstmrId") Long cstmrId) { |
| | | List<CstmrFoll> cstmrFolls = cstmrFollService.selectList(new EntityWrapper<CstmrFoll>().eq("cstmr_id", cstmrId)); |
| | | public R cstmrFollowersTable(@RequestParam("cstmrId") Long cstmrId) { |
| | | List<CstmrFoll> cstmrFolls = cstmrFollService.selectList(new EntityWrapper<CstmrFoll>().eq("cstmr_id", cstmrId).orderBy("id", false)); |
| | | List<CstmrFollowerTableVo> result = new ArrayList<>(); |
| | | for (CstmrFoll cstmrFoll : cstmrFolls) { |
| | | User user = userService.selectById(cstmrFoll.getUserId()); |
| | |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/cstmr/followers/add/auth") |
| | | @ManagerAuth |
| | | @Transactional |
| | | public R cstmrFollowersAdd(@RequestParam("cstmrId") Long cstmrId, |
| | | @RequestParam("followerIds[]") Long[] followerIds) { |
| | | if (Cools.isEmpty(cstmrId, followerIds)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | for (Long userId : followerIds) { |
| | | if (cstmrFollService.selectCount(new EntityWrapper<CstmrFoll>().eq("cstmr_id", cstmrId).eq("user_id", userId)) == 0) { |
| | | CstmrFoll cstmrFoll = new CstmrFoll(); |
| | | cstmrFoll.setCstmrId(cstmrId); |
| | | cstmrFoll.setUserId(userId); |
| | | if (!cstmrFollService.insert(cstmrFoll)) { |
| | | throw new CoolException("添加失败,请联系管理员"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/cstmr/followers/remove/auth") |
| | | @ManagerAuth |
| | | public R cstmrFollowersRemove(@RequestParam("cstmrId") Long cstmrId, |
| | | @RequestParam("userId") Long userId) { |
| | | if (Cools.isEmpty(cstmrId, userId)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (!cstmrFollService.delete(new EntityWrapper<CstmrFoll>().eq("cstmr_id", cstmrId).eq("user_id", userId))) { |
| | | throw new CoolException("删除失败,请联系管理员"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | } |