package com.fgkj.services; import java.util.Iterator; import java.util.List; import com.fgkj.dao.BaseDAO; import com.fgkj.dao.BaseDAOFactory; import com.fgkj.dto.Limit; import com.fgkj.dto.RoleLimit; import com.fgkj.dto.Roles; import com.fgkj.dto.ServiceModel; import com.fgkj.dto.UserRole; public class UserRoleService { private BaseDAO dao; private ServiceModel model; public UserRoleService() { dao = BaseDAOFactory.getBaseDAO(5); model = new ServiceModel(); } public ServiceModel findAllUserRole(){ List list=dao.searchAll(); if(list!=null && list.size()>0){ model.setCode(1); model.setData(list); } return model; } public ServiceModel addUserRole(Object obj){ UserRole ur=(UserRole) obj; List list=dao.serchByCondition(ur); Boolean bl=false; //System.out.println(ur); if(list.isEmpty()){ bl=dao.add(ur); 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 del(Object obj){ boolean flag=dao.del(obj); if(flag){ model.setCode(1); model.setMsg("删除成功"); }else{ model.setMsg("删除失败"); } return model; } }