| package com.matrix.system.hive.action; | 
|   | 
| import java.util.List; | 
|   | 
| import javax.annotation.Resource; | 
| import javax.servlet.http.HttpServletRequest; | 
|   | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.system.constance.Dictionary; | 
| import com.matrix.system.hive.action.util.QueryUtil; | 
| import com.matrix.system.common.bean.SystemDictionary; | 
| import com.matrix.system.common.service.SystemDictionaryService; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
|   | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
|   | 
| /** | 
|  *  | 
|  * @description 单位管理 | 
|  * @author chen | 
|  * @date 2016年12月18日 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/unit") | 
| public class UnitController extends BaseController { | 
|   | 
|   | 
|   | 
|     // 数据字典 | 
|     @Resource | 
|     private SystemDictionaryService currentService; | 
|   | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(HttpServletRequest request, SystemDictionary dictionary, | 
|                         PaginationVO pageVo) { | 
|   | 
|         QueryUtil.setQueryLimit(dictionary); | 
|         //设置类型为计量单位 | 
|         dictionary.setType(Dictionary.DICTIONARY_UNIT); | 
|         return showList(currentService, dictionary, pageVo); | 
|     } | 
|   | 
|     @RequestMapping(value = "/addOrModify") | 
|     @RemoveRequestToken | 
|     public @ResponseBody AjaxResult addOrModify(SystemDictionary dictionary) { | 
|         if (dictionary.getId() != null) { | 
|   | 
|             return modify(currentService, dictionary, "计量单位"); | 
|         } else { | 
|   | 
|             QueryUtil.setQueryLimit(dictionary); | 
|             dictionary.setType(Dictionary.DICTIONARY_UNIT); | 
|             return add(currentService, dictionary, "计量单位"); | 
|         } | 
|     } | 
|   | 
|     @RequestMapping(value = "/del") | 
|     public @ResponseBody AjaxResult del(String keys) { | 
|   | 
|         return remove(currentService, keys); | 
|     } | 
|   | 
|     @RequestMapping(value = "/editForm") | 
|     @SaveRequestToken | 
|     public String editForm(Long id, HttpServletRequest request) { | 
|         SystemDictionary dictionary; | 
|         if (id != null) { | 
|             dictionary = currentService.findById(id); | 
|             request.setAttribute("obj", dictionary); | 
|         } | 
|         return "admin/hive/store/unit-form"; | 
|     } | 
|     @RequestMapping(value = "/getUnitName") | 
|     public @ResponseBody AjaxResult getDictionaryType() { | 
|         SystemDictionary data = new SystemDictionary(); | 
|         QueryUtil.setQueryLimit(data); | 
|         data.setType(Dictionary.DICTIONARY_UNIT); | 
|         List<SystemDictionary> dics = currentService.findByModel(data); | 
|         return new AjaxResult(AjaxResult.STATUS_SUCCESS, dics, 0); | 
|     } | 
| } |