package com.product.administration.controller; import com.alibaba.druid.util.StringUtils; import com.product.administration.config.CmnConst; import com.product.administration.config.SystemCode; import com.product.administration.service.AddressListService; 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.data.config.CmnCode; import com.product.module.sys.version.ApiVersion; 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 * @Title: AddressListController * @Project: product-server * @date: 2021-05-25 14:15 * @author: ZhouJie * @Description: 通讯录 */ @RequestMapping("/api/addresslist") @RestController public class AddressListController extends AbstractBaseController { @Autowired public AddressListService addressListService; /** * @description: 获取通讯录 * @author: ZhouJie * @date: 2021-05-25 14:38 */ @RequestMapping(value = "/list-address/{version}", method = RequestMethod.POST) @ApiVersion(1) public String AddressList(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_USERS.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 = addressListService.Addresslist(fse); return OK_List(dt); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_ADDRESS_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_ADDRESS_LIST_FAIL.getText()); } } /** * @description: 全员搜索(匹配名字、电话、邮箱) * @author: ZhouJie * @date: 2021-05-25 17:57 */ @RequestMapping(value = "/list-addressby/{version}", method = RequestMethod.POST) @ApiVersion(1) public String FullSearch(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_USERS.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 = addressListService.FullSearch(fse); return OK_List(dt); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.SYSTEM_GET_ADDRESS_LIST_FAIL.getValue(), SystemCode.SYSTEM_GET_ADDRESS_LIST_FAIL.getText()); } } /** * @description: 通讯录导出 * @author: luoxin * @date: 2021-05-25 17:57 */ @PostMapping(value = "/export-addressBook/{version}") @ApiVersion(1) public String addressBookExport(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()); } addressListService.addressBookExport(fse); return OK(); } catch (BaseException e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return this.error(SystemCode.EXPORT_FILE_FAIL.getValue(), SystemCode.EXPORT_FILE_FAIL.getText()); } } }