郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
package com.gk.hotwork.Service.ServiceImpl;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.hotwork.Domain.Enum.Etype;
import com.gk.hotwork.Domain.Exception.BusinessException;
import com.gk.hotwork.Domain.FourColorMap2;
import com.gk.hotwork.Domain.UserInfo;
import com.gk.hotwork.Domain.Utils.StringUtils;
import com.gk.hotwork.Mapper.FourColorMap2Mapper;
import com.gk.hotwork.Service.FourColorMap2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
@Service("fourColorMap2Service")
public class FourColorMap2ServiceImpl extends ServiceImpl<FourColorMap2Mapper, FourColorMap2> implements FourColorMap2Service {
 
    @Autowired
    FourColorMap2Mapper fourColorMap2Mapper;
 
    @Override
    public void addOne(JSONObject mapJson, UserInfo userInfo) {
        String type = mapJson.getString("type");
        String geometry = mapJson.getString("geometry");
        String properties = mapJson.getString("properties");
        Integer etype = mapJson.getInteger("etype");
        if (etype == null || StringUtils.isBlank(type) || StringUtils.isBlank(geometry) || StringUtils.isBlank(properties)) {
            throw new BusinessException("参数不能为空");
        }
        //检验
        Etype.parse(etype);
 
        FourColorMap2 fourColorMap2 = new FourColorMap2();
        fourColorMap2.setEtype(etype);
        fourColorMap2.setGeometry(geometry);
        fourColorMap2.setProperties(properties);
        fourColorMap2.setType(type);
        Date now = new Date();
        fourColorMap2.setCreateTime(now);
        fourColorMap2.setCreateBy(userInfo.getRealname());
        fourColorMap2.setUpdateTime(now);
        fourColorMap2.setValidFlag(true);
        this.save(fourColorMap2);
    }
 
    @Override
    public List<FourColorMap2> getList2(Integer eType) {
        Etype.parse(eType);
        return fourColorMap2Mapper.selectList(new LambdaQueryWrapper<FourColorMap2>().
                eq(FourColorMap2::getEtype, eType)
                .eq(FourColorMap2::getValidFlag, Boolean.TRUE));
    }
 
    @Override
    public void delOne(Long id) {
        if (id == null) throw new BusinessException("参数为空");
        FourColorMap2 byId = this.getById(id);
        if (byId == null) throw new BusinessException("数据不存在");
        FourColorMap2 delOne = new FourColorMap2();
        delOne.setValidFlag(Boolean.FALSE);
        delOne.setUpdateTime(new Date());
        delOne.setId(byId.getId());
        this.updateById(delOne);
    }
}