ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.vci.web.controller;
 
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.web.service.impl.FormulaServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.HtmlUtils;
 
/**
 * 公式控制器
 * @author weidy
 * @date 2022-2-11
 */
@RestController
@RequestMapping("/formulaController")
public class WebFormulaController {
 
    /**
     * 公式的服务
     */
    @Autowired
    private FormulaServiceImpl formulaService;
 
    /**
     * 解析公式
     * @param formula 公式的内容
     * @return 执行后的结果
     */
    @PostMapping("/doFormula")
    public BaseResult doFormula(String formula){
        formula = StringUtils.isBlank(formula)?"": HtmlUtils.htmlUnescape(formula);
        return BaseResult.success(formulaService.calculate(formula));
    }
}