hhhyyq
2021-03-17 45e45ff70ba7cd7889f76cbf489d6bf012a4f84d
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
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.community.ComMngCarAppletDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngCarVO;
import com.panzhihua.service_community.dao.ComMngCarDAO;
import com.panzhihua.service_community.model.dos.ComMngCarDO;
import com.panzhihua.service_community.service.ComMngCarService;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @description:
 * @author: Null
 * @date: 2021/3/16 14:33
 */
@Service
public class ComMngCarServiceImpl extends ServiceImpl<ComMngCarDAO, ComMngCarDO> implements ComMngCarService {
 
    @Resource
    private ComMngCarDAO comMngCarDAO;
 
    @Override
    public R addComMngCarApplet(ComMngCarAppletDTO comCvtBusinessDTO) {
        int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getPlateNum, comCvtBusinessDTO.getPlateNum()));
        if (count > 0) {
            return R.ok("车辆已存在");
        }
        ComMngCarDO comMngCarDO = new ComMngCarDO();
        BeanUtils.copyProperties(comCvtBusinessDTO, comMngCarDO);
        comMngCarDO.setCreateAt(new Date());
        boolean insert = this.save(comMngCarDO);
        if (insert) {
            return R.ok();
        }
        return R.fail();
    }
 
    @Override
    public R userComMngCarList(Long userId) {
        List<ComMngCarVO> comMngCarVOS = new ArrayList<>();
        List<ComMngCarDO> carDOS = comMngCarDAO.selectList(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getUserId,userId));
        carDOS.forEach(carDO->{
            ComMngCarVO carVO = new ComMngCarVO();
            BeanUtils.copyProperties(carDO,carVO);
            comMngCarVOS.add(carVO);
        });
        return R.ok(comMngCarVOS);
    }
}