package com.product.admin.controller; import com.product.admin.config.CmnConst; import com.product.admin.config.SystemCode; import com.product.admin.service.CodeService; import com.product.admin.service.PortalsService; import com.product.admin.service.idel.IPortalsService; import com.product.common.lang.StringUtils; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.module.sys.version.ApiVersion; 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 javax.servlet.http.HttpServletRequest; /** * Copyright LX-BASE * * @Title: PortalController * @Project: LX-BASE-CONTROLLER * @Date: 2021-03-18 09:21 * @Author: ZhouJie * @Description: 门户配置 */ @RequestMapping("/api/portals") @RestController public class PortalController extends AbstractBaseController { @Autowired private PortalsService portalsService; @Autowired CodeService codeService; /** * @Date: 2020-03-18 10:04 * @Author: ZhouJie * @Description: 门户配置列表查询 */ @RequestMapping(value = "/list-portals/{version}", method = RequestMethod.POST) public String listPortals(HttpServletRequest request) { 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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_SYS_PORTALS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断分页参数 if (fse.getString(CmnConst.PAGESIZE) == null || fse.getString(CmnConst.CPAGE) == null) { return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); } DataTableEntity dt = portalsService.getPortalList(fse); return OK_List(dt); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_PORTALS_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_PORTALS_LIST_FAIL.getText()); } } /** * @Date: 2020-03-18 09:58 * @Author: ZhouJie * @Description: 门户配置详情查询 */ @RequestMapping(value = "/find-portals/{version}", method = RequestMethod.POST) @ApiVersion(1) public String portalInfo(HttpServletRequest request) { 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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } if ("1".equals(fse.getString("index_load"))) { return OK_List(portalsService.findUserIndexPortal()); } //判断表名是否正常 if (!CmnConst.PRODUCT_SYS_PORTALS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } FieldSetEntity fs = portalsService.getPortalInfo(fse); return OK_List(fs); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_PORTALS_INFO_FAIL.getValue(), SystemCode.SYSTEM_GET_PORTALS_INFO_FAIL.getText()); } } /** * @Date: 2020-03-18 11:13 * @Author: ZhouJie * @Description: 新增门户配置 */ @RequestMapping(value = "/add-portals/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addPortal(HttpServletRequest request) { 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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_PORTALS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } String uuid = portalsService.addPortal(fse); if (!StringUtils.isEmpty(uuid)) { return OK_Add(uuid); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_ADD_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_ADD_PORTALS_FAIL.getText()); return error(SystemCode.SYSTEM_ADD_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_ADD_PORTALS_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_ADD_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_ADD_PORTALS_FAIL.getText()); } } /** * @Date: 2020-03-18 13:51 * @Author: ZhouJie * @Description: 修改门户配置 */ @RequestMapping(value = "/update-portals/{version}", method = RequestMethod.POST) @ApiVersion(1) public String updataPortal(HttpServletRequest request) { 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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_SYS_PORTALS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } IPortalsService service = (IPortalsService) getProxyInstance(portalsService); boolean success = service.updatePortal(fse); if (success) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getText()); return error(SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_UPDATE_PORTALS_FAIL.getText()); } } /** * @Date: 2020-03-18 14:45 * @Author: ZhouJie * @Description: 删除门户配置 */ @RequestMapping(value = "/delete-portals/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deletePortal(HttpServletRequest request) { 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) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText()); } //判断表名是否正常 if (!CmnConst.PRODUCT_SYS_PORTALS.equals(fse.getTableName())) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //判断uuid是否为空 if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) { SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } IPortalsService service = (IPortalsService) getProxyInstance(portalsService); boolean success = service.deletePortal(fse); if (success) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getText()); return error(SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getText()); } catch (BaseException e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getValue(), SystemCode.SYSTEM_DELETE_PORTALS_FAIL.getText()); } } }