package com.fgkj.services;
|
|
|
import java.util.List;
|
|
import com.fgkj.dao.BaseDAO;
|
import com.fgkj.dao.BaseDAOFactory;
|
import com.fgkj.dto.Limit;
|
import com.fgkj.dto.ServiceModel;
|
|
|
public class LimitService {
|
private BaseDAO dao;
|
private ServiceModel model;
|
|
public LimitService() {
|
dao = BaseDAOFactory.getBaseDAO(BaseDAO.LIMIT);
|
model = new ServiceModel();
|
}
|
public ServiceModel addLimit(Object obj){
|
Limit l=(Limit) obj;
|
List<Limit> list=dao.serchByCondition(l);
|
Boolean bl=false;
|
if(list.isEmpty()){
|
bl=dao.add(l);
|
if(bl==true){
|
model.setCode(1);
|
model.setMsg("添加成功");
|
}
|
else{
|
model.setMsg("添加失败");
|
}
|
//System.out.println("Result:"+bl);
|
}
|
else{
|
|
//System.out.println("Result:"+bl);
|
}
|
return model;
|
}
|
|
|
public ServiceModel delLimit(Object obj){
|
Limit l=(Limit) obj;
|
if(dao.del(l)){
|
model.setCode(1);
|
model.setMsg("删除成功");
|
}else{
|
model.setMsg("删除失败");
|
}
|
return model;
|
}
|
|
public ServiceModel updateLimit(Object obj){
|
Limit l=(Limit) obj;
|
List<Limit> list=dao.serchByCondition(l);
|
if(list.isEmpty()){
|
if(dao.update(l)){
|
model.setCode(1);
|
model.setMsg("修改成功");
|
|
}else{
|
model.setMsg("修改失败");
|
}
|
}else{
|
model.setMsg("修改失败");
|
}
|
return model;
|
}
|
|
public ServiceModel findLimit(Object obj){
|
Limit l=(Limit) obj;
|
List<Limit> list=dao.serchByCondition(l);
|
if(list!=null && list.size()>0){
|
model.setData(list);
|
model.setCode(1);
|
}else{
|
model.setMsg("查询失败");
|
}
|
//for(Limit lm:list){
|
//System.out.println(lm);
|
//}
|
return model;
|
}
|
|
public ServiceModel findLimitAll(){
|
List<Limit> list=dao.searchAll();
|
if(list!=null && list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
}
|
for(Limit lm:list){
|
//System.out.println(lm);
|
}
|
return model;
|
}
|
|
public ServiceModel findByInfo(Object obj){
|
Limit l=(Limit) obj;
|
List list=dao.serchByInfo(l);
|
if(list==null || list.size()<1){
|
model.setMsg("没有匹配的角色");
|
}else{
|
model.setData(list);
|
model.setCode(1);
|
}
|
return model;
|
}
|
|
}
|