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);
|
}
|
}
|