| package com.matrix.system.hive.action; | 
|   | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.StringUtils; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.constance.SystemConstance; | 
| import com.matrix.system.hive.bean.SysVipInfo; | 
| import com.matrix.system.hive.plugin.util.BaseServices; | 
|   | 
| import java.util.List; | 
| /** | 
|  * @description 除了特殊的action一般业务action都继承这个action来实现 | 
|  * 基本增删改查功能 | 
|  * @author 姜友瑶 | 
|  * @email 935090232@qq.com | 
|  * @date 2016-06-26 | 
|  */ | 
| public abstract class BaseController { | 
|   | 
|     public <T> AjaxResult add(BaseServices<T> baseServices, T t, String name) { | 
|         int i = baseServices.add(t); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, name + "添加成功"); | 
|         } else { | 
|             return new AjaxResult(AjaxResult.STATUS_FAIL, name + "添加失败"); | 
|         } | 
|     } | 
|   | 
|     public <T> AjaxResult modify(BaseServices<T> baseServices, T t, String name) { | 
|         int i = baseServices.modify(t); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, name +"修改成功"); | 
|         } else { | 
|             return new AjaxResult(AjaxResult.STATUS_FAIL, name +"修改失败"); | 
|         } | 
|     } | 
|   | 
|     public <T> AjaxResult remove(BaseServices<T> baseServices, String keys) { | 
|         List<Long> ids = StringUtils.strToCollToLong(keys, ","); | 
|         int i = baseServices.remove(ids); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, "成功删除" + i + "条数据"); | 
|         } else { | 
|             return new AjaxResult(AjaxResult.STATUS_FAIL, "删除失败"); | 
|         } | 
|     } | 
|   | 
|     public <T> AjaxResult showList(BaseServices<T> baseServices, T t, PaginationVO pageVo) { | 
|   | 
|         List<T> dataList = baseServices.findInPage(t, pageVo); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS,  dataList, baseServices.findTotal(t)); | 
|         return result; | 
|     } | 
|   | 
|     public <T> AjaxResult findByModel(BaseServices<T> baseServices, T t) { | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS,  baseServices.findByModel(t), 0); | 
|         return result; | 
|     } | 
|   | 
|     public <T> T findById(BaseServices<T> baseServices, Long id) { | 
|         return baseServices.findById(id); | 
|     } | 
|   | 
|      | 
|     /** | 
|      * 获取登录员工登录对象 | 
|      * @author 姜友瑶 | 
|      * @date 2016/7/5 | 
|      */ | 
|     public SysUsers getMe() { | 
|         return (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); | 
|      | 
|     } | 
|   | 
|     /** | 
|      * 获取当前操作的会员对象 | 
|      * @author 姜友瑶 | 
|      * @date 2016/7/5 | 
|      */ | 
|     public SysVipInfo getCurrentVioInfo() { | 
|         return (SysVipInfo) (WebUtil.getSession().getAttribute(SystemConstance.CURRENT_CUSTOMER)); | 
|     } | 
|   | 
|   | 
| } |