| package com.zy.acs.manager.manager.controller; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.zy.acs.framework.common.Cools; | 
| import com.zy.acs.framework.common.R; | 
| import com.zy.acs.manager.common.utils.ExcelUtil; | 
| import com.zy.acs.manager.common.annotation.OperationLog; | 
| import com.zy.acs.manager.common.domain.BaseParam; | 
| import com.zy.acs.manager.common.domain.KeyValVo; | 
| import com.zy.acs.manager.common.domain.PageParam; | 
| import com.zy.acs.manager.manager.entity.ActionType; | 
| import com.zy.acs.manager.manager.service.ActionTypeService; | 
| import com.zy.acs.manager.system.controller.BaseController; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.security.access.prepost.PreAuthorize; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.util.*; | 
|   | 
| @RestController | 
| @RequestMapping("/api") | 
| public class ActionTypeController extends BaseController { | 
|   | 
|     @Autowired | 
|     private ActionTypeService actionTypeService; | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @PostMapping("/actionType/page") | 
|     public R page(@RequestBody Map<String, Object> map) { | 
|         BaseParam baseParam = buildParam(map, BaseParam.class); | 
|         PageParam<ActionType, BaseParam> pageParam = new PageParam<>(baseParam, ActionType.class); | 
|         return R.ok().add(actionTypeService.page(pageParam, pageParam.buildWrapper(true))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @PostMapping("/actionType/list") | 
|     public R list(@RequestBody Map<String, Object> map) { | 
|         return R.ok().add(actionTypeService.list()); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @PostMapping({"/actionType/many/{ids}", "/actionTypes/many/{ids}"}) | 
|     public R many(@PathVariable Long[] ids) { | 
|         return R.ok().add(actionTypeService.listByIds(Arrays.asList(ids))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @GetMapping("/actionType/{id}") | 
|     public R get(@PathVariable("id") Long id) { | 
|         return R.ok().add(actionTypeService.getById(id)); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:save')") | 
|     @OperationLog("Create ActionType") | 
|     @PostMapping("/actionType/save") | 
|     public R save(@RequestBody ActionType actionType) { | 
|         actionType.setCreateBy(getLoginUserId()); | 
|         actionType.setCreateTime(new Date()); | 
|         actionType.setUpdateBy(getLoginUserId()); | 
|         actionType.setUpdateTime(new Date()); | 
|         if (!actionTypeService.save(actionType)) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         return R.ok("Save Success").add(actionType); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:update')") | 
|     @OperationLog("Update ActionType") | 
|     @PostMapping("/actionType/update") | 
|     public R update(@RequestBody ActionType actionType) { | 
|         actionType.setUpdateBy(getLoginUserId()); | 
|         actionType.setUpdateTime(new Date()); | 
|         if (!actionTypeService.updateById(actionType)) { | 
|             return R.error("Update Fail"); | 
|         } | 
|         return R.ok("Update Success").add(actionType); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:remove')") | 
|     @OperationLog("Delete ActionType") | 
|     @PostMapping("/actionType/remove/{ids}") | 
|     public R remove(@PathVariable Long[] ids) { | 
|         if (!actionTypeService.removeByIds(Arrays.asList(ids))) { | 
|             return R.error("Delete Fail"); | 
|         } | 
|         return R.ok("Delete Success").add(ids); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @PostMapping("/actionType/query") | 
|     public R query(@RequestParam(required = false) String condition) { | 
|         List<KeyValVo> vos = new ArrayList<>(); | 
|         LambdaQueryWrapper<ActionType> wrapper = new LambdaQueryWrapper<>(); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(ActionType::getName, condition); | 
|         } | 
|         actionTypeService.page(new Page<>(1, 30), wrapper).getRecords().forEach( | 
|                 item -> vos.add(new KeyValVo(item.getId(), item.getName())) | 
|         ); | 
|         return R.ok().add(vos); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:actionType:list')") | 
|     @PostMapping("/actionType/export") | 
|     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|         ExcelUtil.build(ExcelUtil.create(actionTypeService.list(), ActionType.class), response); | 
|     } | 
|   | 
| } |