|
@@ -1,103 +0,0 @@
|
|
|
-package com.uas.platform.b2c.b2b.controller;
|
|
|
|
|
-
|
|
|
|
|
-import com.uas.platform.b2c.b2b.model.EnterpriseBaseInfo;
|
|
|
|
|
-import com.uas.platform.b2c.b2b.service.EnterpriseBaseInfoService;
|
|
|
|
|
-import com.uas.platform.b2c.common.base.model.AccessToken;
|
|
|
|
|
-import com.uas.platform.b2c.common.base.service.AccessTokenService;
|
|
|
|
|
-import com.uas.platform.b2c.core.config.SysConf;
|
|
|
|
|
-import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
|
|
-import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
|
|
|
|
|
-import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
|
|
-import com.uas.platform.core.model.PageInfo;
|
|
|
|
|
-import com.uas.platform.core.model.PageParams;
|
|
|
|
|
-import com.wordnik.swagger.annotations.ApiOperation;
|
|
|
|
|
-import com.wordnik.swagger.annotations.ApiParam;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
-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.HttpServletResponse;
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-import java.rmi.AccessException;
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * b2b操作
|
|
|
|
|
- *
|
|
|
|
|
- * Created by hejq on 2018-04-20.
|
|
|
|
|
- */
|
|
|
|
|
-@RequestMapping("/b2b/manage")
|
|
|
|
|
-@RestController
|
|
|
|
|
-public class ManageController {
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private AccessTokenService accessTokenService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private SysConf sysConf;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private EnterpriseBaseInfoService baseInfoService;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 操作日志
|
|
|
|
|
- */
|
|
|
|
|
- private UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 定义可以访问的公司
|
|
|
|
|
- */
|
|
|
|
|
- private static final Long[] ACCESS_ENUU = {1000001L, 10044948L, 10042291L, 10042875L, 10043923L, 10041166L};
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 通过UU号进行跳转到平台
|
|
|
|
|
- *
|
|
|
|
|
- * @param response HttpServletResponse
|
|
|
|
|
- * @param enUU uu号
|
|
|
|
|
- * @throws IOException
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping("/authed/redirect/{enUU}")
|
|
|
|
|
- public void redirect(HttpServletResponse response, HttpServletRequest request, @PathVariable("enUU") long enUU)
|
|
|
|
|
- throws IOException {
|
|
|
|
|
- Object bindObj = enUU;
|
|
|
|
|
- if (null == SystemSession.getUser() || null == SystemSession.getUser().getEnterprise()) {
|
|
|
|
|
- throw new AccessException("请先登录");
|
|
|
|
|
- }
|
|
|
|
|
- if (!Arrays.asList(ACCESS_ENUU).contains(SystemSession.getUser().getEnterprise().getUu())) {
|
|
|
|
|
- throw new AccessException("没有访问权限");
|
|
|
|
|
- }
|
|
|
|
|
- AccessToken token = accessTokenService.createNew(bindObj);
|
|
|
|
|
- request.getSession().setAttribute("user", SystemSession.getUser());
|
|
|
|
|
- StringBuffer redirectUrl = new StringBuffer();
|
|
|
|
|
- String domain = sysConf.getB2bDomain();
|
|
|
|
|
- if (StringUtils.hasText(domain)) {
|
|
|
|
|
- // 防止使用同一个www.ubtob.com造成session冲突
|
|
|
|
|
- redirectUrl.append("http://").append(enUU).append(".").append(domain);
|
|
|
|
|
- } else {
|
|
|
|
|
- redirectUrl.append(sysConf.getB2bUrl());
|
|
|
|
|
- }
|
|
|
|
|
- redirectUrl.append("?client_type=manage&access_token=").append(token.getId());
|
|
|
|
|
- logger.log("管理员访问B2B", "通过商务平台后台访问B2B");
|
|
|
|
|
- response.sendRedirect(redirectUrl.toString());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 分页查询B2B注册信息
|
|
|
|
|
- *
|
|
|
|
|
- * @param params 分页参数
|
|
|
|
|
- * @param keyword 关键词
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping(value = "/enterpriseList", method = RequestMethod.GET)
|
|
|
|
|
- @ApiOperation(value = "分页获取平台所有注册企业信息", httpMethod = "GET")
|
|
|
|
|
- public Page<EnterpriseBaseInfo> findEnterPageByStatus(@ApiParam(required = true, value = "分页参数") PageParams params, @ApiParam(required = true, value = "搜索字符串") String keyword) {
|
|
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
|
|
- logger.log("管理平台获取企业列表", "通过[" + keyword + "]获取企业信息");
|
|
|
|
|
- return baseInfoService.findEnterPageByKeyword(info, keyword);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|