whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
src/main/java/com/fgkj/services/UserRoleService.java
@@ -1,64 +1,64 @@
package com.fgkj.services;
import java.util.List;
import com.fgkj.mapper.BaseDAO;
import com.fgkj.mapper.BaseDAOFactory;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.UserRole;
public class UserRoleService {
   private Impl mapper;;
   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<UserRole> 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;
   }
}
// package com.fgkj.services;
//
// import java.util.List;
//
// import com.fgkj.mapper.BaseDAO;
// import com.fgkj.mapper.BaseDAOFactory;
// import com.fgkj.dto.ServiceModel;
// import com.fgkj.dto.UserRole;
//
// public class UserRoleService {
//
//
//    private Impl mapper;;
//
//    ServiceModel model = new ServiceModel();
//
//    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<UserRole> 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;
//    }
//
// }