| | |
| | | import com.alibaba.druid.util.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.zxing.WriterException; |
| | | import com.google.zxing.client.j2se.MatrixToImageWriter; |
| | | import com.google.zxing.common.BitMatrix; |
| | | import com.product.administration.config.CmnConst; |
| | | import com.product.administration.config.SystemCode; |
| | | import com.product.administration.service.ConferenceManagerService; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 会议管理签到二维码 |
| | | * @param request |
| | | * @param response |
| | | * @throws IOException |
| | | * @throws WriterException |
| | | */ |
| | | @PostMapping("/get_QrCode/{version}") |
| | | @ApiVersion(1) |
| | | public String getQrCode(HttpServletRequest request) throws IOException, WriterException { |
| | | public void getQrCode(HttpServletRequest request, HttpServletResponse response) throws IOException, WriterException { |
| | | |
| | | //获取参数 |
| | | FieldSetEntity fse = null; |
| | | conferenceManagerService.getQrCode(fse); |
| | | return OK(); |
| | | Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); |
| | | if (bean != null) { |
| | | RequestParameterEntity reqp = (RequestParameterEntity) bean; |
| | | fse = reqp.getFormData(); |
| | | |
| | | //判断参数是否为空 |
| | | if (bean == null || fse == null) { |
| | | this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); |
| | | } |
| | | String uuid = fse.getString("uuid"); |
| | | if(!StringUtils.isEmpty(uuid)){ |
| | | |
| | | // 设置响应流信息 |
| | | response.setContentType("image/jpg"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | response.setDateHeader("Expires", 0); |
| | | |
| | | OutputStream stream = response.getOutputStream(); |
| | | //后端跳转地址 |
| | | // String content = ("http://www.baidu.com"); |
| | | JSONObject jsonData = new JSONObject(); |
| | | jsonData.put("uuid",uuid); |
| | | jsonData.put("date",new Date()); |
| | | //jsonData.put("url",content); |
| | | //获取一个二维码图片 |
| | | BitMatrix bitMatrix = conferenceManagerService.getQrCode(jsonData.toString()); |
| | | //以流的形式输出到前端 |
| | | MatrixToImageWriter.writeToStream(bitMatrix , "jpg" , stream); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |