青羊经侦大队-数据平台
安瑾然
2022-07-18 9b3dbdc74b2a508249b1d1e489db8a2134a3a7de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.example.jz.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.jz.dao.GroupDao;
import com.example.jz.dao.GroupUserDao;
import com.example.jz.dao.ReportDao;
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.vo.ReportListVo;
import com.example.jz.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.io.Serializable;
import java.util.Date;
 
/**
 * 报案表(Report)表服务实现类
 *
 * @author makejava
 * @since 2022-07-13 11:52:58
 */
@Service("reportService")
public class ReportServiceImpl extends ServiceImpl<ReportDao, Report> implements ReportService {
 
    @Autowired
    private ReportDao reportDao;
    @Autowired
    private GroupDao groupDao;
    @Autowired
    private GroupUserDao groupUserDao;
 
    /**
     * 审核报案
     *
     * @param report
     * @return
     */
    @Override
    @Transactional
    public Boolean audit(Report report) {
        // 1. 更新报案表
        report.setStatus(1);
        reportDao.updateById(report);
        // 2. 更新群用户表
        Group group = groupDao.selectOne(new LambdaQueryWrapper<>(Group.class)
                .eq(Group::getCauseId, report.getCauseId()));
        GroupUser groupUser = new GroupUser().setGroupId(group.getId()).setUserId(report.getUserId()).setCtime(new Date()).setBanSpeech(0);
        groupUserDao.insert(groupUser);
        return true;
    }
 
    @Override
    public void leaveGroup(Integer id, Integer groupId) {
        groupUserDao.delete(new QueryWrapper<GroupUser>().eq("user_id", id).eq("group_id", groupId));
    }
 
    @Override
    public Page<ReportListVo> getPage(Page<ReportListVo> page, ReportParamDto reportParamDto) {
        Page<ReportListVo> aaa = reportDao.getPage(page, reportParamDto);
        aaa.getRecords().stream().forEach(x -> x.setIdcard(x.getIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*")));
        return aaa;
    }
 
    @Override
    public ReportListVo getReportListVoById(Serializable id) {
        return reportDao.getReportListVoById(id);
    }
 
    @Override
    public Page<ReportListVo> getPageByGroupId(Page<ReportListVo> page, ReportParamDto reportParamDto, Integer groupId) {
        Page<ReportListVo> aaa = reportDao.getPageByGroupId(page, reportParamDto,groupId);
        aaa.getRecords().stream().forEach(x -> x.setIdcard(x.getIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*")));
        return aaa;
    }
}