Skip to content

Commit 9dcb1a3

Browse files
committed
把AccountResultService中的查询粉丝列表和查询关注列表接口移植到AccountService中
1 parent b3d892e commit 9dcb1a3

File tree

15 files changed

+196
-116
lines changed

15 files changed

+196
-116
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class Account implements Serializable, UserDetails {
9494
*/
9595
@JsonIgnore
9696
@TableField(exist = false)
97-
private Role role;
97+
private Role role=new Role(1,"ROLE_normal");
9898
/**
9999
* 描述
100100
*/
@@ -131,6 +131,12 @@ public class Account implements Serializable, UserDetails {
131131
@TableField("recycle")
132132
@JsonIgnore
133133
private Integer recycle;
134+
/**
135+
* 我的关注
136+
*/
137+
@TableField(exist = false)
138+
@JsonProperty("myFollow")
139+
private Boolean myFollow=false;
134140
/**
135141
* 创建时间
136142
*/

springboot-dubbo-api/src/main/java/com/lzq/api/service/AccountResultService.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ public interface AccountResultService {
2020
*/
2121
AccountResult queryByUsername(String username);
2222

23-
/**
24-
* 获取关注列表
25-
* @param result
26-
* @param currentPage 当前页
27-
* @return
28-
*/
29-
PageInfo<AccountResult> getFollowList(AccountResult result, Integer currentPage);
30-
31-
/**
32-
* 获取粉丝列表
33-
* @param result
34-
* @return
35-
*/
36-
PageInfo<AccountResult> getFanList(AccountResult result,Integer currentPage);
37-
3823
/**
3924
* 更新喜爱数(校正喜爱数)
4025
* @param result

springboot-dubbo-api/src/main/java/com/lzq/api/service/AccountService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lzq.api.service;
22

33

4+
import com.github.pagehelper.PageInfo;
45
import com.lzq.api.pojo.Account;
56

67
/**
@@ -31,7 +32,7 @@ public interface AccountService {
3132
* @param account 实例对象
3233
* @return
3334
*/
34-
Boolean update(Account account) throws Exception;
35+
Boolean update(Account account);
3536

3637

3738
/**
@@ -75,6 +76,21 @@ public interface AccountService {
7576
*/
7677
Account queryByGitId(String githubId, String giteeId);
7778

79+
/**
80+
* 获取关注列表
81+
* @param result
82+
* @param currentPage 当前页
83+
* @return
84+
*/
85+
PageInfo<Account> getFollowList(Account result, Integer currentPage);
86+
87+
/**
88+
* 获取粉丝列表
89+
* @param result
90+
* @return
91+
*/
92+
PageInfo<Account> getFanList(Account result,Integer currentPage);
93+
7894
/**
7995
* 根据用户名查询用户信息
8096
* @param username

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.apache.ibatis.annotations.Param;
66
import org.springframework.stereotype.Repository;
77

8+
import java.util.List;
9+
810
/**
911
* @author :LZQ
1012
* @description:TODO
@@ -26,4 +28,8 @@ public interface AccountMapper extends BaseMapper<Account> {
2628
Integer reduceRecycle(@Param("username") String username);
2729

2830
Integer bindGit(Account account);
31+
32+
List<Account> getFollowList(Account result);
33+
34+
List<Account> getFanList(Account result);
2935
}

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

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

33
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
44
import com.lzq.api.dto.AccountResult;
5-
import com.lzq.api.pojo.Account;
65
import org.springframework.stereotype.Repository;
76

87
import java.util.List;
@@ -15,9 +14,5 @@
1514
@Repository
1615
public interface AccountResultMapper extends BaseMapper<AccountResult> {
1716

18-
public List<AccountResult> getFollowList(AccountResult result);
19-
20-
public List<AccountResult> getFanList(AccountResult result);
21-
2217
Integer updateFavorites(AccountResult result);
2318
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ public AccountResult queryByUsername(String username) {
3131
return baseMapper.selectOne(wrapper);
3232
}
3333

34-
@Override
35-
public PageInfo<AccountResult> getFollowList(AccountResult result, Integer currentPage) {
36-
PageHelper.startPage(currentPage,24);
37-
List<AccountResult> list = baseMapper.getFollowList(result);
38-
return new PageInfo<>(list);
39-
40-
}
41-
42-
@Override
43-
public PageInfo<AccountResult> getFanList(AccountResult result,Integer currentPage) {
44-
PageHelper.startPage(currentPage,24);
45-
List<AccountResult> list = baseMapper.getFanList(result);
46-
return new PageInfo<>(list);
47-
}
48-
4934
@Override
5035
public Boolean updateFavorites(AccountResult result) {
5136
return baseMapper.updateFavorites(result)>0?true:false;

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

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

33
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
44
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5+
import com.github.pagehelper.PageHelper;
6+
import com.github.pagehelper.PageInfo;
57
import com.lzq.api.pojo.Account;
68
import com.lzq.api.service.AccountService;
79
import com.lzq.dubboservice.mapper.AccountMapper;
810
import org.apache.commons.lang.StringUtils;
911
import org.apache.dubbo.config.annotation.Service;
1012
import org.springframework.stereotype.Component;
1113

14+
import java.util.List;
15+
1216
/**
1317
* @author :LZQ
1418
* @description:AccountService实现类
@@ -32,19 +36,10 @@ public void insert(Account account) {
3236
}
3337

3438
@Override
35-
public Boolean update(Account account) throws NullPointerException {
39+
public Boolean update(Account account){
3640
QueryWrapper<Account> wrapper = new QueryWrapper<>();
3741
//当同时存在时则修改邮箱
38-
if (StringUtils.isNotBlank(account.getEmail())
39-
&& StringUtils.isNotBlank(account.getUsername())){
40-
wrapper.eq("username",account.getUsername());
41-
}else if (StringUtils.isNotBlank(account.getEmail())){
42-
wrapper.eq("email",account.getEmail());
43-
}else if (StringUtils.isNotBlank(account.getUsername())){
44-
wrapper.eq("username",account.getUsername());
45-
}else {
46-
throw new NullPointerException();
47-
}
42+
wrapper.eq("username",account.getUsername());
4843
return baseMapper.update(account,wrapper)>0?true:false;
4944
}
5045

@@ -109,5 +104,19 @@ public Boolean reduceRecycle(String username) {
109104
return baseMapper.reduceRecycle(username)>0?true:false;
110105
}
111106

107+
@Override
108+
public PageInfo<Account> getFollowList(Account result, Integer currentPage) {
109+
PageHelper.startPage(currentPage,24);
110+
List<Account> list = baseMapper.getFollowList(result);
111+
return new PageInfo<>(list);
112+
113+
}
114+
115+
@Override
116+
public PageInfo<Account> getFanList(Account result,Integer currentPage) {
117+
PageHelper.startPage(currentPage,24);
118+
List<Account> list = baseMapper.getFanList(result);
119+
return new PageInfo<>(list);
120+
}
112121

113122
}

springboot-dubbo-service/src/main/resources/mapper/AccoutMapper.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@
22
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
33
<mapper namespace="com.lzq.dubboservice.mapper.AccountMapper">
44

5+
<sql id="Account">
6+
a.username, name, user_picture
7+
</sql>
58

69
<update id="addFavorites">
710
update account set favorites=favorites+1 where username=#{username}
811
</update>
12+
913
<update id="updateFavorites">
1014
update account set favorites=#{favorites} where username=#{username}
1115
</update>
16+
1217
<update id="addWorks">
1318
update account set works=works+1 where username=#{username}
1419
</update>
20+
1521
<update id="reduceWorks">
1622
update account set works=works-1 where username=#{username}
1723
</update>
24+
1825
<update id="increaseRecycle">
1926
update account set recycle=recycle+1 where username=#{username}
2027
</update>
28+
2129
<update id="reduceRecycle">
2230
update account set recycle=recycle-1 where username=#{username}
2331
</update>
32+
2433
<update id="bindGit">
2534
update account
2635
<if test=" githubId != '' and githubId != null ">
@@ -31,4 +40,24 @@
3140
</if>
3241
where username=#{username}
3342
</update>
43+
44+
<select id="getFollowList" resultType="com.lzq.api.pojo.Account">
45+
select
46+
<include refid="Account"/>
47+
from account a left join follow b
48+
on
49+
a.username=b.follow_username
50+
where
51+
b.username=#{username}
52+
</select>
53+
54+
<select id="getFanList" resultType="com.lzq.api.pojo.Account">
55+
select
56+
<include refid="Account"/>
57+
from account a left join follow b
58+
on
59+
a.username=b.username
60+
where
61+
b.follow_username=#{username}
62+
</select>
3463
</mapper>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public class ExampleController {
7676
@ApiOperation("创建一个实例")
7777
public Map<String, Object> CreateFile(Example example, Content exampleContent, String content) {
7878
log.info("开始"+System.currentTimeMillis());
79-
String uuid = UUID.randomUUID().toString().replaceAll("-","");
79+
//生成22位uuid
80+
String uuid = ExampleUtils.getUUid();
8081
Boolean bol =false;
8182
//随机生成uuid
8283
//判断用户是保存实例还是第一次创建实例

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.lzq.web.utils.JWTUtils;
1111
import com.lzq.web.utils.ResultMapUtils;
1212
import com.lzq.web.utils.UserUtils;
13-
import com.lzq.web.utils.VerifyCodeUtils;
1413
import com.qiniu.util.Auth;
1514
import io.swagger.annotations.Api;
1615
import io.swagger.annotations.ApiOperation;
@@ -236,7 +235,7 @@ public Map<String, Object> modifyPossword(HttpServletRequest request, Account ac
236235
@GetMapping({"/send"})
237236
@ApiOperation("发送邮箱验证码")
238237
public Map<String, Object> sendEmail(String email) {
239-
String code = VerifyCodeUtils.getCode();
238+
String code = UserUtils.getCode();
240239
Mail mail = new Mail();
241240
mail.setTo(email);
242241
mail.setSubject("验证码");
@@ -362,5 +361,9 @@ public Map<String, Object> doLogin(HttpServletRequest request) {
362361
}
363362

364363

365-
364+
@GetMapping("/Test")
365+
public Map<String,Object> Test(String username){
366+
Account account = accountService.queryByUsername(username);
367+
return ResultMapUtils.ResultMap(true,0,account);
368+
}
366369
}

0 commit comments

Comments
 (0)