docs: D.E.P.R.E.C.A.T.E.D

This commit is contained in:
wzp 2024-12-24 18:42:56 +08:00
parent f728d3ae59
commit d533fac80f
2 changed files with 14 additions and 9 deletions

View File

@ -3,6 +3,10 @@
A clubs home for Hangzhou Electron & Information Vocational School
building by springboot3.0 with mysql db
---
<h1><center><font color="red"> ⚠⚠⚠⚠ <font color="yellow">🚮 D.E.P.R.E.C.A.T.E.D </font>⚠⚠⚠⚠ </font></center></h1>
---
## Usage
### 1.Create user table

View File

@ -30,19 +30,19 @@ public class VerifyCodeService {
public VerifyImgVo generateVerifyCode() {
int width = 100;
int height = 40;
BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.createGraphics();
Font font = new Font("宋体",Font.BOLD,25);
Font font = new Font("宋体", Font.BOLD, 25);
g.setFont(font);
StringBuilder code = new StringBuilder();
for (int i = 0; i < 4; i++) {
int index = new Random().nextInt(StringUtils.source.length() - 1);
char myCode = StringUtils.source.charAt(index);
Random random = new Random();
g.setColor(new Color(20+random.nextInt(120),20+random.nextInt(120),20+random.nextInt(120)));
g.drawString(myCode+"",15+i*20,20+new Random().nextInt(10));
g.setColor(new Color(20 + random.nextInt(120), 20 + random.nextInt(120), 20 + random.nextInt(120)));
g.drawString(myCode + "", 15 + i * 20, 20 + new Random().nextInt(10));
for (int j = 0; j < 5; j++) {
g.drawLine(random.nextInt(width),random.nextInt(height),random.nextInt(width),random.nextInt(height));
g.drawLine(random.nextInt(width), random.nextInt(height), random.nextInt(width), random.nextInt(height));
}
code.append(myCode);
}
@ -50,17 +50,18 @@ public class VerifyCodeService {
String s = generatorRandomString(32);
String codeString = code.toString();
verifyDao.save(new VerifyVo(s, codeString, new Date()));
try(ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()){
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
ImageIO.write(image, "png", byteArrayOutputStream);
return new VerifyImgVo(byteArrayOutputStream.toByteArray(), s);
}
}
public boolean invalid(String code, String ans){
if (code == null || ans == null){
public boolean invalid(String code, String ans) {
if (code == null || ans == null) {
return true;
}
VerifyVo byKey = verifyDao.getByKey(code);
if (byKey == null){
if (byKey == null) {
return true;
}
verifyDao.delete(byKey);