package com.oying.modules.fee.rest; import com.oying.annotation.Log; import com.oying.modules.fee.domain.WeightSurchargeRules; import com.oying.modules.fee.service.WeightSurchargeRulesService; import com.oying.modules.fee.domain.dto.WeightSurchargeRulesQueryCriteria; import lombok.RequiredArgsConstructor; import java.util.List; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.oying.utils.PageResult; /** * @author lixin * @date 2025-10-07 **/ @RestController @RequiredArgsConstructor @Api(tags = "重量加价规则") @RequestMapping("/api/weightSurchargeRules") public class WeightSurchargeRulesController { private final WeightSurchargeRulesService weightSurchargeRulesService; @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('weightSurchargeRules:list')") public void exportWeightSurchargeRules(HttpServletResponse response, WeightSurchargeRulesQueryCriteria criteria) throws IOException { weightSurchargeRulesService.download(weightSurchargeRulesService.queryAll(criteria), response); } @GetMapping @ApiOperation("查询重量加价规则") @PreAuthorize("@el.check('weightSurchargeRules:list')") public ResponseEntity> queryWeightSurchargeRules(WeightSurchargeRulesQueryCriteria criteria){ Page page = new Page<>(criteria.getPage(), criteria.getSize()); return new ResponseEntity<>(weightSurchargeRulesService.queryAll(criteria,page),HttpStatus.OK); } @PostMapping @Log("新增重量加价规则") @ApiOperation("新增重量加价规则") @PreAuthorize("@el.check('weightSurchargeRules:add')") public ResponseEntity createWeightSurchargeRules(@Validated @RequestBody WeightSurchargeRules resources){ weightSurchargeRulesService.create(resources); return new ResponseEntity<>(HttpStatus.CREATED); } @PutMapping @Log("修改重量加价规则") @ApiOperation("修改重量加价规则") @PreAuthorize("@el.check('weightSurchargeRules:edit')") public ResponseEntity updateWeightSurchargeRules(@Validated @RequestBody WeightSurchargeRules resources){ weightSurchargeRulesService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping @Log("删除重量加价规则") @ApiOperation("删除重量加价规则") @PreAuthorize("@el.check('weightSurchargeRules:del')") public ResponseEntity deleteWeightSurchargeRules(@ApiParam(value = "传ID数组[]") @RequestBody List ids) { weightSurchargeRulesService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } }