package com.product.base.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.product.base.config.BaseErrorCode; import com.product.base.config.CmnConst; import com.product.base.service.WarehouseManagerService; 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; /** * 仓库信息Controller * @author 86151 * */ @RequestMapping("/api/warehouseManager") @RestController public class WarehouseManagerController extends AbstractBaseController{ @Autowired WarehouseManagerService warehouseManagerService; /** * 获取所有仓库信息 * @param request * @param response * @return */ @RequestMapping(value="/list/{version}", method = RequestMethod.POST) @ApiVersion(1) public String listWarehousrInfo(HttpServletRequest request, HttpServletResponse response) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE); //判断分页参数是否为空 if (BaseUtil.strIsNull(fse.getString(CmnConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CmnConst.PAGESIZE))) { return error(BaseErrorCode.SYSTEM_CPAGES_NOT_NULL.getValue(), BaseErrorCode.SYSTEM_CPAGES_NOT_NULL.getText()); } return OK_List(warehouseManagerService.listWarehousrInfo(fse)); } catch (Exception e) { return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage()); } } /** * 获取仓库信息 * @param request * @param response * @return */ @RequestMapping(value="/get/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getWarehouseInfo(HttpServletRequest request, HttpServletResponse response) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE); //判断uuid是否为空 if (BaseUtil.strIsNull(fse.getUUID())) { return error(BaseErrorCode.SYSTEM_FORM_COUNT.getValue(), BaseErrorCode.SYSTEM_FORM_COUNT.getValue()); } return OK_List(warehouseManagerService.getWarehouseInfo(fse.getUUID())); } catch (Exception e) { return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage()); } } /** * 保存仓库信息 * @param request * @param response * @return */ @RequestMapping(value="/save/{version}",method = RequestMethod.POST) @ApiVersion(1) public String saveWarehousrInfo(HttpServletRequest request, HttpServletResponse response) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE); //保存 boolean succ = warehouseManagerService.saveWarehouseInfo(fse); if (succ) { return OK(); } return error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_SAVE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getText()); } catch (Exception e) { return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage()); } } /** * 删除仓库信息 * @param request * @param response * @return */ @RequestMapping(value="/delete/{version}",method = RequestMethod.POST) @ApiVersion(1) public String deleteWarehousrInfo(HttpServletRequest request, HttpServletResponse response) { try { //获取参数 FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE); //判断uuid是否为空 if (BaseUtil.strIsNull(fse.getUUID())) { return error(BaseErrorCode.SYSTEM_FORM_COUNT.getValue(), BaseErrorCode.SYSTEM_FORM_COUNT.getValue()); } //删除 boolean succ = warehouseManagerService.deleteWarehouseInfo(fse.getUUID()); if (succ) { return OK(); } return error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getText()); } catch (Exception e) { return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage()); } } }