Skip to content

Commit 6b2b677

Browse files
committed
战术性调整
1 parent 110112c commit 6b2b677

File tree

6 files changed

+93
-75
lines changed

6 files changed

+93
-75
lines changed

springboot-dubbo-api/src/main/java/com/lzq/api/pojo/Follow.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public class Follow implements Serializable {
2121
/**
2222
* 用户名
2323
*/
24-
@TableField(value = "username")
24+
@TableId(value = "username")
2525
@JsonProperty("username")
2626
private String username;
2727
/**
2828
* 关注的用户冥
2929
*/
30-
@TableField(value = "follow_username")
30+
@TableId(value = "follow_username")
3131
@JsonProperty("followUsername")
3232
private String followUsername;
3333
/**

springboot-dubbo-service/src/main/java/com/lzq/dubboservice/service/MailServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import com.lzq.api.pojo.Mail;
55
import com.lzq.api.service.MailService;
6+
import lombok.extern.slf4j.Slf4j;
67
import org.apache.dubbo.config.annotation.Service;
78
import org.springframework.beans.factory.annotation.Autowired;
89
import org.springframework.mail.javamail.JavaMailSender;
@@ -17,6 +18,7 @@
1718
* @description:MailService实现类
1819
* @date :2021/8/23 10:48
1920
*/
21+
@Slf4j
2022
@Component
2123
@Service(interfaceClass = MailService.class,timeout = 60000,retries = 0)
2224
public class MailServiceImpl implements MailService {
@@ -35,10 +37,10 @@ public boolean sendActiveMail(Mail mail) {
3537
helper.setSubject(mail.getSubject());
3638
helper.setText(mail.getMailContent(), true);
3739
javaMailSender.send(message);
38-
System.out.println("发送成功");
40+
log.info("发送成功");
3941
return true;
4042
} catch (MessagingException var4) {
41-
System.out.println("发送失败");
43+
log.info("发送失败");
4244
return false;
4345
}
4446
}

springboot-dubbo-web/src/main/java/com/lzq/web/config/WebConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class WebConfigurer implements WebMvcConfigurer {
1010

1111
@Override
1212
public void addInterceptors(InterceptorRegistry registry) {
13-
registry.addInterceptor(new JWTIntercepter()).addPathPatterns("/user/**","/example/**");
13+
registry.addInterceptor(new JWTIntercepter()).addPathPatterns("/user/**","/example/**","/feedback/**");
1414
}
1515
}

springboot-dubbo-web/src/main/java/com/lzq/web/controller/IndexController.java

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,6 @@ public Map<String, Object> getverify(HttpServletRequest request) {
9090
@GetMapping({"/github"})
9191
@ApiOperation("gituhub第三方登录调用接口")
9292
public Map<String, Object> githubcallback(HttpServletRequest request) throws JsonProcessingException {
93-
// Map<String, String> jwtmap = new HashMap();
94-
// //获取code 和 state
95-
// String code = request.getParameter("code");
96-
// String state = request.getParameter("state");
97-
// //获取github返回的信息
98-
// JSONObject userInfo = githubService.getUserInfo(githubService.getAccessToken(code, state));
99-
// //把返回的信息封装成对象
100-
// UserInfo info = JSON.parseObject(userInfo.toString(), UserInfo.class);
101-
// //根据githubid查询用户信息
102-
// Account rest = accountService.queryByGitId(info.getId(), null);
103-
// String token;
104-
// //判断改github是否进行过绑定 未绑定则进行绑定,绑定则返回用户信息
105-
// if (rest != null) {
106-
// jwtmap.put("username", rest.getUsername());
107-
// jwtmap.put("githubId", rest.getGithubId());
108-
// //把githubId存入数据库中用来严重token是否过期
109-
// stringRedisTemplate.opsForValue().set(rest.getGithubId(), rest.getGithubId(), 900L, TimeUnit.SECONDS);
110-
// token = JWTUtils.getToken(jwtmap);
111-
// log.info("该用户已绑定");
112-
// return ResultMapUtils.ResultMapWithToken(true, 0, "返回token用于登录", token);
113-
// } else {
114-
// jwtmap.put("githubId", info.getId().toString());
115-
// token = JWTUtils.getToken(jwtmap);
116-
// log.info("该用户未绑定");
117-
// //返回token 用来绑定第三方账号
118-
// return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
119-
// }
12093
log.info("我进入了github第三方登录调用接口");
12194
Map<String, Object> map = UserUtils.callback(request, githubService, accountService, "githubId");
12295
return map;
@@ -132,31 +105,6 @@ public Map<String, Object> githubcallback(HttpServletRequest request) throws Jso
132105
@ApiOperation("gitee第三方登录调用接口")
133106
public Map<String, Object> giteeCallBack(HttpServletRequest request) throws IOException {
134107
log.info("我进入了gitee第三方登录调用接口");
135-
// Map<String, String> jwtmap = new HashMap();
136-
// String code = request.getParameter("code");
137-
// String state = request.getParameter("state");
138-
// JSONObject userInfo = giteeService.getUserInfo(this.giteeService.getAccessToken(code, state));
139-
// //把json转化为对象
140-
// UserInfo info = JSON.parseObject(userInfo.toString(), UserInfo.class);
141-
// //根据giteeid查询用户信息
142-
// Account rest = accountService.queryByGitId(null, Integer.toString(info.getId()));
143-
// String token;
144-
// //判断该gitee是否进行过绑定 未绑定则进行绑定,绑定则返回用户信息
145-
// if (rest != null) {
146-
// jwtmap.put("username", rest.getUsername());
147-
// jwtmap.put("giteeId", rest.getGiteeId());
148-
// token = JWTUtils.getToken(jwtmap);
149-
// //把giteeId存入数据库中用来严重token是否过期
150-
// stringRedisTemplate.opsForValue().set(rest.getGiteeId(), rest.getGiteeId(), 900L, TimeUnit.SECONDS);
151-
// log.info("该用户已绑定");
152-
// return ResultMapUtils.ResultMapWithToken(true, 0, "返回token用于登录", token);
153-
// } else {
154-
// jwtmap.put("giteeId", Integer.toString(info.getId()));
155-
// token = JWTUtils.getToken(jwtmap);
156-
// log.info("该用户未绑定");
157-
// //返回token 用来绑定第三方账号
158-
// return ResultMapUtils.ResultMapWithToken(false, 0, "返回token用于绑定账号", token);
159-
// }
160108
Map<String, Object> map = UserUtils.callback(request, giteeService, accountService, "giteeId");
161109
return map;
162110
}
@@ -171,15 +119,43 @@ public Map<String, Object> giteeCallBack(HttpServletRequest request) throws IOEx
171119
@PostMapping("/sendPasswordEmail")
172120
@ApiOperation("发送修改密码链接到邮箱")
173121
public Map<String, Object> sendPasswordEmail(Account account) {
174-
log.info("我进入了发送链接邮箱地址");
175122
HashMap<String, String> map = new HashMap<>();
176-
//判断用户名是否不为空
177123
map.put("email", account.getEmail());
178124
String token = JWTUtils.getToken(map, 12, 10);
125+
log.info("我进入了发送链接邮箱地址");
126+
String url="http://localhost:8080/resetPwd?token=" + token;
127+
String template="<!DOCTYPE html>" +
128+
"<html lang=\"zh-n\">" +
129+
"<head><meta charset=\"UTF-8\">" +
130+
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" +
131+
"<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">" +
132+
"<style>body{background:#1e1e1e;width:100%;}.flex{display:flex;}.flex-ai{align-items:center;}.flex-col{flex-direction:column;}.flex-jcc{justify-content:center;}" +
133+
"</style>" +
134+
"</head>" +
135+
"<body>" +
136+
"<div class=\"flex flex-jcc\" style=\"background:#1e1e1e;width:100%;height:100%;padding: 50px 15px 100px 15px;box-sizing:border-box;\">" +
137+
"<div class=\"flex flex-ai flex-jcc\"><img style=\"width: 60px\" src=\"http://images.lliiooiill.cn/logo.svg\" alt=\"JS Encoder\">" +
138+
"<span style=\"color:#F8F8F8;font-weight:bold;font-size:24px;margin-left:15px\">JS Encoder</span>" +
139+
"</div>" +
140+
"<div class=\"flex flex-col\" style=\"width:100%;color:#999999;font-size:14px;margin-top:40px\">" +
141+
"<span>这是你的重置密码链接,有效期为10分钟,请尽快操作!</span>" +
142+
"<a style=\"margin-top:15px;color=#1890ff\" href=\" \">"+url+"</ a>" +
143+
"</div>" +
144+
"<div style=\"width:100%;color:#999999;font-size:14px;margin-top:40px\" class=\"flex flex-col\">" +
145+
"<span>非本人操作,请忽略此邮件!</span>" +
146+
"<span>此为系统邮件,请勿回复</span>" +
147+
"</div>" +
148+
"<hr style=\"width:100%;border-color:#777777\">" +
149+
"<a href=\"https://www.lliiooiill.cn\" style=\"color:#999999;font-size:12px;margin-top:40px\">JS Encoder</ a>" +
150+
"<span style=\"color:#999999;font-size:12px;margin-top:10px\">JS Encoder 团队</span>" +
151+
"</div>" +
152+
"</div>" +
153+
"</body>" +
154+
"</html>";
179155
Mail mail = new Mail();
180156
mail.setTo(account.getEmail());
181157
mail.setSubject("请点击以下链接进行密码修改");
182-
mail.setMailContent("http://localhost:8080/resetPwd?token=" + token);
158+
mail.setMailContent(url);
183159
//发送修改密码链接
184160
boolean b = mailService.sendActiveMail(mail);
185161
//返回token令牌
@@ -211,7 +187,7 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
211187
account.setEmail(email);
212188
//更新密码
213189
Boolean update = accountService.update(account);
214-
log.info("修改:"+Boolean.toString(update));
190+
log.info("修改:" + Boolean.toString(update));
215191
return ResultMapUtils.ResultMap(update, 0, null);
216192
} else {
217193

@@ -239,11 +215,42 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
239215
@GetMapping({"/send"})
240216
@ApiOperation("发送邮箱验证码")
241217
public Map<String, Object> sendEmail(String email) {
218+
log.info("发送邮箱验证码:"+email);
242219
String code = UserUtils.getCode();
220+
String template = "" +
221+
"<!DOCTYPE html>" +
222+
"<html lang=\"zh-n\">" +
223+
"<head>" +
224+
"<meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" +
225+
"<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">" +
226+
"<style>" +
227+
"body{width:100%;}.flex{display:flex;}.flex-ai{align-items:center;}.flex-col{flex-direction:column;}.flex-jcc{justify-content:center;}" +
228+
"</style>" +
229+
"</head>" +
230+
"<body>" +
231+
"<div class=\"flex flex-jcc\" style=\"background:#1e1e1e;width:100%;height:100%;padding: 50px 15px 100px 15px;box-sizing:border-box;\"><div style=\"width:450px;\" class=\"flex flex-col flex-ai\">" +
232+
"<div class=\"flex flex-ai flex-jcc\"><img style=\"width: 60px\" src=\"http://images.lliiooiill.cn/logo.png\" alt=\"JS Encoder\">" +
233+
"<span style=\"color:#F8F8F8;font-weight:bold;font-size:24px;margin-left:15px\">JS Encoder</span>" +
234+
"</div>" +
235+
"<div class=\"flex flex-col\" style=\"width:100%;color:#999999;font-size:14px;margin-top:40px\">" +
236+
"<span>欢迎注册 JS Encoder!</span><span style=\"margin-top:10px\">这是你的邮箱验证码,有效期为5分钟,请尽快注册!</span></div><div class=\"flex flex-jcc\">" +
237+
"<span style=\"margin-top:30px;font-weight:bold;font-size:24px;background:#1a1a1a;color:#1890ff;padding:5px 15px;border-radius:5px\">" + code + "</span>" +
238+
"</div>" +
239+
"<div style=\"width:100%;color:#999999;font-size:14px;margin-top:40px\" class=\"flex flex-col\">" +
240+
"<span>非本人操作,请忽略此邮件!</span>" +
241+
"<span>此为系统邮件,请勿回复</span>" +
242+
"</div>" +
243+
"<hr style=\"width:100%;border-color:#777777\">" +
244+
"<a href=\" \" style=\"color:#999999;font-size:12px;margin-top:40px\">JS Encoder</a>" +
245+
"<span style=\"color:#999999;font-size:12px;margin-top:10px\">JS Encoder 团队</span>" +
246+
"</div>" +
247+
"</div>" +
248+
"</body>" +
249+
"</html>";
243250
Mail mail = new Mail();
244251
mail.setTo(email);
245252
mail.setSubject("验证码");
246-
mail.setMailContent(code);
253+
mail.setMailContent(template);
247254
boolean bol = mailService.sendActiveMail(mail);
248255
//把验证码存储到redis中
249256
stringRedisTemplate.opsForValue().set(email, code, 300L, TimeUnit.SECONDS);

springboot-dubbo-web/src/main/java/com/lzq/web/controller/UserController.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.lzq.api.pojo.Account;
44
import com.lzq.api.pojo.Follow;
5-
import com.lzq.api.pojo.Mail;
65
import com.lzq.api.pojo.Role;
76
import com.lzq.api.service.AccountService;
87
import com.lzq.api.service.FollowService;
@@ -16,6 +15,7 @@
1615
import org.apache.dubbo.config.annotation.Reference;
1716
import org.springframework.beans.factory.annotation.Autowired;
1817
import org.springframework.data.redis.core.RedisTemplate;
18+
import org.springframework.data.redis.core.StringRedisTemplate;
1919
import org.springframework.web.bind.annotation.*;
2020

2121
import javax.servlet.http.HttpServletRequest;
@@ -48,6 +48,9 @@ public class UserController {
4848
@Autowired
4949
private RedisTemplate redisTemplate;
5050

51+
@Autowired
52+
private StringRedisTemplate stringRedisTemplate;
53+
5154

5255
/**
5356
* 更新用户信息
@@ -76,7 +79,6 @@ public Map<String, Object> updateUserInfo(HttpSession session, Account account)
7679

7780
/**
7881
* 解绑Github
79-
*
8082
* @param account
8183
* @return
8284
*/
@@ -155,20 +157,28 @@ public Map<String, Object> deleteAccount(Account account) {
155157
*/
156158
@PutMapping("/updateEmail")
157159
@ApiOperation("更新注册邮箱")
158-
public Map<String, Object> updatEmail(Account account, String newEmail) {
160+
public Map<String, Object> updatEmail(Account account,String code) {
159161
log.info("我进入了更新注册邮箱接口:" + account.getUsername());
160-
Account byEmail = accountService.queryByEmail(newEmail);
162+
Account byEmail = accountService.queryByEmail(account.getEmail());
163+
log.info("更新注册邮箱:"+account.getEmail());
164+
String resultCode=stringRedisTemplate.opsForValue().get(account.getEmail());
165+
log.info(resultCode);
161166
Account byPassword = accountService.queryByPassword(account);
162167
//当新邮箱没被注册过且用户名和验证码正确时进行邮箱修改
163-
if (byEmail != null) {
164-
return ResultMapUtils.ResultMap(false, 2, "邮箱已被注册");
165-
} else if (byPassword!=null) {
166-
Boolean bol = accountService.update(account);
167-
return ResultMapUtils.ResultMap(bol, 0, null);
168+
if (code.equals(resultCode)){
169+
if (byEmail != null) {
170+
return ResultMapUtils.ResultMap(false, 2, "邮箱已被注册");
171+
} else if (byPassword!=null) {
172+
Boolean bol = accountService.update(account);
173+
return ResultMapUtils.ResultMap(bol, 0, null);
174+
}else {
175+
return ResultMapUtils.ResultMap(false,1,"密码错误");
176+
}
168177
}else {
169-
return ResultMapUtils.ResultMap(false,1,"密码错误");
178+
return ResultMapUtils.ResultMap(false,3,"验证码错误");
170179
}
171180

181+
172182
}
173183

174184
/**
@@ -209,5 +219,4 @@ public Map<String, Object> cancelFollow(Follow follow) {
209219
return ResultMapUtils.ResultMap(bol, 0, null);
210220
}
211221

212-
213222
}

springboot-dubbo-web/src/main/java/com/lzq/web/utils/ExampleUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static String screenshot(String username, String filename) throws IOExcep
9898
convertWebp(screenshotAs, file);
9999
//把生成的webp文件转换位byte数组
100100
//上传到七牛云
101-
String imgName = QiniuyunUtils.uploadFile(file);
101+
String imgName = QiniuyunUtils.uploadFile(file,username);
102102
broswer.close();
103103
//删除截图原始图片缓存
104104
screenshotAs.delete();
@@ -130,7 +130,7 @@ public static Boolean SaveExampleContent(Example example, Content exampleContent
130130
Boolean bol = false;
131131
try {
132132
//包编译后的html内容覆盖原来的内容
133-
fos.write(content.getBytes("GBK"));
133+
fos.write(content.getBytes("UTF-8"));
134134
//第一次保存时生成图片
135135
if (StringUtils.isNullOrEmpty(example.getImg())) {
136136
//截图后进行保存

0 commit comments

Comments
 (0)