| | |
| | | import com.product.base.config.BaseErrorCode; |
| | | import com.product.base.config.CmnConst; |
| | | import com.product.base.service.MaterialManagerService; |
| | | import com.product.core.config.CoreConst; |
| | | import com.product.core.controller.support.AbstractBaseController; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.entity.RequestParameterEntity; |
| | | import com.product.module.sys.version.ApiVersion; |
| | | import com.product.util.BaseUtil; |
| | | |
| | |
| | | @ApiVersion(1) |
| | | public String getMaterialTypeTree(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse = null; |
| | | Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if(bean != null){ |
| | | RequestParameterEntity reqp=(RequestParameterEntity)bean; |
| | | fse = reqp.getFormData(); |
| | | } |
| | | //判断上传参数是否为空 |
| | | if(bean == null || fse == null) { |
| | | return error(BaseErrorCode.SYSTEM_FORM_NODATA.getValue(), BaseErrorCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | //判断表名是否正确 |
| | | if(!CmnConst.PRODUCT_PROJECT_BASE_MATERIAL.equals(fse.getTableName())) { |
| | | return error(BaseErrorCode.SYSTEM_TABLE_NODATA.getValue(), BaseErrorCode.SYSTEM_TABLE_NODATA.getText()); |
| | | } |
| | | return OK_List(materialManagerService.getMaterialTypeTree()); |
| | | } catch (Exception e) { |
| | | return this.error(BaseErrorCode.PROJECT_BASE_MATERIAL_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_MATERIAL_OPERATE_FAIL.getText()+e.getMessage()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存材料类型 |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value="/save-material-type/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String saveMaterialType(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | //获取参数 |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_MATERIAL_TYPE); |
| | | if (BaseUtil.strIsNull(fse.getString(CmnConst.MATERIAL_TYPE_NAME))) { |
| | | return error(BaseErrorCode.SYSTEM_FORM_COUNT.getValue(), BaseErrorCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | return OK_Add(materialManagerService.saveMaterialType(fse)); |
| | | } catch (Exception e) { |
| | | return this.error(BaseErrorCode.PROJECT_BASE_MATERIAL_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_MATERIAL_OPERATE_FAIL.getText()+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取所有材料信息 |
| | | * @param request |
| | | * @param response |