| | |
| | | package com.doumee.api.web; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import com.amazonaws.util.Md5Utils; |
| | | import com.amazonaws.util.StringUtils; |
| | | import com.doumee.biz.system.SystemDataPermissionBiz; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.biz.zbom.ZbomCRMService; |
| | | import com.doumee.biz.zbom.ZbomZhongTaiService; |
| | | import com.doumee.config.annotation.LoginRequired; |
| | | import com.doumee.config.annotation.UserLoginRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.codec.digest.Md5Crypt; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.apache.tomcat.util.security.MD5Encoder; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | public UsersService usersService; |
| | | |
| | | @Autowired |
| | | public SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | |
| | | @UserLoginRequired |
| | |
| | | |
| | | @ApiOperation(value = "生成小程序码", notes = "PAD端") |
| | | @PostMapping("/getQrCode") |
| | | public void getQrCode(@RequestBody GenerateQRCodeRequest generateQRCodeRequest, HttpServletResponse response) { |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "interfaceToken", value = "token", required = true), |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "timestamp", value = "时间戳", required = true), |
| | | }) |
| | | public void getQrCode(@RequestBody GenerateQRCodeRequest generateQRCodeRequest, HttpServletRequest httpServletRequest, HttpServletResponse response) { |
| | | String interfaceToken = httpServletRequest.getHeader("interfaceToken"); |
| | | String timestamp = httpServletRequest.getHeader("timestamp"); |
| | | String interfaceKey = systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_PAD_INTERFACE_KEY).getCode(); |
| | | String token = DigestUtils.md5Hex(timestamp+interfaceKey); |
| | | if(!token.equals(interfaceToken)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"token已失效!"); |
| | | } |
| | | try{ |
| | | response.setHeader("Cache-Control", "no-store, no-cache"); |
| | | response.setContentType("image/jpeg"); |