From caaa6ec6ee809b1c9e56600ba1468e8f4da0103b Mon Sep 17 00:00:00 2001 From: whj <1070107765@qq.com> Date: 星期二, 19 七月 2022 15:39:15 +0800 Subject: [PATCH] commit --- src/main/java/com/example/jz/service/ReportService.java | 8 ++++++++ src/main/java/com/example/jz/controller/ReportController.java | 12 +++++------- src/main/java/com/example/jz/service/impl/ReportServiceImpl.java | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/example/jz/controller/ReportController.java b/src/main/java/com/example/jz/controller/ReportController.java index 821f17b..2734a05 100644 --- a/src/main/java/com/example/jz/controller/ReportController.java +++ b/src/main/java/com/example/jz/controller/ReportController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.example.jz.modle.R; +import com.example.jz.modle.dto.AddReportDto; import com.example.jz.modle.dto.ReportParamDto; import com.example.jz.modle.entity.Report; import com.example.jz.modle.vo.ReportListVo; @@ -63,17 +64,14 @@ /** * 鎶ユ * - * @param report 瀹炰綋瀵硅薄 + * @param AddReportDto 瀹炰綋瀵硅薄 * @return 鏂板缁撴灉 */ @PostMapping @ApiOperation(value = "鎶ユ") - public R<Boolean> insert(@RequestBody Report report) { - report.setCtime(new Date()); - report.setStatus(0); - //TODO 鍔ㄦ�佽幏鍙栧綋鍓嶇殑鐢ㄦ埛id - report.setUserId(1); - return R.ok(reportService.save(report)); + public R<Boolean> insert(@RequestBody AddReportDto addReportDto) { + + return R.ok(reportService.addReport(addReportDto)); } /** diff --git a/src/main/java/com/example/jz/service/ReportService.java b/src/main/java/com/example/jz/service/ReportService.java index 33e0b6f..c0141d7 100644 --- a/src/main/java/com/example/jz/service/ReportService.java +++ b/src/main/java/com/example/jz/service/ReportService.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.example.jz.modle.dto.AddReportDto; import com.example.jz.modle.dto.ReportParamDto; import com.example.jz.modle.entity.Report; import com.example.jz.modle.vo.ReportListVo; @@ -28,5 +29,12 @@ ReportListVo getReportListVoById(Serializable id); Page<ReportListVo> getPageByGroupId(Page<ReportListVo> page, ReportParamDto reportParamDto, Integer groupId); + + /** + * 娣诲姞妗堜欢 + * @param addReportDto + * @return + */ + Boolean addReport(AddReportDto addReportDto); } diff --git a/src/main/java/com/example/jz/service/impl/ReportServiceImpl.java b/src/main/java/com/example/jz/service/impl/ReportServiceImpl.java index 679896c..d6dd6c8 100644 --- a/src/main/java/com/example/jz/service/impl/ReportServiceImpl.java +++ b/src/main/java/com/example/jz/service/impl/ReportServiceImpl.java @@ -13,10 +13,13 @@ import com.example.jz.dao.GroupDao; import com.example.jz.dao.GroupUserDao; import com.example.jz.dao.ReportDao; +import com.example.jz.dao.UserDao; +import com.example.jz.modle.dto.AddReportDto; import com.example.jz.modle.dto.ReportParamDto; import com.example.jz.modle.entity.Group; import com.example.jz.modle.entity.GroupUser; import com.example.jz.modle.entity.Report; +import com.example.jz.modle.entity.User; import com.example.jz.modle.vo.ReportListVo; import com.example.jz.dao.*; import com.example.jz.modle.entity.*; @@ -24,6 +27,7 @@ import com.example.jz.service.MinIOService; import com.example.jz.service.ReportService; import lombok.SneakyThrows; +import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -152,5 +156,27 @@ aaa.getRecords().stream().forEach(x -> x.setIdcard(x.getIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*"))); return aaa; } + + @Override + @Transactional + public Boolean addReport(AddReportDto addReportDto) { + User user = userDao.selectOne(new LambdaQueryWrapper<User>(User.class).eq(User::getUserIdcard, addReportDto.getIdcard())); + if (user == null) { + // 濡傛灉鐢ㄦ埛涓嶅瓨鍦� 鍒欐坊鍔犵敤鎴� + user = new User().setUserIdcard(addReportDto.getIdcard()).setUserMobile(addReportDto.getMobile()).setRealName(addReportDto.getReporterName()) + .setModifyTime(new Date()).setUserRegtime(new Date()).setPic(addReportDto.getPic()); + userDao.insert(user); + } + // 娣诲姞鎶ユ淇℃伅 + Report report = new Report(); + BeanUtils.copyProperties(addReportDto, report); + report + .setUserId(user.getId()) + .setCtime(new Date()) + .setStatus(0) + .setReportMethod("鐜板満褰曞叆") + .setIsCommission("0").setReportTime(new Date()); + return reportDao.insert(report) > 0; + } } -- Gitblit v1.8.0