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.PagesService; 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 com.product.util.BaseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; 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: PageController * @Project: LX-BASE-CONTROLLER * @Date: 2021-03-16 09:16 * @Author: ZhouJie * @Description: 栏目配置 */ @RequestMapping("/api/pages") @RestController public class PageController extends AbstractBaseController { @Autowired private PagesService pagesService; @Autowired CodeService codeService; @PostMapping("/get-org-role/{version}") @ApiVersion(1) public String getOrgRoles(){ try{ return BaseUtil.success(pagesService.getCompanyRoleTree()); }catch(BaseException e){ e.printStackTrace(); return error(e); }catch (Exception e){ e.printStackTrace(); return error(SystemCode.GET_COMPANY_ROLE_FAIL.getValue(),SystemCode.GET_COMPANY_ROLE_FAIL.getText()+(e.getMessage()!=null?","+e.getMessage():"")); } } /** * @Date: 2020-03-22 09:49 * @Author: ZhouJie * @Description: 栏目配置类型查询 */ @RequestMapping(value = "/list-pagetype/{version}", method = RequestMethod.POST) public String listPageType(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_PORTAL_COLUMN_CONFIG.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()); } DataTableEntity dt = pagesService.getPageListPagetype(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_PAGETYPE_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_PAGETYPE_LIST_FAIL.getText()); } } /** * @Date: 2020-03-19 16:49 * @Author: ZhouJie * @Description: 根据栏目类型查询栏目配置列表 */ @RequestMapping(value = "/list-pagesBytype/{version}", method = RequestMethod.POST) public String listPagesByPagetype(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_PORTAL_COLUMN_CONFIG.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()); } DataTableEntity dt = pagesService.getPageListByPagetype(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_PAGES_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_PAGES_LIST_FAIL.getText()); } } /** * @Date: 2020-03-18 09:49 * @Author: ZhouJie * @Description: 栏目配置列表查询 */ @RequestMapping(value = "/list-pages/{version}", method = RequestMethod.POST) public String listPages(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_PORTAL_COLUMN_CONFIG.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 = pagesService.getPageList(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_PAGES_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_PAGES_LIST_FAIL.getText()); } } /** * @Date: 2020-03-18 10:32 * @Author: ZhouJie * @Description: 栏目配置详情查询 */ @RequestMapping(value="/find-pages/{version}",method=RequestMethod.POST) @ApiVersion(1) public String pageInfo(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_PORTAL_COLUMN_CONFIG.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 = pagesService.getPageInfo(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_PAGES_INFO_FAIL.getValue(),SystemCode.SYSTEM_GET_PAGES_INFO_FAIL.getText()); } } /** * @Date: 2020-03-16 14:45 * @Author: ZhouJie * @Description: 新增栏目配置 */ @RequestMapping(value = "/add-pages/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addPage(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_PORTAL_COLUMN_CONFIG.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 = pagesService.addPage(fse); if (!StringUtils.isEmpty(uuid)) { return OK_Add(uuid); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_ADD_PAGES_FAIL.getValue(), SystemCode.SYSTEM_ADD_PAGES_FAIL.getText()); return error(SystemCode.SYSTEM_ADD_PAGES_FAIL.getValue(), SystemCode.SYSTEM_ADD_PAGES_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_PAGES_FAIL.getValue(), SystemCode.SYSTEM_ADD_PAGES_FAIL.getText()); } } /** * @Date: 2020-03-16 15:31 * @Author: ZhouJie * @Description: 修改栏目配置 */ @RequestMapping(value = "/update-pages/{version}", method = RequestMethod.POST) @ApiVersion(1) public String updataPage(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_PORTAL_COLUMN_CONFIG.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()); } boolean succ=pagesService.updatePage(fse); if(succ) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_UPDATE_PAGES_FAIL.getValue(),SystemCode.SYSTEM_UPDATE_PAGES_FAIL.getText()); return error(SystemCode.SYSTEM_UPDATE_PAGES_FAIL.getValue(),SystemCode.SYSTEM_UPDATE_PAGES_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_UPDATE_PAGES_FAIL.getValue(),SystemCode.SYSTEM_UPDATE_PAGES_FAIL.getText()); } } /** * @Date: 2020-03-16 16:13 * @Author: ZhouJie * @Description: 删除栏目配置 */ @RequestMapping(value = "/delete-pages/{version}", method = RequestMethod.POST) @ApiVersion(1) public String deletePage(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_PORTAL_COLUMN_CONFIG.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()); } boolean success=pagesService.deletePage(fse); if(success) { return OK(); } SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_PAGES_FAIL.getValue(),SystemCode.SYSTEM_DELETE_PAGES_FAIL.getText()); return error(SystemCode.SYSTEM_DELETE_PAGES_FAIL.getValue(),SystemCode.SYSTEM_DELETE_PAGES_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_PAGES_FAIL.getValue(),SystemCode.SYSTEM_DELETE_PAGES_FAIL.getText()); } } }