| | |
| | | package com.ycl.platform.controller; |
| | | |
| | | import com.ycl.platform.domain.form.DefaultRuleSetForm; |
| | | import com.ycl.system.domain.group.Update; |
| | | import com.ycl.system.domain.group.Add; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import lombok.RequiredArgsConstructor; |
| | | import java.util.List; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import com.ycl.platform.service.DefaultRuleService; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.platform.domain.form.DefaultRuleForm; |
| | | import com.ycl.platform.domain.query.DefaultRuleQuery; |
| | | import lombok.RequiredArgsConstructor; |
| | | import annotation.Log; |
| | | import com.ycl.platform.domain.entity.CalculateRule; |
| | | import com.ycl.platform.service.IDefaultRuleService; |
| | | import com.ycl.system.AjaxResult; |
| | | import com.ycl.system.controller.BaseController; |
| | | import com.ycl.utils.poi.ExcelUtil; |
| | | import enumeration.BusinessType; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 违约规则 前端控制器 |
| | | * 违约规则Controller |
| | | * |
| | | * @author xp |
| | | * @since 2024-03-05 |
| | | * @author ruoyi |
| | | * @date 2024-04-01 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "违约规则", tags = "违约规则管理") |
| | | @RestController |
| | | @RequestMapping("/default-rule") |
| | | public class DefaultRuleController { |
| | | @RequestMapping("/default/rule") |
| | | public class DefaultRuleController extends BaseController |
| | | { |
| | | @Autowired |
| | | private IDefaultRuleService defaultRuleService; |
| | | |
| | | private final DefaultRuleService defaultRuleService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) DefaultRuleForm form) { |
| | | return defaultRuleService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) DefaultRuleForm form) { |
| | | return defaultRuleService.update(form); |
| | | } |
| | | |
| | | @PostMapping("/set") |
| | | @ApiOperation(value = "启用/停用", notes = "启用/停用") |
| | | public Result set(@RequestBody DefaultRuleSetForm form) { |
| | | return defaultRuleService.set(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return defaultRuleService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return defaultRuleService.remove(ids); |
| | | } |
| | | |
| | | @PostMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | public Result page(@RequestBody DefaultRuleQuery query) { |
| | | return defaultRuleService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | public Result detail(@PathVariable("id") String id) { |
| | | return defaultRuleService.detail(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询违约规则列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:list')") |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result list() { |
| | | return defaultRuleService.all(); |
| | | public AjaxResult list(CalculateRule calculateRule) |
| | | { |
| | | List<CalculateRule> list = defaultRuleService.selectDefaultRuleList(calculateRule); |
| | | return success(list); |
| | | } |
| | | |
| | | /** |
| | | * 导出违约规则列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:export')") |
| | | @Log(title = "违约规则", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, CalculateRule calculateRule) |
| | | { |
| | | List<CalculateRule> list = defaultRuleService.selectDefaultRuleList(calculateRule); |
| | | ExcelUtil<CalculateRule> util = new ExcelUtil<CalculateRule>(CalculateRule.class); |
| | | util.exportExcel(response, list, "违约规则数据"); |
| | | } |
| | | |
| | | /** |
| | | * 获取违约规则详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) |
| | | { |
| | | return success(defaultRuleService.selectDefaultRuleById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增违约规则 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:add')") |
| | | @Log(title = "违约规则", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody CalculateRule calculateRule) |
| | | { |
| | | return toAjax(defaultRuleService.insertDefaultRule(calculateRule)); |
| | | } |
| | | |
| | | /** |
| | | * 修改违约规则 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:edit')") |
| | | @Log(title = "违约规则", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody CalculateRule calculateRule) |
| | | { |
| | | return toAjax(defaultRuleService.updateDefaultRule(calculateRule)); |
| | | } |
| | | |
| | | /** |
| | | * 删除违约规则 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:rule:remove')") |
| | | @Log(title = "违约规则", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(defaultRuleService.deleteDefaultRuleByIds(ids)); |
| | | } |
| | | } |