package com.gkhy.safePlatform.specialWork.controller; import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.specialWork.model.dto.req.ApprovalRuleItemMeasureAddReqDTO; import com.gkhy.safePlatform.specialWork.model.dto.req.DeleteForm; import com.gkhy.safePlatform.specialWork.model.dto.req.SpecialWorkAppointmentAddReqDTO; import com.gkhy.safePlatform.specialWork.model.dto.req.SpecialWorkAppointmentModReqDTO; import com.gkhy.safePlatform.specialWork.model.dto.resp.SpecialWorkAppointmentRespDTO; import com.gkhy.safePlatform.specialWork.model.dto.resp.WorkStatisticsRespDTO; import com.gkhy.safePlatform.specialWork.model.query.SpecialWorkAppointmentQuery; import com.gkhy.safePlatform.specialWork.service.SpecialWorkAppointmentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * (SpecialWorkAppointment)表控制层 * * @author makejava * @since 2022-09-09 10:33:45 */ @RestController @RequestMapping("/specialWork/appointment") public class SpecialWorkAppointmentController { @Autowired private SpecialWorkAppointmentService specialWorkAppointmentService; @RequestMapping(value = "/save",method = RequestMethod.POST) public ResultVO save(Authentication authentication, @Validated @RequestBody SpecialWorkAppointmentAddReqDTO addReqDTO){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.save(currentUser, addReqDTO); } @RequestMapping(value = "/update",method = RequestMethod.POST) public ResultVO save(Authentication authentication, @Validated @RequestBody SpecialWorkAppointmentModReqDTO modReqDTO){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.update(currentUser, modReqDTO); } @RequestMapping(value = "/delete",method = RequestMethod.POST) public ResultVO save(Authentication authentication, @Validated @RequestBody JSONObject jsonObject){ Long id = jsonObject.getLong("id"); ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.deleteOne(currentUser, id); } @RequestMapping(value = "/batchDelete",method = RequestMethod.POST) public ResultVO batchDelete(Authentication authentication, @Validated @RequestBody DeleteForm deleteForm){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.batchDelete(currentUser, deleteForm); } @RequestMapping(value = "/queryById",method = RequestMethod.POST) public ResultVO queryById(Authentication authentication, @Validated @RequestBody JSONObject jsonObject){ Long id = jsonObject.getLong("id"); ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.queryById(currentUser, id); } @RequestMapping(value = "/listAll",method = RequestMethod.POST) public SearchResultVO> listAll(Authentication authentication, @RequestBody PageQuery pageQuery){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.listAll(currentUser, pageQuery); } @RequestMapping(value = "/listByDep",method = RequestMethod.POST) public SearchResultVO> listByDep(Authentication authentication, @RequestBody PageQuery pageQuery){ ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.listByDep(currentUser, pageQuery); } @RequestMapping(value = "/statistics",method = RequestMethod.POST) public ResultVO> statisticsAppointment(Authentication authentication, @RequestBody SpecialWorkAppointmentQuery query){ ContextCacheUser contextCacheUser = (ContextCacheUser) authentication.getPrincipal(); return specialWorkAppointmentService.statisticsAppointment(query); } }