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));
|
}
|
}
|