Commit 728dc489 by zhangkb

提交改变接口httpStatus代码

parent fdb461f0
package com.keymobile.indicators.api.hytobacco; package com.keymobile.indicators.api.hytobacco;
import java.io.IOException;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -13,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -13,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.keymobile.indicators.constant.Constants; import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.exception.ApiException;
import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog; import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog;
import com.keymobile.indicators.model.entity.indicators.IndCatalog; import com.keymobile.indicators.model.entity.indicators.IndCatalog;
import com.keymobile.indicators.service.hytobacco.DriveIndCatalogService; import com.keymobile.indicators.service.hytobacco.DriveIndCatalogService;
...@@ -93,14 +91,20 @@ public class IndCatalogCtrl { ...@@ -93,14 +91,20 @@ public class IndCatalogCtrl {
//考核指标目录 //考核指标目录
@ApiOperation(value = "新建考核指标目录", notes = "新建考核指标目录") @ApiOperation(value = "新建考核指标目录", notes = "新建考核指标目录")
@PostMapping(value = "/createDriveIndCatalog") @PostMapping(value = "/createDriveIndCatalog")
public Integer createDriveIndCatalog(@RequestBody DriveIndCatalog driveIndCatalog) throws Exception{ public Integer createDriveIndCatalog(@RequestBody DriveIndCatalog driveIndCatalog,
HttpServletResponse response) throws Exception{
String message = null; String message = null;
if(driveIndCatalog.getId()==null) { if(driveIndCatalog.getId()==null) {
message = "新增考核指标目录:{}"; message = "新增考核指标目录:{}";
}else { }else {
message = "修改考核指标目录:{}"; message = "修改考核指标目录:{}";
} }
try {
driveIndCatalog = driveIndCatalogService.saveOrUpdate(driveIndCatalog); driveIndCatalog = driveIndCatalogService.saveOrUpdate(driveIndCatalog);
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,message,driveIndCatalog.getCatalogName()); LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,message,driveIndCatalog.getCatalogName());
return driveIndCatalog.getId(); return driveIndCatalog.getId();
} }
......
...@@ -4,6 +4,8 @@ import java.util.ArrayList; ...@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -33,14 +35,20 @@ public class IndScorecardCtrl { ...@@ -33,14 +35,20 @@ public class IndScorecardCtrl {
@ApiOperation(value = "新增/修改评分卡目录", notes = "新增/修改评分卡目录") @ApiOperation(value = "新增/修改评分卡目录", notes = "新增/修改评分卡目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public Integer saveOrUpdateCatalog(@RequestBody ScorecardCatalog scorecardCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ScorecardCatalog scorecardCatalog,
HttpServletResponse response)throws Exception{
String message = null; String message = null;
if(scorecardCatalog.getId()==null) { if(scorecardCatalog.getId()==null) {
message = "新增指标计分规则目录:{}"; message = "新增指标计分规则目录:{}";
}else { }else {
message = "修改指标计分规则目录:{}"; message = "修改指标计分规则目录:{}";
} }
try {
scorecardCatalog = scorecardCatalogService.saveOrUpdate(scorecardCatalog); scorecardCatalog = scorecardCatalogService.saveOrUpdate(scorecardCatalog);
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
LogManager.logInfo(Constants.LOG_INDICATOR_SCORECARD_API,message,scorecardCatalog.getCatalogName()); LogManager.logInfo(Constants.LOG_INDICATOR_SCORECARD_API,message,scorecardCatalog.getCatalogName());
return scorecardCatalog.getId(); return scorecardCatalog.getId();
} }
......
...@@ -3,6 +3,8 @@ package com.keymobile.indicators.api.hytobacco; ...@@ -3,6 +3,8 @@ package com.keymobile.indicators.api.hytobacco;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -56,15 +58,23 @@ public class IndicatorsDefCtrl { ...@@ -56,15 +58,23 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "新建基础指标(isUpdate:0 新增 1修改)", notes = "新建基础指标(isUpdate:0 新增 1修改)") @ApiOperation(value = "新建基础指标(isUpdate:0 新增 1修改)", notes = "新建基础指标(isUpdate:0 新增 1修改)")
@PostMapping(value = "/createBaseInd") @PostMapping(value = "/createBaseInd")
public void createBaseInd(@RequestBody BaseIndDef baseIndDef,@RequestParam Integer catalogId, public String createBaseInd(@RequestBody BaseIndDef baseIndDef,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user, @RequestParam String catalogIdPath,@RequestParam String user,
@RequestParam String isUpdate,@RequestParam String code) throws Exception{ @RequestParam String isUpdate,@RequestParam String code,
baseIndDefService.saveOrUpdate(baseIndDef, catalogId, catalogIdPath, user, isUpdate, code); HttpServletResponse response) throws Exception{
String result = null;
try {
result = baseIndDefService.saveOrUpdate(baseIndDef, catalogId, catalogIdPath, user, isUpdate, code);
if("0".equals(isUpdate)) { if("0".equals(isUpdate)) {
LogManager.logInfo(Constants.LOG_INDICATOR_BASE_INDI_API,"新增基础项:{}",baseIndDef.getIndName()); LogManager.logInfo(Constants.LOG_INDICATOR_BASE_INDI_API,"新增基础项:{}",baseIndDef.getIndName());
}else { }else {
LogManager.logInfo(Constants.LOG_INDICATOR_BASE_INDI_API,"修改基础项:{}",baseIndDef.getIndName()); LogManager.logInfo(Constants.LOG_INDICATOR_BASE_INDI_API,"修改基础项:{}",baseIndDef.getIndName());
} }
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
return result;
} }
@ApiOperation(value = "删除基础指标", notes = "删除基础指标") @ApiOperation(value = "删除基础指标", notes = "删除基础指标")
...@@ -119,13 +129,21 @@ public class IndicatorsDefCtrl { ...@@ -119,13 +129,21 @@ public class IndicatorsDefCtrl {
@PostMapping(value = "/createDriveInd") @PostMapping(value = "/createDriveInd")
public String createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam String code,@RequestParam Integer catalogId, public String createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam String code,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user,@RequestParam String isUpdate, @RequestParam String catalogIdPath,@RequestParam String user,@RequestParam String isUpdate,
@RequestParam(required=false) String shortboardIds) throws Exception{ @RequestParam(required=false) String shortboardIds,
HttpServletResponse response) throws Exception{
String result = null;
try {
result = driveIndDefService.saveOrUpdate(driveIndDef, code, catalogId, catalogIdPath, user, isUpdate, shortboardIds);
if("0".equals(isUpdate)) { if("0".equals(isUpdate)) {
LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,"新增考核指标:{}",driveIndDef.getIndName()); LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,"新增考核指标:{}",driveIndDef.getIndName());
}else { }else {
LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,"新增考核指标:{}",driveIndDef.getIndName()); LogManager.logInfo(Constants.LOG_INDICATOR_DRIVE_INDI_API,"新增考核指标:{}",driveIndDef.getIndName());
} }
return driveIndDefService.saveOrUpdate(driveIndDef, code, catalogId, catalogIdPath, user, isUpdate, shortboardIds); } catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
return result;
} }
@ApiOperation(value = "删除考核指标", notes = "删除考核指标") @ApiOperation(value = "删除考核指标", notes = "删除考核指标")
......
...@@ -4,6 +4,8 @@ import java.util.ArrayList; ...@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -33,14 +35,20 @@ public class ObjScoreRuleCtrl { ...@@ -33,14 +35,20 @@ public class ObjScoreRuleCtrl {
@ApiOperation(value = "新增/修改单位规则目录", notes = "新增/修改单位规则目录") @ApiOperation(value = "新增/修改单位规则目录", notes = "新增/修改单位规则目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public Integer saveOrUpdateCatalog(@RequestBody ScoreRuleCatalog scoreRuleCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ScoreRuleCatalog scoreRuleCatalog,
HttpServletResponse response)throws Exception{
String message = null; String message = null;
if(scoreRuleCatalog.getId()==null) { if(scoreRuleCatalog.getId()==null) {
message = "新增单位得分规则目录:{}"; message = "新增单位得分规则目录:{}";
}else { }else {
message = "修改单位得分规则目录:{}"; message = "修改单位得分规则目录:{}";
} }
try {
scoreRuleCatalog = scoreRuleCatalogService.saveOrUpdate(scoreRuleCatalog); scoreRuleCatalog = scoreRuleCatalogService.saveOrUpdate(scoreRuleCatalog);
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
LogManager.logInfo(Constants.LOG_INDICATOR_OBJ_SCORERULE_API,message,scoreRuleCatalog.getCatalogName()); LogManager.logInfo(Constants.LOG_INDICATOR_OBJ_SCORERULE_API,message,scoreRuleCatalog.getCatalogName());
return scoreRuleCatalog.getId(); return scoreRuleCatalog.getId();
} }
......
...@@ -4,6 +4,8 @@ import java.util.ArrayList; ...@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -33,14 +35,20 @@ public class ShortboardRuleCtrl { ...@@ -33,14 +35,20 @@ public class ShortboardRuleCtrl {
@ApiOperation(value = "新增/修改短板筛选规则目录", notes = "新增/修改短板筛选规则目录") @ApiOperation(value = "新增/修改短板筛选规则目录", notes = "新增/修改短板筛选规则目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public Integer saveOrUpdateCatalog(@RequestBody ShortboardCatalog shortboardCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ShortboardCatalog shortboardCatalog,
HttpServletResponse response)throws Exception{
String message = null; String message = null;
if(shortboardCatalog.getId()==null) { if(shortboardCatalog.getId()==null) {
message = "新增短板筛选规则目录:{}"; message = "新增短板筛选规则目录:{}";
}else { }else {
message = "修改短板筛选规则目录:{}"; message = "修改短板筛选规则目录:{}";
} }
try {
shortboardCatalog = shortboardCatalogService.saveOrUpdate(shortboardCatalog); shortboardCatalog = shortboardCatalogService.saveOrUpdate(shortboardCatalog);
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_RULE_API,message,shortboardCatalog.getCatalogName()); LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_RULE_API,message,shortboardCatalog.getCatalogName());
return shortboardCatalog.getId(); return shortboardCatalog.getId();
} }
......
...@@ -4,6 +4,8 @@ import java.util.ArrayList; ...@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -37,14 +39,20 @@ public class ShortboardUnitCtrl { ...@@ -37,14 +39,20 @@ public class ShortboardUnitCtrl {
@ApiOperation(value = "新增/修改短板筛选单元目录", notes = "新增/修改短板筛选单元目录") @ApiOperation(value = "新增/修改短板筛选单元目录", notes = "新增/修改短板筛选单元目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public Integer saveOrUpdateCatalog(@RequestBody ShortboardUnitCatalog shortboardUnitCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ShortboardUnitCatalog shortboardUnitCatalog,
HttpServletResponse response)throws Exception{
String message = null; String message = null;
if(shortboardUnitCatalog.getId()==null) { if(shortboardUnitCatalog.getId()==null) {
message = "新增短板规则目录:{}"; message = "新增短板规则目录:{}";
}else { }else {
message = "修改短板规则目录:{}"; message = "修改短板规则目录:{}";
} }
try {
shortboardUnitCatalog = shortboardUnitCatalogService.saveOrUpdate(shortboardUnitCatalog); shortboardUnitCatalog = shortboardUnitCatalogService.saveOrUpdate(shortboardUnitCatalog);
} catch (Exception e) {
response.sendError(500);
throw new Exception(e.getMessage());
}
LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,message,shortboardUnitCatalog.getCatalogName()); LogManager.logInfo(Constants.LOG_INDICATOR_SHORTBOARD_UNIT_API,message,shortboardUnitCatalog.getCatalogName());
return shortboardUnitCatalog.getId(); return shortboardUnitCatalog.getId();
} }
......
package com.keymobile.indicators.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR,reason="server error")
public class ApiException extends Exception{
public ApiException(String msg) {
super(msg);
}
}
...@@ -31,16 +31,16 @@ public class BaseIndDefService { ...@@ -31,16 +31,16 @@ public class BaseIndDefService {
//判断公式合法性 //判断公式合法性
if(StringUtils.isNotBlank(baseIndDef.getIndFormat()) && if(StringUtils.isNotBlank(baseIndDef.getIndFormat()) &&
!CalculateUtils.isValidformula(baseIndDef.getIndFormat())) { !CalculateUtils.isValidformula(baseIndDef.getIndFormat())) {
return "formula is not valid"; throw new Exception("公式校验不合法");
} }
if(StringUtils.isBlank(baseIndDef.getIndId())) { if(StringUtils.isBlank(baseIndDef.getIndId())) {
return "indId can not be null"; throw new Exception("数据项编号不能为空");
} }
//如果是新增,需要判断库中是否已存在指标编号 //如果是新增,需要判断库中是否已存在指标编号
if("0".equals(isUpdate)) {//新增 if("0".equals(isUpdate)) {//新增
BaseIndDef dbBaseIndDef = this.getById(baseIndDef.getIndId()); BaseIndDef dbBaseIndDef = this.getById(baseIndDef.getIndId());
if(dbBaseIndDef!=null) { if(dbBaseIndDef!=null) {
return "indId is exist,create base indicators fail"; throw new Exception("数据项编号已存在,新增基础数据项失败");
}else { }else {
baseIndDef.setCreater(user); baseIndDef.setCreater(user);
baseIndDef.setCreateTime(new Date()); baseIndDef.setCreateTime(new Date());
...@@ -68,7 +68,7 @@ public class BaseIndDefService { ...@@ -68,7 +68,7 @@ public class BaseIndDefService {
baseIndDefMapper.updateByPrimaryKey(baseIndDef); baseIndDefMapper.updateByPrimaryKey(baseIndDef);
} }
}else { }else {
return "base ind is not exist,update ind fail"; throw new Exception("数据项已存在,修改失败");
} }
} }
//保存或修改指标关系 //保存或修改指标关系
......
...@@ -43,15 +43,15 @@ public class DriveIndDefService { ...@@ -43,15 +43,15 @@ public class DriveIndDefService {
//判断公式合法性 //判断公式合法性
if(StringUtils.isNotBlank(driveIndDef.getIndFormat()) && if(StringUtils.isNotBlank(driveIndDef.getIndFormat()) &&
!CalculateUtils.isValidformula(driveIndDef.getIndFormat())) { !CalculateUtils.isValidformula(driveIndDef.getIndFormat())) {
return "formula is not valid"; throw new Exception("校验公式不合法");
} }
if(StringUtils.isBlank(driveIndDef.getIndId())) { if(StringUtils.isBlank(driveIndDef.getIndId())) {
return "indId can not be null"; throw new Exception("指标编号不能为空");
} }
if("0".equals(isUpdate)) {//新建 if("0".equals(isUpdate)) {//新建
DriveIndDef dbDriveIndDef = this.getById(driveIndDef.getIndId()); DriveIndDef dbDriveIndDef = this.getById(driveIndDef.getIndId());
if(dbDriveIndDef!=null) { if(dbDriveIndDef!=null) {
return "indId is exist,create drive indicators fail"; throw new Exception("指标编号存在,新增指标失败");
}else { }else {
driveIndDef.setCreater(user); driveIndDef.setCreater(user);
driveIndDef.setCreateTime(new Date()); driveIndDef.setCreateTime(new Date());
...@@ -79,7 +79,7 @@ public class DriveIndDefService { ...@@ -79,7 +79,7 @@ public class DriveIndDefService {
driveIndDefMapper.updateByPrimaryKey(driveIndDef); driveIndDefMapper.updateByPrimaryKey(driveIndDef);
} }
}else { }else {
return "drive ind is not exist,update ind fail"; throw new Exception("指标不存在,修改失败");
} }
} }
//插入短板筛选规则 //插入短板筛选规则
......
...@@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory; ...@@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.exception.ApiException;
import com.keymobile.indicators.model.entity.indicators.IndCatalog; import com.keymobile.indicators.model.entity.indicators.IndCatalog;
import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.IndCatalogMapper; import com.keymobile.indicators.model.mapper.indmapper.IndCatalogMapper;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment