52 lines
1.6 KiB
Java
52 lines
1.6 KiB
Java
|
|
package com.rzyc.controller;
|
||
|
|
|
||
|
|
import com.common.utils.verification.Verification;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.validation.annotation.Validated;
|
||
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
|
||
|
|
import javax.imageio.ImageIO;
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
import java.awt.image.BufferedImage;
|
||
|
|
import java.io.OutputStream;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @author Xuwanxin
|
||
|
|
* @date 2022-10-10
|
||
|
|
*/
|
||
|
|
@Api(tags = "企业端公共接口")
|
||
|
|
@CrossOrigin("*")
|
||
|
|
@RequestMapping("common")
|
||
|
|
@Controller
|
||
|
|
@Validated
|
||
|
|
public class CommonController extends BaseController{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 验证码
|
||
|
|
* @param request
|
||
|
|
* @param response
|
||
|
|
* @throws Exception
|
||
|
|
*/
|
||
|
|
@ApiOperation(value = "验证码", notes = "验证码")
|
||
|
|
@GetMapping("/generateCode")
|
||
|
|
@ResponseBody
|
||
|
|
public void generateCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||
|
|
try {
|
||
|
|
BufferedImage image = Verification.getVerify(constantsConfigure.getGenerateCodeKey(),request);
|
||
|
|
OutputStream out = response.getOutputStream();
|
||
|
|
ImageIO.write(image, "JPEG", out);
|
||
|
|
out.flush();
|
||
|
|
out.close();
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|