| 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.TaskType; | 
| import com.zy.acs.manager.manager.service.TaskTypeService; | 
| 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 TaskTypeController extends BaseController { | 
|   | 
|     @Autowired | 
|     private TaskTypeService taskTypeService; | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:list')") | 
|     @PostMapping("/taskType/page") | 
|     public R page(@RequestBody Map<String, Object> map) { | 
|         BaseParam baseParam = buildParam(map, BaseParam.class); | 
|         PageParam<TaskType, BaseParam> pageParam = new PageParam<>(baseParam, TaskType.class); | 
|         return R.ok().add(taskTypeService.page(pageParam, pageParam.buildWrapper(true))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:list')") | 
|     @PostMapping("/taskType/list") | 
|     public R list(@RequestBody Map<String, Object> map) { | 
|         return R.ok().add(taskTypeService.list()); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:list')") | 
|     @PostMapping({"/taskType/many/{ids}", "/taskTypes/many/{ids}"}) | 
|     public R many(@PathVariable Long[] ids) { | 
|         return R.ok().add(taskTypeService.listByIds(Arrays.asList(ids))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:list')") | 
|     @GetMapping("/taskType/{id}") | 
|     public R get(@PathVariable("id") Long id) { | 
|         return R.ok().add(taskTypeService.getById(id)); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:save')") | 
|     @OperationLog("Create TaskType") | 
|     @PostMapping("/taskType/save") | 
|     public R save(@RequestBody TaskType taskType) { | 
|         taskType.setCreateBy(getLoginUserId()); | 
|         taskType.setCreateTime(new Date()); | 
|         taskType.setUpdateBy(getLoginUserId()); | 
|         taskType.setUpdateTime(new Date()); | 
|         if (!taskTypeService.save(taskType)) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         return R.ok("Save Success").add(taskType); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:update')") | 
|     @OperationLog("Update TaskType") | 
|     @PostMapping("/taskType/update") | 
|     public R update(@RequestBody TaskType taskType) { | 
|         taskType.setUpdateBy(getLoginUserId()); | 
|         taskType.setUpdateTime(new Date()); | 
|         if (!taskTypeService.updateById(taskType)) { | 
|             return R.error("Update Fail"); | 
|         } | 
|         return R.ok("Update Success").add(taskType); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:remove')") | 
|     @OperationLog("Delete TaskType") | 
|     @PostMapping("/taskType/remove/{ids}") | 
|     public R remove(@PathVariable Long[] ids) { | 
|         if (!taskTypeService.removeByIds(Arrays.asList(ids))) { | 
|             return R.error("Delete Fail"); | 
|         } | 
|         return R.ok("Delete Success").add(ids); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:taskType:list')") | 
|     @PostMapping("/taskType/query") | 
|     public R query(@RequestParam(required = false) String condition) { | 
|         List<KeyValVo> vos = new ArrayList<>(); | 
|         LambdaQueryWrapper<TaskType> wrapper = new LambdaQueryWrapper<>(); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(TaskType::getName, condition); | 
|         } | 
|         taskTypeService.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:taskType:list')") | 
|     @PostMapping("/taskType/export") | 
|     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|         ExcelUtil.build(ExcelUtil.create(taskTypeService.list(), TaskType.class), response); | 
|     } | 
|   | 
| } |