| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.example.jz.auth.TokenJwtManager; |
| | | import com.example.jz.dao.UserDao; |
| | | import com.example.jz.modle.R; |
| | |
| | | import com.example.jz.modle.vo.*; |
| | | import com.example.jz.service.*; |
| | | import com.example.jz.utils.HttpUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Array; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("/wx") |
| | | @Api(tags = "微信小程序接口") |
| | | public class WxAppController { |
| | | |
| | | private final String wxApp_userCode_verify_url = "https://api.weixin.qq.com/sns/jscode2session"; |
| | |
| | | GroupUserService groupUserService; |
| | | @Autowired |
| | | PublicityService publicityService; |
| | | @Autowired |
| | | private AnnouncementService announcementService; |
| | | @Autowired |
| | | private PoliceAnnouncementService policeAnnouncementService; |
| | | |
| | | @GetMapping("/checkIdentity") |
| | | public R checkIdentity(@RequestParam String code, @RequestParam String phoneNumberCode) throws Exception { |
| | |
| | | return R.ok(reportService.save(report)); |
| | | } |
| | | |
| | | @PostMapping("/user/policeAddReport") |
| | | public R policeAddReport(@RequestBody ReportVXVO reportVXVO) { |
| | | User one = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getUserMobile, reportVXVO.getPhone())); |
| | | if (Objects.nonNull(one)){ |
| | | return R.ok("该手机号已被注册"); |
| | | } |
| | | |
| | | User user = new User(); |
| | | |
| | | user.setUserMobile(reportVXVO.getPhone()); |
| | | user.setRealName(reportVXVO.getRealName()); |
| | | user.setSex(reportVXVO.getSex()); |
| | | user.setUserIdcard(reportVXVO.getUserIdCard()); |
| | | user.setLocation(reportVXVO.getLocation()); |
| | | user.setWorkingLocation(reportVXVO.getWorkingLocation()); |
| | | user.setCtime(new Date()); |
| | | userService.save(user); |
| | | |
| | | Report report = new Report(); |
| | | BeanUtils.copyProperties(reportVXVO, report); |
| | | report.setAmountInvolved(reportVXVO.getAmountInvolved()); |
| | | report.setUserId(user.getId()); |
| | | report.setPic(user.getPic()); |
| | | report.setIsInGroup(0); |
| | | report.setCtime(new Date()); |
| | | report.setStatus(0); |
| | | report.setReportMethod("扫码报案"); |
| | | return R.ok(reportService.save(report)); |
| | | } |
| | | |
| | | @PutMapping ("/user/addReport") |
| | | public R addReport1(@RequestBody ReportVXVO reportVXVO) { |
| | | User user = userService.getOne(new QueryWrapper<User>().eq("id", reportVXVO.getUserId())); |
| | | user.setRealName(reportVXVO.getRealName()); |
| | | user.setSex(reportVXVO.getSex()); |
| | | user.setUserIdcard(reportVXVO.getUserIdCard()); |
| | | user.setLocation(reportVXVO.getLocation()); |
| | | user.setWorkingLocation(reportVXVO.getWorkingLocation()); |
| | | |
| | | userService.update(user, new LambdaQueryWrapper<User>().eq(User::getId, user.getId())); |
| | | Report report = new Report(); |
| | | BeanUtils.copyProperties(reportVXVO, report); |
| | | report.setAmountInvolved(reportVXVO.getAmountInvolved()); |
| | | report.setPic(user.getPic()); |
| | | report.setIsInGroup(0); |
| | | report.setCtime(new Date()); |
| | | report.setStatus(0); |
| | | report.setReportMethod("扫码报案"); |
| | | |
| | | reportService.update(report, new LambdaQueryWrapper<Report>().eq(Report::getId, report.getId())); |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | @PostMapping("/user/add") |
| | | public R addUser(@RequestBody User user) { |
| | | user.setUserLasttime(new Date()); |
| | |
| | | HashMap<String, Object> messageMap = new HashMap<>(); |
| | | messageMap.put("text", item.getText()); |
| | | messageMap.put("time", item.getCtime()); |
| | | messageMap.put("messageId", item.getId()); |
| | | if (item.getUserId() != null) { |
| | | Report report = reportService.getOne(new QueryWrapper<Report>().eq("id", item.getUserId())); |
| | | User user = userService.getOne(new QueryWrapper<User>().eq("id", report.getUserId())); |
| | | if (Objects.isNull(user)) { |
| | | return; |
| | | } |
| | | messageMap.put("id", user.getId()); |
| | | messageMap.put("name", item.getReportName()); |
| | | messageMap.put("mobile", user.getUserMobile()); |
| | |
| | | } else { |
| | | messageMap.put("id", item.getCopId()); |
| | | User user = userService.getOne(new QueryWrapper<User>().eq("id", item.getCopId())); |
| | | if (Objects.isNull(user)) { |
| | | return; |
| | | } |
| | | messageMap.put("name", user.getRealName()); |
| | | messageMap.put("mobile", user.getUserMobile()); |
| | | messageMap.put("sex", user.getSex()); |
| | |
| | | if (StringUtils.isBlank(msg)) { |
| | | return R.failed("msg is blank"); |
| | | } |
| | | GroupUser one = groupUserService.getOne(new LambdaQueryWrapper<GroupUser>().eq(GroupUser::getUserId, id).eq(GroupUser::getGroupId, groupId)); |
| | | if (one.getBanSpeech() == 1){ |
| | | return R.failed("该用户已经被禁言"); |
| | | } |
| | | Message message = new Message(); |
| | | message.setUserId(id); |
| | | message.setText(msg); |
| | |
| | | return R.ok(reportVo); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/manager/report") |
| | | public R queryReport() { |
| | | return R.ok(reportService.list(new LambdaQueryWrapper<Report>().eq(Report::getStatus, 0)) |
| | | public R queryReport(@RequestParam Integer id) { |
| | | List<Integer> collect = causeService.list(Wrappers.<Cause>lambdaQuery().eq(Cause::getUserId, id)).stream().map(cause -> cause.getId()).collect(Collectors.toList()); |
| | | R<List<ReportVo>> ok = R.ok(reportService.list(new LambdaQueryWrapper<Report>().eq(Report::getStatus, 0).in(Report::getCauseId, collect)) |
| | | .stream() |
| | | .map(item -> { |
| | | ReportVo reportVo = new ReportVo(); |
| | | BeanUtils.copyProperties(item, reportVo); |
| | | User user = userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, item.getUserId())); |
| | | Cause one = causeService.getOne(new LambdaQueryWrapper<Cause>().eq(Cause::getId, item.getCauseId())); |
| | | reportVo.setReportDescription(one.getName()); |
| | | reportVo.setReporterName(user.getRealName()); |
| | | reportVo.setMobile(user.getUserMobile()); |
| | | reportVo.setIdcard(user.getUserIdcard()); |
| | | return reportVo; |
| | | }) |
| | | .collect(Collectors.toList())); |
| | | return ok; |
| | | } |
| | | |
| | | @GetMapping("/publicity") |
| | |
| | | } |
| | | return R.ok(publicityList); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "POST", value = "群公告添加") |
| | | @PostMapping("/announcement/add") |
| | | public R insert(@RequestParam(value = "groupId") Integer groupId, @RequestParam String announcement) { |
| | | Announcement announcement1 = new Announcement(); |
| | | announcement1.setText(announcement); |
| | | announcement1.setStatus(1); |
| | | return R.ok(announcementService.vxAdd(groupId, announcement1)); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "DELETE", value = "群公告删除") |
| | | @DeleteMapping("/announcement/delete") |
| | | public R delete(@RequestParam(value = "id") Integer id) { |
| | | announcementService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(httpMethod = "GET", value = "查看群公告") |
| | | @GetMapping("/getAnnouncements") |
| | | public R getAnnouncements(@RequestParam(value = "groupId") Integer groupId) { |
| | | return R.ok(announcementService.getAnnouncements(groupId)); |
| | | } |
| | | |
| | | @GetMapping("policeAnnouncement/list") |
| | | @ApiOperation(httpMethod = "GET", value = "警方公告") |
| | | public R getPoliceAnnouncement(){ |
| | | List<PoliceAnnouncement> list = policeAnnouncementService.list(Wrappers.<PoliceAnnouncement>lambdaQuery().eq(PoliceAnnouncement::getStatus, 1).orderByDesc(PoliceAnnouncement::getCtime)); |
| | | return R.ok(list); |
| | | } |
| | | } |