|
@@ -1,8 +1,12 @@
|
|
|
package com.fjs.scenic.controller.system;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjs.scenic.controller.common.BaseController;
|
|
|
import com.fjs.scenic.dto.InputInfoDto;
|
|
|
+import com.fjs.scenic.dto.InputInfoPageParam;
|
|
|
import com.fjs.scenic.entity.system.InpIncome;
|
|
|
import com.fjs.scenic.entity.system.InputInfo;
|
|
|
import com.fjs.scenic.entity.system.Manage;
|
|
@@ -23,6 +27,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
+import javax.validation.Valid;
|
|
|
import java.security.Principal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.Date;
|
|
@@ -42,6 +47,8 @@ public class InputInfoController {
|
|
|
private InputInfoService inputInfoService;
|
|
|
@Autowired
|
|
|
private InpIncomeService inpIncomeService;
|
|
|
+ @Autowired
|
|
|
+ private ManageServiceImpl manageService;
|
|
|
|
|
|
@GetMapping("/index")
|
|
|
public ModelAndView sceniclist() {
|
|
@@ -50,15 +57,18 @@ public class InputInfoController {
|
|
|
|
|
|
@PostMapping("/add")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ReturnResult add(@RequestBody List<InputInfoDto> inputInfoDtos) {
|
|
|
+ public ReturnResult add(@Valid @RequestBody List<InputInfoDto> inputInfoDtos, Principal principal) {
|
|
|
+ String account = principal.getName();
|
|
|
+ Manage manage = manageService.getMangerByAccount(account);
|
|
|
for (InputInfoDto inputInfoDto : inputInfoDtos) {
|
|
|
inputInfoDto.setCreateTime(LocalDate.now());
|
|
|
+ inputInfoDto.setManager(manage.getName());
|
|
|
int sum = inputInfoService.count(new LambdaQueryWrapper<InputInfo>()
|
|
|
.eq(InputInfo::getStaticDate, inputInfoDto.getStaticDate())
|
|
|
.eq(InputInfo::getScenic, inputInfoDto.getScenic()));
|
|
|
Assert.isTrue(sum == 0, "请勿重复添加");
|
|
|
inputInfoService.save(inputInfoDto);
|
|
|
- if (inputInfoDto.getIncome()!=null){
|
|
|
+ if (inputInfoDto.getIncome() != null) {
|
|
|
for (InpIncome inpIncome : inputInfoDto.getIncome()) {
|
|
|
inpIncome.setInputInfoId(inputInfoDto.getId());
|
|
|
inpIncomeService.save(inpIncome);
|
|
@@ -68,4 +78,18 @@ public class InputInfoController {
|
|
|
return ReturnResult.ok();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/page")
|
|
|
+ public ReturnResult page(@RequestBody InputInfoPageParam param) {
|
|
|
+ return ReturnResult.ok(inputInfoService
|
|
|
+ .page(new Page<>(param.getCurrentPage(), param.getPageSize()), new LambdaQueryWrapper<InputInfo>()
|
|
|
+ .gt(ObjectUtil.isNotEmpty(param.getStartCreateTime()), InputInfo::getCreateTime, param.getStartCreateTime())
|
|
|
+ .le(ObjectUtil.isNotEmpty(param.getEndtCreateTime()), InputInfo::getCreateTime, param.getEndtCreateTime())
|
|
|
+ .gt(ObjectUtil.isNotEmpty(param.getStartStaticDate()), InputInfo::getStaticDate, param.getStartStaticDate())
|
|
|
+ .le(ObjectUtil.isNotEmpty(param.getEndStaticDate()), InputInfo::getStaticDate, param.getEndStaticDate())
|
|
|
+ .in(ObjectUtil.isNotEmpty(param.getScenics()), InputInfo::getScenic, param.getScenics())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(param.getManager()), InputInfo::getManager, param.getManager())
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
}
|