|
|
@@ -1,6 +1,8 @@
|
|
|
package com.cyksj.web.controller.mini;
|
|
|
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.IoKit;
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.model.entity.User;
|
|
|
@@ -23,6 +25,8 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.OutputStream;
|
|
|
|
|
|
/*
|
|
|
*项目名: netflix
|
|
|
@@ -61,6 +65,30 @@ public class MiniController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(url);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成小程序code
|
|
|
+ */
|
|
|
+ @GetMapping("/generate/code")
|
|
|
+ public void generateCode(String dsCode, HttpServletResponse response) throws Exception {
|
|
|
+ MiniSchemaReq req = new MiniSchemaReq();
|
|
|
+ req.setDsCode(dsCode);
|
|
|
+ byte [] s = miniService.generateCode(req);
|
|
|
+ response.reset();
|
|
|
+ // 若直接在浏览器预览 需要注释下面的response header
|
|
|
+ //response.addHeader("Content-Disposition", "attachment;filename=share.jpeg");
|
|
|
+ response.setContentType("image/jpeg");
|
|
|
+ // 处理文件 返回流
|
|
|
+ OutputStream out = null;
|
|
|
+ try {
|
|
|
+ out = response.getOutputStream();
|
|
|
+ IoKit.write(s, out);
|
|
|
+ } catch (Throwable e) {
|
|
|
+ throw BusinessRuntimeException.getInstance(StringUtil.getErrorMsg(e));
|
|
|
+ } finally {
|
|
|
+ IoKit.close(out);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 银河小程序 静默授权登录
|
|
|
*/
|