package com.boying.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.boying.common.R; import com.boying.entity.CostRule; import com.boying.entity.OutPark; import com.boying.entity.Park; import com.boying.entity.User; import com.boying.service.CostRuleService; import com.boying.service.ParkService; import com.boying.util.DateUtilOther; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.text.ParseException; @RestController @RequestMapping("ffzf/rule") @RequiredArgsConstructor @Tag(description = "ffzf/rule" , name = "缴费规则" ) public class CostRuleController{ private final CostRuleService costRuleService; private final ParkService parkService; @GetMapping("test") @Operation(summary = "测试" , description = "测试" ) public Object save(String start,String end) throws ParseException { double money = costRuleService.getMoney(4, DateUtilOther.stringToLocalDate(start,null), DateUtilOther.stringToLocalDate(end, null), 1); return R.ok(money); } @PostMapping("/findPage") @Operation(summary = "分页查询" , description = "分页查询" ) public Object findPage(Page page,CostRule costRule) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(costRule.getParkId() != null,CostRule::getParkId,costRule.getParkId()) .orderByDesc(CostRule::getId); Page page1 = costRuleService.page(page, wrapper); for (CostRule costRule1 : page1.getRecords()) { if(costRule1.getParkId() != null){ costRule1.setParkName(parkService.getById(costRule1.getParkId()).getName()); } } return R.ok(page1);} @PostMapping("/save") @Operation(summary = "新增规则" , description = "新增规则" ) public Object save(CostRule costRule) { costRuleService.saveOrUpdate(costRule); return R.ok("保存成功"); } @PostMapping("/delete") @Operation(summary = "删除规则" , description = "删除规则" ) public Object delete(Long id) { costRuleService.removeById(id); return R.ok("删除成功"); } }