|
|
@@ -1,14 +1,17 @@
|
|
|
package com.xintong.visualinspection.controller;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import com.mysql.jdbc.StringUtils;
|
|
|
import com.xintong.visualinspection.bean.Constant;
|
|
|
+import com.xintong.visualinspection.err.BusinessException;
|
|
|
import com.xintong.visualinspection.service.ConstantService;
|
|
|
|
|
|
/**
|
|
|
@@ -31,7 +34,7 @@ public class ConstantController extends BaseController {
|
|
|
* @since 1.0.0
|
|
|
*/
|
|
|
@RequestMapping(value = "/addConstant")
|
|
|
- public String addConstant(@Valid @RequestBody Constant constant, BindingResult result){
|
|
|
+ public String addConstant(@Valid @RequestBody Constant constant){
|
|
|
constantService.insert(constant);
|
|
|
return super.returnSuccessResult("添加成功");
|
|
|
}
|
|
|
@@ -57,8 +60,63 @@ public class ConstantController extends BaseController {
|
|
|
* @since 1.0.0
|
|
|
*/
|
|
|
@RequestMapping(value = "/deleteConstant")
|
|
|
- public String deleteConstant(@RequestBody String id){
|
|
|
- constantService.delete(Long.parseLong(id));
|
|
|
+ public String deleteConstant(@RequestBody Constant constant){
|
|
|
+ if(constant.getId()==null){
|
|
|
+ throw new BusinessException(20002);
|
|
|
+ }
|
|
|
+ constantService.delete(constant.getId());
|
|
|
return super.returnSuccessResult("删除成功");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过常量标识获取某一类型常量
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getConstantByFlag")
|
|
|
+ public String getConstantByFlag(@RequestBody Constant constant){
|
|
|
+ if(StringUtils.isNullOrEmpty(constant.getCodeFlag())){
|
|
|
+ throw new BusinessException(20101);
|
|
|
+ }
|
|
|
+ List<Constant> constantList = constantService.getByFlag(constant.getCodeFlag());
|
|
|
+ return super.returnSuccessResult(constantList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过常量标识和字典值获取常量
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getConstantByFlagAndValue")
|
|
|
+ public String getConstantByFlagAndValue(@RequestBody Constant constant){
|
|
|
+ if(StringUtils.isNullOrEmpty(constant.getCodeFlag())){
|
|
|
+ throw new BusinessException(20101);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNullOrEmpty(constant.getCodeValue())){
|
|
|
+ throw new BusinessException(20102);
|
|
|
+ }
|
|
|
+ Constant con = constantService.getByFlagAndValue(constant);
|
|
|
+ return super.returnSuccessResult(con);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过名称模糊查询
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getConstantByName")
|
|
|
+ public String getConstantByName(@RequestBody Constant constant){
|
|
|
+ if(StringUtils.isNullOrEmpty(constant.getFlagName())){
|
|
|
+ throw new BusinessException(20103);
|
|
|
+ }
|
|
|
+ List<Constant> constantList = constantService.getByName(constant.getFlagName());
|
|
|
+ return super.returnSuccessResult(constantList);
|
|
|
+ }
|
|
|
}
|