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