whycrzg
2021-02-02 76f04402a726c1da002de99c5078b8272fa47a45
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
83
84
85
86
87
88
89
90
package com.fgkj.services;
 
import com.fgkj.dto.Chart_Color;
import com.fgkj.dto.ServiceModel;
import com.fgkj.mapper.impl.Chart_ColorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
import javax.annotation.Resource;
@Service
public class Chart_ColorService {
 
    ServiceModel model = new ServiceModel();
 
    @Resource
    private Chart_ColorMapper mapper;;
    
    //修改用户的颜色组
    public ServiceModel update(Chart_Color obj) {
        ServiceModel model = new ServiceModel();
        List list = mapper.serchByCondition(obj);
        if (list != null && list.size() > 0) {
            boolean bl = true;
            try {
                bl = mapper.update(obj) > 0;
            } catch (Exception e) {
                e.printStackTrace();
                model.setCode(0);
                model.setMsg("修改失败");
                return model;
            }
            if (bl) {
                model.setCode(1);
                model.setMsg("修改成功");
            } else {
                model.setCode(0);
                model.setMsg("修改失败");
            }
        } else {
            boolean bl = true;
            try {
                bl = mapper.add(obj) > 0;
            } catch (Exception e) {
                e.printStackTrace();
                model.setCode(0);
                model.setMsg("修改失败");
                return model;
            }
            if (bl) {
                model.setCode(1);
                model.setMsg("添加成功");
            } else {
                model.setCode(0);
                model.setMsg("添加失败");
            }
 
        }
        return model;
    }
    //查询用户对应得颜色组
    public ServiceModel serchByCondition(Chart_Color obj) {
        ServiceModel model = new ServiceModel();
        List list=mapper.serchByCondition(obj);
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
 
    public static void main(String[] args) {
        Chart_ColorService cservice=new Chart_ColorService();
        Chart_Color cc=new Chart_Color();
        cc.setuId(1002);
        cc.setMax_color("green");
        cc.setMin_color("#BFA0D1");
        cc.setNormal_color("#BFA0D1");
        cc.setChange_color("#BFA0D1");
        cc.setWarn_color("#BFA0D1");
        //ServiceModel model=cservice.serchByCondition(cc);
        ServiceModel model=cservice.update(cc);
        System.out.println(model);
    }
}