zxl
6 小时以前 3b0516a2959e25576e4f3fda697a3b025d06c8c9
ycl-server/src/main/java/com/ycl/platform/controller/CalculateRuleController.java
@@ -1,7 +1,7 @@
package com.ycl.platform.controller;
import annotation.Log;
import com.ycl.platform.domain.entity.CalculateMoneyRule;
import com.ycl.platform.domain.entity.CalculateRule;
import com.ycl.platform.service.ICalculateRuleService;
import com.ycl.system.AjaxResult;
import com.ycl.system.controller.BaseController;
@@ -15,82 +15,102 @@
import java.util.List;
/**
 * 核算规则Controller
 * 核算规则(分)Controller
 *
 * @author ruoyi
 * @date 2024-04-03
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/calculate/rule")
public class CalculateRuleController extends BaseController
{
    @Autowired
    private ICalculateRuleService calculateRuleService;
    private ICalculateRuleService defaultRuleService;
    /**
     * 查询核算规则列表
     * 查询违约规则列表
     */
   @PreAuthorize("@ss.hasPermi('calculate:rule:list')")
    @PreAuthorize("@ss.hasPermi('system:rule:list')")
    @GetMapping("/list")
    public AjaxResult list(CalculateMoneyRule calculateMoneyRule)
    public AjaxResult list(CalculateRule calculateRule)
    {
        List<CalculateMoneyRule> list = calculateRuleService.selectCalculateRuleList(calculateMoneyRule);
        List<CalculateRule> list = defaultRuleService.selectDefaultRuleList(calculateRule);
        return success(list);
    }
    /**
     * 导出核算规则列表
     * 根据合同id查询违约规则列表
     */
    @PreAuthorize("@ss.hasPermi('calculate:rule:export')")
    @Log(title = "核算规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CalculateMoneyRule calculateMoneyRule)
    @PreAuthorize("@ss.hasPermi('system:rule:query')")
    @GetMapping("/getRuleListByContractId")
    public AjaxResult getRuleListByContractId(Integer contractId)
    {
        List<CalculateMoneyRule> list = calculateRuleService.selectCalculateRuleList(calculateMoneyRule);
        ExcelUtil<CalculateMoneyRule> util = new ExcelUtil<CalculateMoneyRule>(CalculateMoneyRule.class);
        util.exportExcel(response, list, "核算规则数据");
        return success(defaultRuleService.getRuleListByContractId(contractId));
    }
    /**
     * 获取核算规则详细信息
     * 根据运维单位查询违约规则列表
     */
   @PreAuthorize("@ss.hasPermi('calculate:rule:query')")
    @PreAuthorize("@ss.hasPermi('system:rule:query')")
    @GetMapping("/getRuleListByUnitId")
    public AjaxResult getRuleListByUnitId(Integer unitId)
    {
        return success(defaultRuleService.getRuleListByUnitId(unitId));
    }
    /**
     * 导出违约规则列表
     */
    @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(calculateRuleService.selectCalculateRuleById(id));
        return success(defaultRuleService.selectDefaultRuleById(id));
    }
    /**
     * 新增核算规则
     * 新增违约规则
     */
    @PreAuthorize("@ss.hasPermi('calculate:rule:add')")
    @Log(title = "核算规则", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('system:rule:add')")
    @Log(title = "违约规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CalculateMoneyRule calculateMoneyRule)
    public AjaxResult add(@RequestBody CalculateRule calculateRule)
    {
        return toAjax(calculateRuleService.insertCalculateRule(calculateMoneyRule));
        return toAjax(defaultRuleService.insertDefaultRule(calculateRule));
    }
    /**
     * 修改核算规则
     * 修改违约规则
     */
    @PreAuthorize("@ss.hasPermi('calculate:rule:edit')")
    @Log(title = "核算规则", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('system:rule:edit')")
    @Log(title = "违约规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CalculateMoneyRule calculateMoneyRule)
    public AjaxResult edit(@RequestBody CalculateRule calculateRule)
    {
        return toAjax(calculateRuleService.updateCalculateRule(calculateMoneyRule));
        return toAjax(defaultRuleService.updateDefaultRule(calculateRule));
    }
    /**
     * 删除核算规则
     * 删除违约规则
     */
    @PreAuthorize("@ss.hasPermi('calculate:rule:remove')")
    @Log(title = "核算规则", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('system:rule:remove')")
    @Log(title = "违约规则", businessType = BusinessType.DELETE)
   @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(calculateRuleService.deleteCalculateRuleByIds(ids));
        return toAjax(defaultRuleService.deleteDefaultRuleByIds(ids));
    }
}