diff --git a/pom.xml b/pom.xml index 193e9a8..794d74f 100644 --- a/pom.xml +++ b/pom.xml @@ -151,4 +151,5 @@ + diff --git a/src/main/java/com/jryyy/forum/config/AliPayConfiguration.java b/src/main/java/com/jryyy/forum/config/AliPayConfiguration.java new file mode 100644 index 0000000..487c24d --- /dev/null +++ b/src/main/java/com/jryyy/forum/config/AliPayConfiguration.java @@ -0,0 +1,79 @@ +package com.jryyy.forum.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.io.FileWriter; +import java.io.IOException; + +/** + * @author OU + */ + +@Data +@Component +@ConfigurationProperties(prefix = "alipay") +public class AliPayConfiguration { + /** + * 日志地址,这里在d盘下要创建这个文件,不然会报错 + */ + private static String log_path = "C:/logs/"; + /** + * 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号 + */ + private String appID; + /**例:2016082600317257 + *商户私钥,您的PKCS8格式RSA2私钥 + */ + private String merchantPrivateKey; + /** + * 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm + * 对应APPID下的支付宝公钥。 + */ + private String alipayPublicKey ; + /** + * 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问 + * 返回的时候此页面不会返回到用户页面,只会执行你写到控制器里的地址 + */ + private String notifyUrl; + /** + * 签名方式 + */ + private String signType = "RSA2"; + /** + * 字符编码格式 + */ + private String charset = "utf-8"; + /** + * 支付宝网关 + */ + private String gatewayUrl; + private String sysServiceProviderId = "2088102180418544"; + + /** + * 写日志,方便测试(看网站需求,也可以改成把记录存入数据库) + * + * @param sWord + * 要写入日志里的文本内容 + */ + public static void logResult(String sWord) { + FileWriter writer = null; + try { + writer = new FileWriter(log_path + "alipay_log_" + + System.currentTimeMillis() + ".txt"); + writer.write(sWord); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/src/main/java/com/jryyy/forum/config/AlipayConfiguration.java b/src/main/java/com/jryyy/forum/config/AlipayConfiguration.java deleted file mode 100644 index 8319387..0000000 --- a/src/main/java/com/jryyy/forum/config/AlipayConfiguration.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.jryyy.forum.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import java.io.FileWriter; -import java.io.IOException; - -/** - * @author OU - */ - -@Data -@Component -@ConfigurationProperties(prefix = "alipay") -public class AlipayConfiguration { - - - - /** - * 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号 - */ - private String appID; - - /** - * 商户私钥,您的PKCS8格式RSA2私钥 - */ - private String merchantPrivateKey; - - /** - * 支付宝公钥 - */ - private String alipayPublicKey; - - /** - * 签名方式 - */ - private String signType="RSA2"; - - /** - * 网关 - */ - private String gatewayUrl="https://openapi.alipay.com/gateway.do"; - - /** - * 编码 - */ - private String charset= "utf-8"; - - /** - * 异步通知地址 - */ - private String notifyUrl=""; - - /** - * 类型 - */ - private String format="json"; - - /** - * 商户号 - */ - private String sysServiceProviderId="1234"; - - -} diff --git a/src/main/java/com/jryyy/forum/config/GlobalCorsConfiguration.java b/src/main/java/com/jryyy/forum/config/GlobalCorsConfiguration.java index 9e6397f..f6415c1 100644 --- a/src/main/java/com/jryyy/forum/config/GlobalCorsConfiguration.java +++ b/src/main/java/com/jryyy/forum/config/GlobalCorsConfiguration.java @@ -21,7 +21,7 @@ public CorsFilter corsFilter() { //放行哪些原始域 config.addAllowedOrigin("*"); //是否发送Cookie信息 - config.setAllowCredentials(true); + config.setAllowCredentials(false); //放行哪些原始域(请求方式) config.addAllowedMethod("*"); //放行哪些原始域(头部信息) diff --git a/src/main/java/com/jryyy/forum/config/interceptor/JwtInterceptor.java b/src/main/java/com/jryyy/forum/config/interceptor/JwtInterceptor.java index a0a952f..8057f4c 100644 --- a/src/main/java/com/jryyy/forum/config/interceptor/JwtInterceptor.java +++ b/src/main/java/com/jryyy/forum/config/interceptor/JwtInterceptor.java @@ -4,10 +4,7 @@ import com.jryyy.forum.constant.GlobalStatus; import com.jryyy.forum.exception.GlobalException; import com.jryyy.forum.model.User; -import com.jryyy.forum.utils.security.PassToken; -import com.jryyy.forum.utils.security.SecurityUtils; import com.jryyy.forum.utils.security.TokenUtils; - import com.jryyy.forum.utils.security.UserLoginToken; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/jryyy/forum/constant/Constants.java b/src/main/java/com/jryyy/forum/constant/Constants.java index 3fb47cf..56f727f 100644 --- a/src/main/java/com/jryyy/forum/constant/Constants.java +++ b/src/main/java/com/jryyy/forum/constant/Constants.java @@ -7,10 +7,14 @@ */ public class Constants { + public static final String file_url = "http://47.98.102.73:9896/upload/"; + public static final String USER_TOKEN_STRING = "Authorization"; public static final int MAXIMUM_NUMBER_ATTEMPTS = 6; public static final String DEFAULT = "0"; + public static final int TOTAL_WORDS = 3653; + } diff --git a/src/main/java/com/jryyy/forum/constant/GlobalStatus.java b/src/main/java/com/jryyy/forum/constant/GlobalStatus.java index 11614b3..8b6e2d1 100644 --- a/src/main/java/com/jryyy/forum/constant/GlobalStatus.java +++ b/src/main/java/com/jryyy/forum/constant/GlobalStatus.java @@ -50,7 +50,9 @@ public enum GlobalStatus { messageSendingFailed("消息发送失败"), userHasJoinedTheGroup("该用户已加入"), - userIsNotInAGroup("该用户不在群组"); + userIsNotInAGroup("该用户不在群组"), + + thesaurusIsNotApplied("未申请词库"); diff --git a/src/main/java/com/jryyy/forum/constant/KayOrUrl.java b/src/main/java/com/jryyy/forum/constant/KayOrUrl.java index a54ce95..0582839 100644 --- a/src/main/java/com/jryyy/forum/constant/KayOrUrl.java +++ b/src/main/java/com/jryyy/forum/constant/KayOrUrl.java @@ -1,10 +1,12 @@ package com.jryyy.forum.constant; /** - * * @author OU */ public class KayOrUrl { + public static String username(Integer userId) { + return String.format("DOU%d", userId); + } public static final String unchecked_messages_key = "unchecked_messages_list"; @@ -18,39 +20,68 @@ public class KayOrUrl { public static final String GROUP_CHAT_MESSAGE_KEY = "group_chat_message"; - public static String userKey(Integer key){ return String.format("key:%d",key); } + public static String userKey(Integer key) { + return String.format("key:%d", key); + } + + public static String userKey(String key) { + return String.format("key:%s", key); + } + + public static String userTokenKey(Integer key) { + return String.format("%d_token_key", key); + } + + public static String userTokenKey(String key) { + return String.format("%s_token_key", key); + } + + public static String modifyPasswordCodeKey(String key) { + return String.format("%s_password_key", key); + } - public static String userKey(String key){ return String.format("key:%s",key); } + public static String lockKey(String key) { + return String.format("%s_lock_key", key); + } - public static String userTokenKey(Integer key){ - return String.format("%d_token_key",key); + public static String lockKey(Integer key) { + return String.format("%d_lock_key", key); } - public static String userTokenKey(String key){ - return String.format("%s_token_key",key); + public static String registrationCodeKey(String key) { + return String.format("%s_registration_key", key); } - public static String modifyPasswordCodeKey(String key){ - return String.format("%s_password_key",key); + public static String userMessageKey(Integer toKey, Integer fromKey) { + return String.format("%d:%d", toKey, fromKey); } - public static String lockKey(String key){ - return String.format("%s_lock_key",key); + public static String groupMessageKey(Integer groupId) { + return String.format("Group:%d", groupId); } - public static String lockKey(Integer key){ - return String.format("%d_lock_key",key); + public static String unrecordedWordsKey(Integer userId) { + return String.format("unrecordedWordsKey:%d", userId); } - public static String registrationCodeKey(String key){return String.format("%s_registration_key",key); } + public static String memorizingWordsKey(Integer userId) { + return String.format("memorizingWordsKey:%d", userId); + } - public static String userMessageKey(Integer toKey,Integer fromKey){return String.format("%d:%d",toKey,fromKey);} + public static String memorizedWordsKey(Integer userId) { + return String.format("memorizedWords:%d", userId); + } - public static String groupMessageKey(Integer groupId){return String.format("Group:%d",groupId);} + public static String userAvatarUrl(Integer userId) { + return String.format("/user/%d/avatar/", userId); + } - public static String userAvatarUrl(Integer userId){return String.format("/user/%d/avatar/",userId);} + public static String userBgImgUrl(Integer userId) { + return String.format("/user/%d/bgImg/", userId); + } - public static String userBgImgUrl(Integer userId){return String.format("/user/%d/bgImg/",userId);} + public static String zoneImageUrl(Integer userId) { + return String.format("zone/image/%d/", userId); + } -public static String zoneImageUrl(Integer userId){return String.format("zone/image/%d/",userId);} } diff --git a/src/main/java/com/jryyy/forum/constant/WordWeight.java b/src/main/java/com/jryyy/forum/constant/WordWeight.java new file mode 100644 index 0000000..678cf0b --- /dev/null +++ b/src/main/java/com/jryyy/forum/constant/WordWeight.java @@ -0,0 +1,21 @@ +package com.jryyy.forum.constant; + +/** + * @author OU + */ +public class WordWeight { + + public static final int default_level_weighting = 0; + + public static final int one_level_weighting = 1; + + public static final int two_level_weighting = 2; + + public static final int three__level_weighting = 3; + + public static final int four__level_weighting = 4; + + public static final int FIVE_LEVEL_WEIGHTING = 5; + + public static final int SIX_LEVEL_WEIGHTING = 6; +} diff --git a/src/main/java/com/jryyy/forum/controller/AdminController.java b/src/main/java/com/jryyy/forum/controller/AdminController.java index cb17069..95ce1ee 100644 --- a/src/main/java/com/jryyy/forum/controller/AdminController.java +++ b/src/main/java/com/jryyy/forum/controller/AdminController.java @@ -1,23 +1,26 @@ package com.jryyy.forum.controller; -import com.jryyy.forum.utils.security.UserRoleCode; import com.jryyy.forum.model.Response; import com.jryyy.forum.service.AdminService; import com.jryyy.forum.utils.security.UserLoginToken; -import org.springframework.beans.factory.annotation.Autowired; +import com.jryyy.forum.utils.security.UserRoleCode; import org.springframework.web.bind.annotation.*; /** * 管理员控制层 * @author JrYYY */ + @RestController @RequestMapping("/admin") @UserLoginToken(role = UserRoleCode.ADMIN) public class AdminController { - @Autowired - AdminService adminService; + private final AdminService adminService; + + public AdminController(AdminService adminService) { + this.adminService = adminService; + } /** * 解锁用户 @@ -25,7 +28,6 @@ public class AdminController { */ @PutMapping("/{id}/unlock") public Response unlock(@PathVariable("id") long id) { - // userService.unlock(id); return new Response(); } @@ -34,7 +36,6 @@ public Response unlock(@PathVariable("id") long id) { * * @param id 用户id */ - @PutMapping("/{id}/lock/{day}") public Response lock(@PathVariable("id") long id, @PathVariable("day") int day) { // userService.lock(id); diff --git a/src/main/java/com/jryyy/forum/controller/AliPayController.java b/src/main/java/com/jryyy/forum/controller/AliPayController.java new file mode 100644 index 0000000..c2878a3 --- /dev/null +++ b/src/main/java/com/jryyy/forum/controller/AliPayController.java @@ -0,0 +1,24 @@ +package com.jryyy.forum.controller; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author OU + */ +@RestController +@RequestMapping("/pay") +public class AliPayController { + + + @PostMapping("/notify") + public void aliPayNotify(HttpServletRequest request, HttpServletResponse response) { + + } + + +} diff --git a/src/main/java/com/jryyy/forum/controller/FavoritesController.java b/src/main/java/com/jryyy/forum/controller/FavoritesController.java new file mode 100644 index 0000000..2af4a23 --- /dev/null +++ b/src/main/java/com/jryyy/forum/controller/FavoritesController.java @@ -0,0 +1,78 @@ +package com.jryyy.forum.controller; + +import com.jryyy.forum.model.Favorites; +import com.jryyy.forum.model.Response; +import com.jryyy.forum.service.FavoritesService; +import com.jryyy.forum.utils.security.UserLoginToken; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + * @author OU + */ +@RestController +@UserLoginToken +@RequestMapping("/favorites") +public class FavoritesController { + + private final FavoritesService favoritesService; + + public FavoritesController(FavoritesService favoritesService) { + this.favoritesService = favoritesService; + } + + /** + * 收藏 + * + * @param userId 用户id + * @param content 内容 + * @return {@link Response} + * @throws Exception + */ + @PostMapping("/{userId}") + public Response favorites(@PathVariable Integer userId, @ModelAttribute @Valid Favorites favorites) throws Exception { + favorites.setUserId(userId); + return favoritesService.favorites(favorites); + } + + /** + * 取消收藏 + * + * @param userId 用户id + * @param id id + * @return {@link Response} + * @throws Exception + */ + @DeleteMapping("/{userId}") + public Response cancelFavorites(@PathVariable Integer userId, @RequestParam Integer id) throws Exception { + return favoritesService.cancelFavorites(userId, id); + } + + /** + * 查询自己的收藏 + * + * @param userId 用户id + * @return {@link com.jryyy.forum.model.Favorites} + * @throws Exception + */ + @GetMapping("/{userId}") + public Response findFavorites(@PathVariable Integer userId) throws Exception { + return favoritesService.findFavorites(userId); + } + + /** + * 更改 + * + * @param userId 用户id + * @param id id + * @param content 内容 + * @return {@link Response} + * @throws Exception + */ + @PutMapping("/{userId}") + public Response updateFavorites(@PathVariable Integer userId, @ModelAttribute @Valid Favorites favorites) throws Exception { + favorites.setUserId(userId); + return favoritesService.updateFavorites(favorites); + } +} diff --git a/src/main/java/com/jryyy/forum/controller/WordController.java b/src/main/java/com/jryyy/forum/controller/WordController.java new file mode 100644 index 0000000..913ebf9 --- /dev/null +++ b/src/main/java/com/jryyy/forum/controller/WordController.java @@ -0,0 +1,38 @@ +package com.jryyy.forum.controller; + +import com.jryyy.forum.model.Response; +import com.jryyy.forum.service.WordService; +import com.jryyy.forum.utils.security.UserLoginToken; +import org.springframework.web.bind.annotation.*; + +/** + * @author OU + */ +@UserLoginToken +@RestController +@RequestMapping("/word") +public class WordController { + + private final WordService wordService; + + public WordController(WordService wordService) { + this.wordService = wordService; + } + + @GetMapping("/initialize/{userId}") + public Response initialize(@PathVariable Integer userId) throws Exception { + return wordService.getWordLibrary(userId); + } + + @GetMapping("/memory/{userId}") + public Response memory(@PathVariable Integer userId, Boolean know) throws Exception { + return wordService.memory(userId, know); + } + + @DeleteMapping("/remove/{userId}") + public Response remove(@PathVariable Integer userId) throws Exception { + return wordService.remove(userId); + } + + +} diff --git a/src/main/java/com/jryyy/forum/controller/ZoneController.java b/src/main/java/com/jryyy/forum/controller/ZoneController.java index 78cf203..c67fda2 100644 --- a/src/main/java/com/jryyy/forum/controller/ZoneController.java +++ b/src/main/java/com/jryyy/forum/controller/ZoneController.java @@ -6,8 +6,9 @@ import com.jryyy.forum.service.ZoneService; import com.jryyy.forum.utils.security.UserLoginToken; import org.springframework.web.bind.annotation.*; + import javax.validation.Valid; -import java.sql.ResultSet; + /** * @author OU @@ -46,7 +47,7 @@ public Response insertZone(@PathVariable Integer userId,@ModelAttribute @Valid Z @UserLoginToken @GetMapping("/{userId}") public Response getUserZone(@PathVariable Integer userId,@ModelAttribute @Valid GetZoneRequest request)throws Exception{ - return zoneService.getZone(userId,request); + return zoneService.viewSpace(userId, request); } /** diff --git a/src/main/java/com/jryyy/forum/dao/FavoritesMapper.java b/src/main/java/com/jryyy/forum/dao/FavoritesMapper.java index f39f83d..f8a92ce 100644 --- a/src/main/java/com/jryyy/forum/dao/FavoritesMapper.java +++ b/src/main/java/com/jryyy/forum/dao/FavoritesMapper.java @@ -1,18 +1,56 @@ package com.jryyy.forum.dao; -import org.apache.ibatis.annotations.Delete; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; +import com.jryyy.forum.model.Favorites; +import org.apache.ibatis.annotations.*; import java.util.List; +/** + * 收藏数据库操作 + * + * @author OU + */ @Mapper public interface FavoritesMapper { - @Insert("insert into favorites(userId,zoneId) values (#{userId},#{zoneId})") - void insertFavorites(int userId, int zoneId) throws Exception; + /** + * 插入 + * + * @param favorites {@link Favorites} + * @throws Exception + */ + @Insert("insert into favorites(userId,fromUserId,title,content,createDate,modifiedDate,route,extra) " + + "values (#{userId},#{fromUserId},#{title},#{content},now(),now(),#{route},#{extra})") + void insertFavorites(Favorites favorites) throws Exception; - @Delete("delete from favorites where id = #{id}") - void deleteById(int id) throws Exception; + /** + * 删除 + * + * @param userId 用户id + * @param id id + * @return 数量 + * @throws Exception + */ + @Delete("delete from favorites where id = #{id} and userId = #{userId}") + int deleteFavoritesById(int userId, int id) throws Exception; + + /** + * 查找 + * + * @param userId 用户id + * @return {@link Favorites} + * @throws Exception + */ + @Select("select id,fromUserId,title,content,createDate,modifiedDate,route,extra from favorites where userId = #{userId} order by createDate DESC") + List findFavoritesByUserId(Integer userId) throws Exception; + + /** + * 修改 + * + * @param favorites {@link Favorites } + * @return 修改改个数 + * @throws Exception + */ + @Update("update favorites set fromUserId = #{fromUserId},title = #{title},content = #{content},route = #{route},modifiedDate = now(),extra = #{extra} where userId = #{userId} and id = #{id}") + int updateFavoritesById(Favorites favorites) throws Exception; } diff --git a/src/main/java/com/jryyy/forum/dao/FollowMapper.java b/src/main/java/com/jryyy/forum/dao/FollowMapper.java index 240066a..e4ee74e 100644 --- a/src/main/java/com/jryyy/forum/dao/FollowMapper.java +++ b/src/main/java/com/jryyy/forum/dao/FollowMapper.java @@ -40,11 +40,8 @@ public interface FollowMapper { * @return {@link FollowResponse} * @throws Exception */ - @Select("select A.id,A.friendId userId,B.username,B.avatar,B.bio,A.createDate addDate,B.recentLoginDate " + - "from follow A join user_info B " + - "on A.friendId = B.userId " + - "where A.userId = #{userId}") - List findAttentionBasedOnId(@Param("userId") Integer userId) throws Exception; + @Select("select friendId from follow where userId = #{userId}") + List findAttentionBasedOnId(@Param("userId") Integer userId) throws Exception; /** * 查询粉丝列表 @@ -53,11 +50,8 @@ public interface FollowMapper { * @return {@link FollowResponse} * @throws Exception */ - @Select("select A.id,A.userId,B.username,B.avatar,B.bio,A.createDate addDate,B.recentLoginDate " + - "from follow A join user_info B " + - "on A.userId = B.userId " + - "where A.friendId = #{friendId}") - List findFansBasedOnId(@Param("friendId") Integer friendId) throws Exception; + @Select("select userId from follow where friendId = #{friendId}") + List findFansBasedOnId(@Param("friendId") Integer friendId) throws Exception; /** * 验证 diff --git a/src/main/java/com/jryyy/forum/dao/MessageMapper.java b/src/main/java/com/jryyy/forum/dao/MessageMapper.java index 318cc6f..c1d7ea3 100644 --- a/src/main/java/com/jryyy/forum/dao/MessageMapper.java +++ b/src/main/java/com/jryyy/forum/dao/MessageMapper.java @@ -61,7 +61,7 @@ public interface MessageMapper { * @return {@link Message} */ @Select("select fromId,toId,message,type,date from message_record " + - "where fromId = #{from} and toId = #{to} order by date limit 1") + "where fromId = #{from} and toId = #{to} order by date DESC limit 1") @Results({@Result(property = "date", column = "date", jdbcType = JdbcType.DATETIMEOFFSET)}) MessageRecord findMessageByDate(Integer from, Integer to); diff --git a/src/main/java/com/jryyy/forum/dao/ThesaurusMapper.java b/src/main/java/com/jryyy/forum/dao/ThesaurusMapper.java new file mode 100644 index 0000000..0e0db23 --- /dev/null +++ b/src/main/java/com/jryyy/forum/dao/ThesaurusMapper.java @@ -0,0 +1,38 @@ +package com.jryyy.forum.dao; + +import com.jryyy.forum.model.Word; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author OU + */ +@Mapper +public interface ThesaurusMapper { + + /** + * 随机获取n个单词 + * + * @param number 数量 + * @return {@link Word} + * @throws Exception + */ + @Select("select id,English,Chinese " + + "from thesaurus as r1 join " + + "(select round(rand() * (select max(id) from thesaurus)) as id2) as r2 " + + "where r1.id >= r2.id2 order by r1.id limit #{number}") + Word randomlyFindWord(Integer number) throws Exception; + + /** + * 查找所有单词 + * + * @return {@link Word} + * @throws Exception + */ + @Select("select id,English,Chinese from thesaurus") + List findAllWords() throws Exception; + + +} diff --git a/src/main/java/com/jryyy/forum/dao/UserInfoMapper.java b/src/main/java/com/jryyy/forum/dao/UserInfoMapper.java index 92340cd..87eb70f 100644 --- a/src/main/java/com/jryyy/forum/dao/UserInfoMapper.java +++ b/src/main/java/com/jryyy/forum/dao/UserInfoMapper.java @@ -18,6 +18,16 @@ @Mapper public interface UserInfoMapper { + /** + * 修改用户名(只能修改一次) + * + * @param userId 用户id + * @param username 用户名 + * @return 修改数量 + */ + @Update("update user_info set username = #{username} where userId = #{userId}") + int updateUsername(Integer userId, String username); + /** * 清除用户信息 * @@ -31,12 +41,12 @@ public interface UserInfoMapper { * 修改积分 * * @param userId 用户id - * @param integral 积分 + * @param credit 积分 * @return 修改数目 * @throws Exception */ - @Update("update user_info set integral = #{integral} where userId = #{userId}") - int updateIntegral(Integer userId, Integer integral) throws Exception; + @Update("update user_info set credit = #{credit} where userId = #{userId}") + int updateCredit(Integer userId, Integer credit) throws Exception; /** * 查看用户积分 @@ -45,8 +55,8 @@ public interface UserInfoMapper { * @return 积分 * @throws Exception */ - @Select("select integral from user_info where userId = #{userId}") - int findIntegralByUserId(Integer userId) throws Exception; + @Select("select credit from user_info where userId = #{userId}") + int findCreditByUserId(Integer userId) throws Exception; /** * 更改最近的登入 @@ -54,7 +64,7 @@ public interface UserInfoMapper { * @param dateTime 时间 * @param userId 用户id */ - @Update("update user_info set recentLoginDate = #{dateTime} where userId = #{userId}") + @Update("update user_info set recentLogin = #{dateTime} where userId = #{userId}") void updateRecentLoginDate(LocalDateTime dateTime, Integer userId); /** @@ -64,8 +74,9 @@ public interface UserInfoMapper { * @return {@link UserInfo} * @throws Exception */ - @Select("select userId,email,username,avatar,sex,age," + - "checkInDays,checkInDate,bio,continuousCheckInDays continuousDays,bgImg,integral " + + @Select("select userId,email,username,nickname,avatar,sex,age,email," + + "checkInDays,checkInDate,bio,continuousCheckInDays continuousDays," + + "bgImg,credit,recentLogin,recentState " + "from user_info where userId = #{id}") UserInfo selectUserInfo(@Param("id") int id) throws Exception; @@ -76,10 +87,10 @@ public interface UserInfoMapper { * @return {@link UserInfoResponse} * @throws Exception */ - @Select("select userId,username,email,bio,avatar from user_info " + - "where username like concat('%', #{value}, '%') " + - "or email like concat('%', #{value}, '%')" + - "or userId like concat('%', #{value}, '%')") + @Select("select userId,username,nickname,email,bio,avatar,recentLogin,recentState " + + "from user_info where username like concat('%', #{value}, '%') " + + "or email like concat('%', #{value}, '%') " + + "or nickname like concat('%', #{value}, '%')") List findInfoByCondition(String value) throws Exception; /** @@ -89,7 +100,8 @@ public interface UserInfoMapper { * @return {@link UserInfoResponse} * @throws Exception */ - @Select("select userId,username,email,bio,avatar from user_info where userId = #{userId}") + @Select("select userId,username,nickname,email,bio,avatar,recentLogin,recentState " + + "from user_info where userId = #{userId}") UserInfoResponse findInfoByUserId(Integer userId); /** @@ -97,10 +109,11 @@ public interface UserInfoMapper { * * @param id 用户id * @param email 邮箱 + * @param username 用户名称唯一键 * @throws Exception */ - @Insert("insert into user_info(userId,email,recentLoginDate) value (#{id},#{email},now())") - void insertUserInfo(int id, String email) throws Exception; + @Insert("insert into user_info(userId,nickname,username,email,checkInDate,recentLogin) value (#{id},'无名氏',#{username},#{email},now(),now())") + void insertUserInfo(int id, String username, String email) throws Exception; /** * 设置背景图片 @@ -130,10 +143,10 @@ public interface UserInfoMapper { * @return {@link Check} * @throws Exception */ - @Select("select checkInDays,checkInDate,continuousCheckInDays continuousDays from user_info where userId = #{id}") + @Select("select checkInDays,checkInDate,continuousCheckInDays continuousDays " + + "from user_info where userId = #{id}") Check selectCheckIn(@Param("id") int id) throws Exception; - /** * 签到 * @@ -157,16 +170,6 @@ void checkIn(@Param("userId") int userId, @Param("checkInDays") int checkInDays, @Update("update user_info set continuousCheckInDays = 0 where userId = #{userId}") void modifyContinuousCheckIn(int userId) throws Exception; - /** - * 删除(test) - * - * @param userId 用户id - * @throws Exception - */ - @Update("update user_info set checkInDate = null where userId =#{userId}") - void deleteCheckInDate(@Param("userId") int userId) throws Exception; - - /** * 更新用户信息 * @@ -176,7 +179,6 @@ void checkIn(@Param("userId") int userId, @Param("checkInDays") int checkInDays, @UpdateProvider(type = SqlProvider.class, method = "updatePersonSql") void updateUserInfo(UserInfoRequest userInfo) throws Exception; - /** * sql构造器构造动态sql */ @@ -184,8 +186,8 @@ class SqlProvider { public String updatePersonSql(UserInfoRequest userInfo) { return new SQL() {{ UPDATE("user_info"); - if (userInfo.getUsername() != null) { - SET("username = #{username}"); } + if (userInfo.getNickname() != null) { + SET("nickname = #{nickname}"); } if (userInfo.getSex() != null){ SET("sex = #{sex}");} if (userInfo.getAge() != null){ diff --git a/src/main/java/com/jryyy/forum/dao/UserMapper.java b/src/main/java/com/jryyy/forum/dao/UserMapper.java index 4f6d660..36143ec 100644 --- a/src/main/java/com/jryyy/forum/dao/UserMapper.java +++ b/src/main/java/com/jryyy/forum/dao/UserMapper.java @@ -24,6 +24,7 @@ public interface UserMapper { void deleteUser(int id) throws Exception; + /** * 查看所有用户 * @@ -55,9 +56,11 @@ public interface UserMapper { * @return {@link User} * @throws Exception */ - @Select("select id,emailName,password,role,status,loginFailedAttemptCount from user where emailName = #{name}") + @Select("select A.id,A.emailName,A.password,A.role,A.status,A.loginFailedAttemptCount " + + "from user A join user_info B on A.id = B.userId " + + "where A.emailName = #{name} or B.username = #{name}") @Results({@Result(property = "status", column = "status", jdbcType = JdbcType.BIT)}) - User findLoginByName(@Param("name") String name) throws Exception; + User findUserByName(@Param("name") String name) throws Exception; /** * 根据name查询id diff --git a/src/main/java/com/jryyy/forum/dao/ZoneMapper.java b/src/main/java/com/jryyy/forum/dao/ZoneMapper.java index ffd550c..5656af8 100644 --- a/src/main/java/com/jryyy/forum/dao/ZoneMapper.java +++ b/src/main/java/com/jryyy/forum/dao/ZoneMapper.java @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.*; import org.apache.ibatis.jdbc.SQL; -import java.lang.reflect.Field; import java.util.List; /** @@ -56,6 +55,17 @@ public interface ZoneMapper { @Select("select id,userId,msg,createDate date,msgType,praise from user_zone where id = #{id}") Zone findZoneById(@Param("id") int id) throws Exception; + /** + * 单独查询 + * + * @param id id + * @return {@link ZoneResponse} + * @throws Exception + */ + @Select("select id,userId,msg,createDate date,msgType,praise from user_zone where id > #{id}") + List findNewZone(@Param("id") int id) throws Exception; + + /** * 写说说 * @@ -95,12 +105,12 @@ public interface ZoneMapper { /** * 删除单个图片 - * + * @param userId 用户id * @param id id * @throws Exception */ - @Delete("delete from zone_img where id = #{id}") - void deleteZoneImgById(@Param("id") Integer id) throws Exception; + @Delete("delete from zone_img where id = #{id} and userId = #{userId}") + int deleteZoneImgById(Integer userId, @Param("id") Integer id) throws Exception; /** * 查询单个空间所有图片 @@ -115,7 +125,6 @@ public interface ZoneMapper { * 添加图片 * * @param zoneImg {@link ZoneImg} - * @throws Exception */ @Insert("insert into zone_img(zoneId,imgUrl,width,height,dominantColor) values (#{zoneId},#{imgUrl},#{width},#{height},#{dominantColor})") void insertZoneImg(ZoneImg zoneImg); diff --git a/src/main/java/com/jryyy/forum/dao/ZonePraiseMapper.java b/src/main/java/com/jryyy/forum/dao/ZonePraiseMapper.java index 23042ab..1a1c762 100644 --- a/src/main/java/com/jryyy/forum/dao/ZonePraiseMapper.java +++ b/src/main/java/com/jryyy/forum/dao/ZonePraiseMapper.java @@ -62,6 +62,16 @@ public interface ZonePraiseMapper { @Select("select count(*) from zone_praise where zoneId = #{zoneId}") int countZonePraise(int zoneId) throws Exception; + /** + * 更具用户id统计 + * + * @param userId 用户id + * @return 统计数量 + * @throws Exception + */ + @Select("select count(*) from zone_praise where userId = #{userId}") + int countByUserId(Integer userId) throws Exception; + /** * 是否点赞 * @param userId 用户id diff --git a/src/main/java/com/jryyy/forum/exception/GlobalExceptionHandler.java b/src/main/java/com/jryyy/forum/exception/GlobalExceptionHandler.java index 6d50d18..e3f50f6 100644 --- a/src/main/java/com/jryyy/forum/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/jryyy/forum/exception/GlobalExceptionHandler.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.jryyy.forum.constant.GlobalStatus; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.http.HttpHeaders; @@ -27,7 +28,9 @@ /** * 将异常解析为json + * @author JrYYY */ +@Slf4j @RestControllerAdvice public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { @@ -45,6 +48,7 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { private static ResponseEntity buildErrorResponse(HttpStatus status, String message) { Map responseBody = new HashMap<>(); responseBody.put("message", message); + log.error(message); return new ResponseEntity<>(responseBody, status); } @@ -56,6 +60,7 @@ private static ResponseEntity buildErrorResponse(HttpStatus status, Stri private static ResponseEntity buildErrorResponse(GlobalStatus s) { Map responseBody = new HashMap<>(); responseBody.put("message", s.getMsg()); + log.error(s.getMsg()); return new ResponseEntity<>(responseBody, HttpStatus.BAD_REQUEST); } @@ -72,7 +77,7 @@ private Object globalException(GlobalException e) { * @return {@link ResponseEntity} */ @ExceptionHandler(IllegalArgumentException.class) - public Object IllegalArgumentException(IllegalArgumentException e) { + public Object illegalArgumentException(IllegalArgumentException e) { return buildErrorResponse(HttpStatus.BAD_REQUEST, e.getMessage()); } diff --git a/src/main/java/com/jryyy/forum/model/Favorites.java b/src/main/java/com/jryyy/forum/model/Favorites.java index 18b63e5..d0bcbbe 100644 --- a/src/main/java/com/jryyy/forum/model/Favorites.java +++ b/src/main/java/com/jryyy/forum/model/Favorites.java @@ -1,9 +1,13 @@ package com.jryyy.forum.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + /** * 收藏 * @author JrYYY @@ -20,10 +24,40 @@ public class Favorites { /** * 用户id */ + @JsonIgnore private Integer userId; + @NotNull(message = "来源用户id不能为空") + private Integer fromUserId; + + /** + * 标题 + */ + private String title; + + /** + * 类容 + */ + @NotNull(message = "内容不能为空") + private String content; + + /** + * 创建时间 + */ + private LocalDateTime createDate; + + /** + * 更改时间 + */ + private LocalDateTime modifiedDate; + + /** + * 路由 + */ + private String route; + /** - * 动态id + * 配置信息 */ - private Integer zoneId; + private String extra; } diff --git a/src/main/java/com/jryyy/forum/model/UserInfo.java b/src/main/java/com/jryyy/forum/model/UserInfo.java index 6b0bdcc..7a328e8 100644 --- a/src/main/java/com/jryyy/forum/model/UserInfo.java +++ b/src/main/java/com/jryyy/forum/model/UserInfo.java @@ -1,12 +1,11 @@ package com.jryyy.forum.model; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.sql.Date; import java.time.LocalDate; +import java.time.LocalDateTime; /** * 用户信息类 @@ -27,6 +26,11 @@ public class UserInfo { */ private String username; + /** + * 昵称 + */ + private String nickname; + /** * 图像 */ @@ -42,13 +46,18 @@ public class UserInfo { */ private Integer age; + /** + * 邮箱 + */ + private String email; + /** * 签到天数 */ private int checkInDays; /** - * 最近签到时间 + * 最近签到日期 */ private LocalDate checkInDate; @@ -57,6 +66,17 @@ public class UserInfo { */ private String bio; + /** + * 最近登入时间 + */ + private LocalDateTime recentLogin; + + /** + * 最近状态 + */ + private String recentState; + + /** * 联系签到天数 */ @@ -70,5 +90,20 @@ public class UserInfo { /** * 积分 */ - private Integer integral; + private Integer credit; + + /** + * 追随者数量 + */ + private Integer followers; + + /** + * 关注数量 + */ + private Integer following; + + /** + * 喜欢的动态数量 + */ + private Integer likes; } diff --git a/src/main/java/com/jryyy/forum/model/request/ForgotUsernamePasswordRequest.java b/src/main/java/com/jryyy/forum/model/request/ForgotUsernamePasswordRequest.java index b897580..dd56c25 100644 --- a/src/main/java/com/jryyy/forum/model/request/ForgotUsernamePasswordRequest.java +++ b/src/main/java/com/jryyy/forum/model/request/ForgotUsernamePasswordRequest.java @@ -46,7 +46,7 @@ public class ForgotUsernamePasswordRequest { * @param userMapper {@link UserMapper} */ public ForgotUsernamePasswordRequest userDoesNotExist(UserMapper userMapper) throws Exception { - if (userMapper.findLoginByName(this.name) == null) { + if (userMapper.findUserByName(this.name) == null) { throw new GlobalException(GlobalStatus.userDoesNotExist); } return this; diff --git a/src/main/java/com/jryyy/forum/model/request/UserInfoRequest.java b/src/main/java/com/jryyy/forum/model/request/UserInfoRequest.java index 3fc6cca..44e394c 100644 --- a/src/main/java/com/jryyy/forum/model/request/UserInfoRequest.java +++ b/src/main/java/com/jryyy/forum/model/request/UserInfoRequest.java @@ -5,9 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.Max; import javax.validation.constraints.Min; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; /** @@ -24,9 +22,7 @@ public class UserInfoRequest { private Integer userId; - @Pattern(regexp = USERNAME_REGULAR, message = "用户名输入不规范") - private String username; - + private String nickname; private String sex; diff --git a/src/main/java/com/jryyy/forum/model/request/UserRequest.java b/src/main/java/com/jryyy/forum/model/request/UserRequest.java index 5a2586c..8690f98 100644 --- a/src/main/java/com/jryyy/forum/model/request/UserRequest.java +++ b/src/main/java/com/jryyy/forum/model/request/UserRequest.java @@ -10,14 +10,13 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; /** * 用户请求类型 * - * @User JrYYY + * @author JrYYY */ @Data @AllArgsConstructor @@ -27,7 +26,6 @@ public class UserRequest { @NotBlank(message = "用户名不能为空") - @Email(message = "请输入正确的邮箱") private String name; @NotBlank(message = "密码不能为空") @@ -40,7 +38,7 @@ public class UserRequest { * @param userMapper {@link UserMapper} */ public User verifyUserLogin(UserMapper userMapper) throws Exception { - User user = userMapper.findLoginByName(this.name); + User user = userMapper.findUserByName(this.name); if (!user.getPassword().equals(this.pwd)) { if (user.getLoginFailedAttemptCount() < Constants.MAXIMUM_NUMBER_ATTEMPTS) { userMapper.updateLoginFailedAttemptCount(user.getId(), user.getLoginFailedAttemptCount() + 1); @@ -58,7 +56,7 @@ public User verifyUserLogin(UserMapper userMapper) throws Exception { * @param userMapper {@link UserMapper} */ public void userDoesNotExist(UserMapper userMapper) throws Exception { - if (userMapper.findLoginByName(this.name) == null) + if (userMapper.findUserByName(this.name) == null) throw new GlobalException(GlobalStatus.userDoesNotExist); } diff --git a/src/main/java/com/jryyy/forum/model/request/UserRequestAccessRequest.java b/src/main/java/com/jryyy/forum/model/request/UserRequestAccessRequest.java index 8f180bb..1943a75 100644 --- a/src/main/java/com/jryyy/forum/model/request/UserRequestAccessRequest.java +++ b/src/main/java/com/jryyy/forum/model/request/UserRequestAccessRequest.java @@ -2,10 +2,10 @@ import com.jryyy.forum.constant.GlobalStatus; import com.jryyy.forum.constant.KayOrUrl; -import com.jryyy.forum.utils.security.UserRoleCode; import com.jryyy.forum.dao.UserMapper; import com.jryyy.forum.exception.GlobalException; import com.jryyy.forum.model.User; +import com.jryyy.forum.utils.security.UserRoleCode; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -51,7 +51,7 @@ public User toUser() { * @param userMapper {@link UserMapper} */ public void verifyUserRegistered(UserMapper userMapper) throws Exception { - if (userMapper.findLoginByName(this.name) != null) + if (userMapper.findUserByName(this.name) != null) throw new GlobalException(GlobalStatus.userAlreadyExists); } diff --git a/src/main/java/com/jryyy/forum/model/request/ZoneRequest.java b/src/main/java/com/jryyy/forum/model/request/ZoneRequest.java index c76da6a..7f0f3a4 100644 --- a/src/main/java/com/jryyy/forum/model/request/ZoneRequest.java +++ b/src/main/java/com/jryyy/forum/model/request/ZoneRequest.java @@ -5,11 +5,12 @@ import com.jryyy.forum.exception.GlobalException; import com.jryyy.forum.model.Zone; import com.jryyy.forum.model.ZoneImg; -import com.jryyy.forum.utils.ImageUtils; import com.jryyy.forum.utils.FileUtils; +import com.jryyy.forum.utils.ImageUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; @@ -22,12 +23,14 @@ /** * 空间请求类 + * * @author JrYYY */ +@Slf4j @Data @NoArgsConstructor @AllArgsConstructor -public class ZoneRequest { +public class ZoneRequest { /** * 用户id @@ -46,7 +49,7 @@ public class ZoneRequest { private MultipartFile[] files; - public Zone getZone() throws Exception{ + public Zone getZone() throws Exception { int msgType = 0; if (this.msg != null && this.files == null) { msgType = 1; @@ -54,7 +57,7 @@ public Zone getZone() throws Exception{ if (this.files != null && this.msg == null) { msgType = 2; } - if(this.files == null && this.msg == null) { + if (this.files == null && this.msg == null) { throw new GlobalException(GlobalStatus.noContent); } return Zone.builder().userId(this.userId).msg(this.msg).msgType(msgType).build(); diff --git a/src/main/java/com/jryyy/forum/model/response/FavoritesResponse.java b/src/main/java/com/jryyy/forum/model/response/FavoritesResponse.java new file mode 100644 index 0000000..0fc1f0f --- /dev/null +++ b/src/main/java/com/jryyy/forum/model/response/FavoritesResponse.java @@ -0,0 +1,76 @@ +package com.jryyy.forum.model.response; + + +import com.jryyy.forum.model.Favorites; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * 收藏夹响应 + * + * @author JrYYY + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class FavoritesResponse { + /** + * id + */ + private Integer id; + + + /** + * 标题 + */ + private String title; + + /** + * 类容 + */ + private String content; + + /** + * 创建时间 + */ + private LocalDateTime createDate; + + /** + * 更改时间 + */ + private LocalDateTime modifiedDate; + + /** + * 路由 + */ + private String route; + + /** + * 配置信息 + */ + private String extra; + + /** + * 用户信息 + * {@link UserInfoResponse} + */ + private UserInfoResponse userInfo; + + public static FavoritesResponse favoritesResponse(Favorites favorites) { + return FavoritesResponse.builder() + .id(favorites.getId()) + .title(favorites.getTitle()) + .content(favorites.getContent()) + .route(favorites.getRoute()) + .extra(favorites.getExtra()) + .createDate(favorites.getCreateDate()) + .modifiedDate(favorites.getModifiedDate()) + .build(); + } + +} diff --git a/src/main/java/com/jryyy/forum/model/response/UserInfoResponse.java b/src/main/java/com/jryyy/forum/model/response/UserInfoResponse.java index b53fe9c..d486c82 100644 --- a/src/main/java/com/jryyy/forum/model/response/UserInfoResponse.java +++ b/src/main/java/com/jryyy/forum/model/response/UserInfoResponse.java @@ -1,11 +1,12 @@ package com.jryyy.forum.model.response; import com.jryyy.forum.constant.Constants; +import com.jryyy.forum.dao.UserInfoMapper; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; + +import java.time.LocalDateTime; /** @@ -25,6 +26,11 @@ public class UserInfoResponse { */ private String username; + /** + * 昵称 + */ + private String nickname; + /** * 邮箱 */ @@ -40,6 +46,16 @@ public class UserInfoResponse { */ private String avatar; + /** + * 最近登入时间 + */ + private LocalDateTime recentLogin; + + /** + * 最近状态 + */ + private String recentState; + public void addAvatarUrl(String url){ if(!this.avatar.equals(Constants.DEFAULT)) { @@ -47,4 +63,10 @@ public void addAvatarUrl(String url){ } } + public static UserInfoResponse userInfoResponse(UserInfoMapper userInfoMapper, Integer userId, String fileUrl) { + UserInfoResponse userInfo = userInfoMapper.findInfoByUserId(userId); + userInfo.addAvatarUrl(fileUrl); + return userInfo; + } + } diff --git a/src/main/java/com/jryyy/forum/service/AliPayService.java b/src/main/java/com/jryyy/forum/service/AliPayService.java new file mode 100644 index 0000000..d0f8da5 --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/AliPayService.java @@ -0,0 +1,45 @@ +package com.jryyy.forum.service; + +import com.alipay.api.AlipayApiException; +import com.jryyy.forum.model.Response; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +/** + * @author OU + */ +public interface AliPayService { + /** + * @param orderNo: 订单编号 + * @param amount: 实际支付金额 + * @param body: 订单描述 + * @return 订单 + * @throws AlipayApiException {@link AlipayApiException} + * @Description: 创建支付宝订单 + */ + String createOrder(String orderNo, double amount, String body) throws AlipayApiException; + + /** + * @param tradeStatus: 支付宝交易状态 + * @param orderNo: 订单编号 + * @param tradeNo: 支付宝订单号 + * @Description: + */ + boolean notify(String tradeStatus, String orderNo, String tradeNo); + + /** + * @param request {@link HttpServletResponse} + * @Description: 校验签名 + */ + boolean rsaCheckV1(HttpServletRequest request); + + /** + * @param orderNo: 订单编号 + * @param amount: 实际支付金额 + * @param refundReason: 退款原因 + * @Description: 退款 + */ + Response refund(String orderNo, double amount, String refundReason); +} diff --git a/src/main/java/com/jryyy/forum/service/FavoritesService.java b/src/main/java/com/jryyy/forum/service/FavoritesService.java new file mode 100644 index 0000000..8471c14 --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/FavoritesService.java @@ -0,0 +1,47 @@ +package com.jryyy.forum.service; + +import com.jryyy.forum.model.Favorites; +import com.jryyy.forum.model.Response; + +/** + * @author OU + */ +public interface FavoritesService { + + /** + * 收藏 + * + * @param favorites {@link Response} + * @return {@link Response} + * @throws Exception + */ + Response favorites(Favorites favorites) throws Exception; + + /** + * 取消收藏 + * + * @param userId 用户id + * @param id id + * @return {@link Response} + * @throws Exception + */ + Response cancelFavorites(Integer userId, Integer id) throws Exception; + + /** + * 查询自己的收藏 + * + * @param userId 用户id + * @return {@link com.jryyy.forum.model.Favorites} + * @throws Exception + */ + Response findFavorites(Integer userId) throws Exception; + + /** + * 修改 + * + * @param favorites {@link Favorites} + * @return 数量 + * @throws Exception + */ + Response updateFavorites(Favorites favorites) throws Exception; +} diff --git a/src/main/java/com/jryyy/forum/service/IntegralService.java b/src/main/java/com/jryyy/forum/service/IntegralService.java index 531e226..c63041f 100644 --- a/src/main/java/com/jryyy/forum/service/IntegralService.java +++ b/src/main/java/com/jryyy/forum/service/IntegralService.java @@ -1,8 +1,13 @@ package com.jryyy.forum.service; +import com.jryyy.forum.model.Response; + /** * @author OU */ public interface IntegralService { + Response buyPointsToPlaceAnOrder() throws Exception; + +// Response } diff --git a/src/main/java/com/jryyy/forum/service/UserInfoService.java b/src/main/java/com/jryyy/forum/service/UserInfoService.java index 68f632b..fb0df04 100644 --- a/src/main/java/com/jryyy/forum/service/UserInfoService.java +++ b/src/main/java/com/jryyy/forum/service/UserInfoService.java @@ -2,7 +2,6 @@ import com.jryyy.forum.model.Response; import com.jryyy.forum.model.request.UserInfoRequest; -import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; /** @@ -44,14 +43,24 @@ public interface UserInfoService { Response updateAvatar(Integer userId, MultipartFile avatar)throws Exception; /** - * - * @param userId - * @param bgImg - * @return + *修改用户背景 + * @param userId 用户id + * @param bgImg 头像 + * @return {@link Response} * @throws Exception */ Response updateBgImg(Integer userId,MultipartFile bgImg)throws Exception; + /** + * 修改用户背景(只能修改一次) + * + * @param userId 用户id + * @param username 用户名称 + * @return {@link Response} + * @throws Exception + */ + Response updateUsername(Integer userId, String username) throws Exception; + /** * 签到 * @param userId 用户id diff --git a/src/main/java/com/jryyy/forum/service/WordService.java b/src/main/java/com/jryyy/forum/service/WordService.java new file mode 100644 index 0000000..f43261a --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/WordService.java @@ -0,0 +1,48 @@ +package com.jryyy.forum.service; + +import com.jryyy.forum.model.Response; + +/** + * 记忆单词服务 + * + * @author JrYYY + */ +public interface WordService { + + /** + * 获取单词库 + * + * @param userId 用户 + * @return {@link Response} + * @throws Exception + */ + Response getWordLibrary(Integer userId) throws Exception; + + /** + * 记忆 + * + * @param userId 用户id + * @param understanding 认识 + * @return {@link com.jryyy.forum.model.Word} + * @throws Exception + */ + Response memory(Integer userId, Boolean understanding) throws Exception; + + /** + * 复习 + * + * @param userId 用户id + * @return {@link Response} + * @throws Exception + */ + Response review(Integer userId) throws Exception; + + /** + * 清除 + * + * @param userId 用户id + * @return {@link Response} + * @throws Exception + */ + Response remove(Integer userId) throws Exception; +} diff --git a/src/main/java/com/jryyy/forum/service/ZoneService.java b/src/main/java/com/jryyy/forum/service/ZoneService.java index c866dc0..6943218 100644 --- a/src/main/java/com/jryyy/forum/service/ZoneService.java +++ b/src/main/java/com/jryyy/forum/service/ZoneService.java @@ -24,7 +24,14 @@ public interface ZoneService { * @return {@link com.jryyy.forum.model.response.ZoneResponse} * @throws Exception */ - Response getZone(Integer userId,GetZoneRequest request)throws Exception; + Response viewSpace(Integer userId, GetZoneRequest request) throws Exception; + + /** + * @param id id + * @return {@link com.jryyy.forum.model.response.ZoneResponse} + * @throws Exception + */ + Response viewUpdateSpace(Integer id) throws Exception; /** * 删除空间 diff --git a/src/main/java/com/jryyy/forum/service/imp/AliPayServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/AliPayServiceImpl.java new file mode 100644 index 0000000..5a141a4 --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/imp/AliPayServiceImpl.java @@ -0,0 +1,89 @@ +package com.jryyy.forum.service.imp; + +import com.alipay.api.AlipayApiException; +import com.alipay.api.domain.AlipayTradeAppPayModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.AlipayTradeAppPayRequest; +import com.alipay.api.response.AlipayTradeAppPayResponse; +import com.jryyy.forum.config.AliPayConfiguration; +import com.jryyy.forum.model.Response; +import com.jryyy.forum.service.AliPayService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * @author OU + */ +@Slf4j +@Service +public class AliPayServiceImpl implements AliPayService { + + private final AliPayConfiguration aliPayConfig; + + public AliPayServiceImpl(AliPayConfiguration aliPayConfig) { + this.aliPayConfig = aliPayConfig; + } + + @Override + public String createOrder(String orderNo, double amount, String body) throws AlipayApiException { + //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 + AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); + model.setSubject(body); + model.setOutTradeNo(orderNo); + model.setTotalAmount(String.valueOf(amount)); + model.setProductCode("QUICK_MSECURITY_PAY"); + model.setPassbackParams("公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数"); + + //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay + AlipayTradeAppPayRequest ali_request = new AlipayTradeAppPayRequest(); + ali_request.setBizModel(model); + ali_request.setNotifyUrl(aliPayConfig.getNotifyUrl());// 回调地址 + AlipayTradeAppPayResponse ali_response = aliPayConfig.sdkExecute(ali_request); + //就是orderString 可以直接给客户端请求,无需再做处理。 + return ali_response.getBody(); + } + + @Override + public boolean notify(String tradeStatus, String orderNo, String tradeNo) { + if ("TRADE_FINISHED".equals(tradeStatus) || "TRADE_SUCCESS".equals(tradeStatus)) { +// // 支付成功,根据业务逻辑修改相应数据的状态 +// boolean state = orderPaymentService.updatePaymentState(orderNo, tradeNo); +// if (state) { +// return true; +// } + } + return false; + } + + @Override + public boolean rsaCheckV1(HttpServletRequest request) { + try { + Map params = new HashMap<>(); + Map requestParams = request.getParameterMap(); + for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { + String name = (String) iter.next(); + String[] values = requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ","; + } + params.put(name, valueStr); + } + + boolean verifyResult = AlipaySignature.rsaCheckV1(params, aliPayConfig.getAlipayPublicKey(), aliPayConfig.getCharset(), alipayConfig.getSignType()); + return verifyResult; + } catch (AlipayApiException e) { + return false; + } + } + + @Override + public Response refund(String orderNo, double amount, String refundReason) { + return null; + } +} diff --git a/src/main/java/com/jryyy/forum/service/imp/BindingServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/BindingServiceImpl.java index d6e94d2..c097aa5 100644 --- a/src/main/java/com/jryyy/forum/service/imp/BindingServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/BindingServiceImpl.java @@ -1,7 +1,6 @@ package com.jryyy.forum.service.imp; import com.jryyy.forum.constant.GlobalStatus; -import com.jryyy.forum.utils.security.UserRoleCode; import com.jryyy.forum.dao.BindingMapper; import com.jryyy.forum.dao.UserMapper; import com.jryyy.forum.exception.GlobalException; @@ -9,22 +8,27 @@ import com.jryyy.forum.model.Response; import com.jryyy.forum.model.response.BindingResponse; import com.jryyy.forum.service.BindingService; -import org.springframework.beans.factory.annotation.Autowired; +import com.jryyy.forum.utils.security.UserRoleCode; import org.springframework.stereotype.Service; import java.util.List; /** + * @author OU * @see com.jryyy.forum.service.BindingService */ @Service("BindingService") public class BindingServiceImpl implements BindingService { - @Autowired - BindingMapper bindingMapper; - @Autowired - UserMapper userMapper; + private final BindingMapper bindingMapper; + + private final UserMapper userMapper; + + public BindingServiceImpl(BindingMapper bindingMapper, UserMapper userMapper) { + this.bindingMapper = bindingMapper; + this.userMapper = userMapper; + } @Override public Response queryAllAssociatedUsers(int userId) throws Exception { diff --git a/src/main/java/com/jryyy/forum/service/imp/FavoritesServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/FavoritesServiceImpl.java new file mode 100644 index 0000000..7190c14 --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/imp/FavoritesServiceImpl.java @@ -0,0 +1,70 @@ +package com.jryyy.forum.service.imp; + +import com.jryyy.forum.constant.GlobalStatus; +import com.jryyy.forum.dao.FavoritesMapper; +import com.jryyy.forum.dao.UserInfoMapper; +import com.jryyy.forum.exception.GlobalException; +import com.jryyy.forum.model.Favorites; +import com.jryyy.forum.model.Response; +import com.jryyy.forum.model.response.FavoritesResponse; +import com.jryyy.forum.model.response.UserInfoResponse; +import com.jryyy.forum.service.FavoritesService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author OU + */ +@Service +public class FavoritesServiceImpl implements FavoritesService { + + private final FavoritesMapper favoritesMapper; + + private final UserInfoMapper userInfoMapper; + + @Value("${file.url}") + private String fileUrl; + + public FavoritesServiceImpl(FavoritesMapper favoritesMapper, UserInfoMapper userInfoMapper) { + this.favoritesMapper = favoritesMapper; + this.userInfoMapper = userInfoMapper; + } + + @Override + public Response favorites(Favorites favorites) throws Exception { + favoritesMapper.insertFavorites(favorites); + return new Response(); + } + + @Override + public Response cancelFavorites(Integer userId, Integer id) throws Exception { + if (favoritesMapper.deleteFavoritesById(userId, id) < 1) { + throw new GlobalException(GlobalStatus.unauthorizedAccess); + } + return new Response(); + } + + @Override + public Response findFavorites(Integer userId) throws Exception { + List favorites = favoritesMapper.findFavoritesByUserId(userId); + List responses = new ArrayList<>(); + favorites.forEach(o -> { + FavoritesResponse response = FavoritesResponse.favoritesResponse(o); + response.setUserInfo(UserInfoResponse. + userInfoResponse(userInfoMapper, o.getFromUserId(), fileUrl)); + responses.add(response); + }); + return new Response<>(responses); + } + + @Override + public Response updateFavorites(Favorites favorites) throws Exception { + if (favoritesMapper.updateFavoritesById(favorites) < 1) { + throw new GlobalException(GlobalStatus.unauthorizedAccess); + } + return new Response(); + } +} diff --git a/src/main/java/com/jryyy/forum/service/imp/FollowServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/FollowServiceImpl.java index fa2246b..e58ede7 100644 --- a/src/main/java/com/jryyy/forum/service/imp/FollowServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/FollowServiceImpl.java @@ -2,16 +2,18 @@ import com.jryyy.forum.constant.GlobalStatus; import com.jryyy.forum.dao.FollowMapper; +import com.jryyy.forum.dao.UserInfoMapper; import com.jryyy.forum.dao.UserMapper; import com.jryyy.forum.exception.GlobalException; import com.jryyy.forum.model.Response; import com.jryyy.forum.model.User; import com.jryyy.forum.model.UserFollow; -import com.jryyy.forum.model.response.FollowResponse; +import com.jryyy.forum.model.response.UserInfoResponse; import com.jryyy.forum.service.FollowService; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -25,21 +27,25 @@ public class FollowServiceImpl implements FollowService { private final UserMapper userMapper; + private final UserInfoMapper userInfoMapper; + private static final String DEFAULT = "0"; @Value("${file.url}") private String fileUrl; - public FollowServiceImpl(FollowMapper followMapper, UserMapper userMapper) { + public FollowServiceImpl(FollowMapper followMapper, UserMapper userMapper, UserInfoMapper userInfoMapper) { this.followMapper = followMapper; + this.userInfoMapper = userInfoMapper; this.userMapper = userMapper; } @Override public Response viewWatchlist(int userId) throws Exception { try { - List responses = followMapper.findAttentionBasedOnId(userId); - responses.forEach(o-> {if(!o.getAvatar().equals(DEFAULT)){o.setAvatar(fileUrl + o.getAvatar());}}); + List responses = new ArrayList<>(); + List follow = followMapper.findAttentionBasedOnId(userId); + follow.forEach(o -> responses.add(UserInfoResponse.userInfoResponse(userInfoMapper, o, fileUrl))); return new Response<>(responses); } catch (Exception e) { e.printStackTrace(); @@ -50,8 +56,9 @@ public Response viewWatchlist(int userId) throws Exception { @Override public Response viewFanList(int fenId) throws Exception { try { - List responses = followMapper.findFansBasedOnId(fenId); - responses.forEach(o-> {if(!o.getAvatar().equals(DEFAULT)){o.setAvatar(fileUrl + o.getAvatar());}}); + List responses = new ArrayList<>(); + List follow = followMapper.findFansBasedOnId(fenId); + follow.forEach(o -> responses.add(UserInfoResponse.userInfoResponse(userInfoMapper, o, fileUrl))); return new Response<>(responses); } catch (Exception e) { throw new GlobalException(GlobalStatus.serverError); diff --git a/src/main/java/com/jryyy/forum/service/imp/MessageServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/MessageServiceImpl.java index 2f932e2..ae22ab9 100644 --- a/src/main/java/com/jryyy/forum/service/imp/MessageServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/MessageServiceImpl.java @@ -27,12 +27,12 @@ public class MessageServiceImpl implements MessageService { private final UserInfoMapper userInfoMapper; - private static final String DEFAULT = "0"; + private static final String DEFAULT = "0"; @Value("${file.url}") private String fileUrl; - public MessageServiceImpl(MessageMapper messageMapper,UserInfoMapper userInfoMapper){ + public MessageServiceImpl(MessageMapper messageMapper, UserInfoMapper userInfoMapper) { this.messageMapper = messageMapper; this.userInfoMapper = userInfoMapper; } @@ -42,7 +42,7 @@ public Response sendMessage(Message message) throws Exception { try { messageMapper.insertMessage(message); return new Response(); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); throw new GlobalException(GlobalStatus.serverError); } @@ -51,13 +51,13 @@ public Response sendMessage(Message message) throws Exception { @Override public Response readMessage(Integer to, Integer from) throws Exception { try { - List messages = messageMapper.findMessageByFromIdAndToId(from,to); - List messageList = messageMapper.findMessageByFromIdAndToId(to,from); + List messages = messageMapper.findMessageByFromIdAndToId(from, to); + List messageList = messageMapper.findMessageByFromIdAndToId(to, from); messages.addAll(messageList); messages.sort(Comparator.comparing(MessageRecord::getDate)); - messageMapper.updateMessageStatus(from,to); + messageMapper.updateMessageStatus(from, to); return new Response<>(messages); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); throw new GlobalException(GlobalStatus.serverError); } @@ -68,16 +68,17 @@ public Response uncheckedMessages(Integer userId) throws Exception { try { List uncheckedUserIdList = messageMapper.findFromByTo(userId); List responseList = new ArrayList<>(); - uncheckedUserIdList.forEach(from ->{ - UserInfoResponse response = userInfoMapper.findInfoByUserId(from); - if(!response.getAvatar().equals(DEFAULT)){ response.setAvatar(fileUrl+response.getAvatar()); } - responseList.add(MessageResponse.builder().message(messageMapper.findMessageByDate(from,userId)) - .number(messageMapper.findNumberByFromIdAndToId(from,userId)) - .userInfo(response) - .build()); - }); + uncheckedUserIdList.forEach(from -> { + UserInfoResponse response = userInfoMapper.findInfoByUserId(from); + if (!response.getAvatar().equals(DEFAULT)) { + response.setAvatar(fileUrl + response.getAvatar()); + } + responseList.add(MessageResponse.builder().message(messageMapper.findMessageByDate(from, userId)) + .number(messageMapper.findNumberByFromIdAndToId(from, userId)) + .userInfo(response).build()); + }); return new Response<>(responseList); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); throw new GlobalException(GlobalStatus.serverError); } diff --git a/src/main/java/com/jryyy/forum/service/imp/UserInfoServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/UserInfoServiceImpl.java index 5850f39..0485481 100644 --- a/src/main/java/com/jryyy/forum/service/imp/UserInfoServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/UserInfoServiceImpl.java @@ -2,7 +2,9 @@ import com.jryyy.forum.constant.GlobalStatus; import com.jryyy.forum.constant.KayOrUrl; +import com.jryyy.forum.dao.FollowMapper; import com.jryyy.forum.dao.UserInfoMapper; +import com.jryyy.forum.dao.ZonePraiseMapper; import com.jryyy.forum.exception.GlobalException; import com.jryyy.forum.model.Check; import com.jryyy.forum.model.Response; @@ -28,15 +30,24 @@ public class UserInfoServiceImpl implements UserInfoService { private final UserInfoMapper userInfoMapper; + private static final String username_regular = ""; + private final FollowMapper followMapper; + private final FileUtils fileUtils; private static final String DEFAULT = "0"; + private final ZonePraiseMapper zonePraiseMapper; @Value("${file.url}") private String fileUrl; - public UserInfoServiceImpl(UserInfoMapper userInfoMapper,FileUtils fileUtils) { + public UserInfoServiceImpl(UserInfoMapper userInfoMapper, + FollowMapper followMapper, + ZonePraiseMapper zonePraiseMapper, + FileUtils fileUtils) { this.userInfoMapper = userInfoMapper; + this.followMapper = followMapper; + this.zonePraiseMapper = zonePraiseMapper; this.fileUtils = fileUtils; } @@ -50,6 +61,9 @@ public Response viewUserInfo(Integer userId) throws Exception { if (!userInfo.getBgImg().equals(DEFAULT)) { userInfo.setBgImg(fileUrl + userInfo.getBgImg()); } + userInfo.setFollowers(followMapper.followersQuantityByUserId(userId)); + userInfo.setFollowing(followMapper.followingQuantityByUserId(userId)); + userInfo.setLikes(zonePraiseMapper.countByUserId(userId)); consecutiveCheckIn(userId); return new Response<>(userInfo); }catch (Exception e){ @@ -60,7 +74,13 @@ public Response viewUserInfo(Integer userId) throws Exception { @Override public Response changeUserInfo(UserInfoRequest request) throws Exception { - userInfoMapper.updateUserInfo(request); + log.info(request.toString()); + try { + userInfoMapper.updateUserInfo(request); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } return new Response(); } @@ -83,6 +103,11 @@ public Response updateBgImg(Integer userId, MultipartFile bgImg) throws Exceptio return new Response(); } + @Override + public Response updateUsername(Integer userId, String username) throws Exception { + return null; + } + @Override public Response checkIn(Integer userId) throws Exception { checkedIn(userId); diff --git a/src/main/java/com/jryyy/forum/service/imp/UserServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/UserServiceImpl.java index 576d4fd..697644a 100644 --- a/src/main/java/com/jryyy/forum/service/imp/UserServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/UserServiceImpl.java @@ -70,9 +70,10 @@ public Response userRegistration(UserRequestAccessRequest request) throws Except User user = request.toUser(); try { userMapper.insertUser(user); - userInfoMapper.insertUserInfo(user.getId(),user.getEmailName()); + userInfoMapper.insertUserInfo(user.getId(), user.getEmailName(), + KayOrUrl.username(user.getId())); template.delete(KayOrUrl.registrationCodeKey(request.getName())); - return new Response(); + return new Response<>(KayOrUrl.username(user.getId())); } catch (Exception e) { e.printStackTrace(); throw new GlobalException(GlobalStatus.serverError); diff --git a/src/main/java/com/jryyy/forum/service/imp/WordServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/WordServiceImpl.java new file mode 100644 index 0000000..54a19eb --- /dev/null +++ b/src/main/java/com/jryyy/forum/service/imp/WordServiceImpl.java @@ -0,0 +1,125 @@ +package com.jryyy.forum.service.imp; + +import com.alibaba.fastjson.JSONObject; +import com.jryyy.forum.constant.Constants; +import com.jryyy.forum.constant.GlobalStatus; +import com.jryyy.forum.constant.KayOrUrl; +import com.jryyy.forum.constant.WordWeight; +import com.jryyy.forum.dao.ThesaurusMapper; +import com.jryyy.forum.exception.GlobalException; +import com.jryyy.forum.model.Response; +import com.jryyy.forum.model.Word; +import com.jryyy.forum.service.WordService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Random; + +/** + * 单词记忆服务 + * + * @author OU + */ +@Slf4j +@Service +public class WordServiceImpl implements WordService { + + private static final long ONLINE_THESAURUS_LENGTH = 25; + private final ThesaurusMapper thesaurusMapper; + private final RedisTemplate redisTemplate; + + public WordServiceImpl(ThesaurusMapper thesaurusMapper, RedisTemplate redisTemplate) { + this.thesaurusMapper = thesaurusMapper; + this.redisTemplate = redisTemplate; + } + + @Override + public Response getWordLibrary(Integer userId) throws Exception { + Random random = new Random(); + List words = thesaurusMapper.findAllWords(); + redisTemplate.delete(KayOrUrl.unrecordedWordsKey(userId)); + redisTemplate.delete(KayOrUrl.memorizingWordsKey(userId)); + words.forEach(word -> redisTemplate.opsForList().rightPush(KayOrUrl.unrecordedWordsKey(userId), + JSONObject.toJSONString(word))); + for (int i = 0; i < ONLINE_THESAURUS_LENGTH; i++) { + String word = (String) redisTemplate.opsForList().index( + KayOrUrl.unrecordedWordsKey(userId), random.nextInt(Constants.TOTAL_WORDS)); + log.info(word); + redisTemplate.opsForList().remove(KayOrUrl.unrecordedWordsKey(userId), 0, word); + redisTemplate.opsForList().leftPush(KayOrUrl.memorizingWordsKey(userId), word); + } + redisTemplate.delete(KayOrUrl.memorizedWordsKey(userId)); + return new Response<>("词库创建完成"); + } + + @Override + public Response memory(Integer userId, Boolean understanding) throws Exception { + if (redisTemplate.opsForList().size(KayOrUrl.unrecordedWordsKey(userId)) == 0L) { + throw new GlobalException(GlobalStatus.thesaurusIsNotApplied); + } + Word word = JSONObject.parseObject((String) redisTemplate.opsForList(). + index(KayOrUrl.memorizingWordsKey(userId), 0), Word.class); + if (understanding != null) { + if (understanding) { + assert word != null; + if (word.getWeight() == WordWeight.default_level_weighting) { + word.setWeight(WordWeight.FIVE_LEVEL_WEIGHTING); + } else { + word.setWeight(word.getWeight() + 1); + } + } else { + assert word != null; + if (word.getWeight() == WordWeight.default_level_weighting) { + word.setWeight(WordWeight.FIVE_LEVEL_WEIGHTING); + } else if (word.getWeight() != WordWeight.one_level_weighting) { + word.setWeight(word.getWeight() - 1); + } + } + wordSort(userId, word); + } + return new Response<>(JSONObject.parseObject((String) redisTemplate.opsForList(). + index(KayOrUrl.memorizingWordsKey(userId), 0), Word.class)); + } + + @Override + public Response review(Integer userId) throws Exception { + return null; + } + + @Override + public Response remove(Integer userId) throws Exception { + redisTemplate.delete(KayOrUrl.unrecordedWordsKey(userId)); + redisTemplate.delete(KayOrUrl.memorizingWordsKey(userId)); + redisTemplate.delete(KayOrUrl.memorizedWordsKey(userId)); + return new Response(); + } + + private void wordSort(Integer userId, Word word) { + Random random = new Random(); + String wordJSONString = JSONObject.toJSONString(word); + List words = redisTemplate.opsForList().range(KayOrUrl.memorizingWordsKey(userId), 0, -1); + assert words != null; + words.remove(0); + if (word.getWeight() == WordWeight.SIX_LEVEL_WEIGHTING) { + String w = (String) redisTemplate.opsForList().index(KayOrUrl.unrecordedWordsKey(userId), + random.nextInt(Constants.TOTAL_WORDS)); + log.info(w); + redisTemplate.opsForList().rightPush(KayOrUrl.memorizedWordsKey(userId), wordJSONString); + words.add(w); + } else if (word.getWeight() == WordWeight.FIVE_LEVEL_WEIGHTING) { + words.add(2 + random.nextInt(4), wordJSONString); + } else if (word.getWeight() == WordWeight.four__level_weighting || + word.getWeight() == WordWeight.three__level_weighting) { + words.add(5 + random.nextInt(6), wordJSONString); + } else if (word.getWeight() == WordWeight.two_level_weighting || + word.getWeight() == WordWeight.one_level_weighting) { + words.add(11 + random.nextInt(4), wordJSONString); + } + + redisTemplate.delete(KayOrUrl.memorizingWordsKey(userId)); + words.forEach(o -> redisTemplate.opsForList().rightPush(KayOrUrl.memorizingWordsKey(userId), o)); + } +} + diff --git a/src/main/java/com/jryyy/forum/service/imp/ZoneServiceImpl.java b/src/main/java/com/jryyy/forum/service/imp/ZoneServiceImpl.java index b839080..e093a52 100644 --- a/src/main/java/com/jryyy/forum/service/imp/ZoneServiceImpl.java +++ b/src/main/java/com/jryyy/forum/service/imp/ZoneServiceImpl.java @@ -6,7 +6,9 @@ import com.jryyy.forum.dao.ZoneMapper; import com.jryyy.forum.dao.ZonePraiseMapper; import com.jryyy.forum.exception.GlobalException; -import com.jryyy.forum.model.*; +import com.jryyy.forum.model.Response; +import com.jryyy.forum.model.Zone; +import com.jryyy.forum.model.ZoneImg; import com.jryyy.forum.model.request.GetZoneRequest; import com.jryyy.forum.model.request.ZoneRequest; import com.jryyy.forum.model.response.PaginationResponse; @@ -63,15 +65,18 @@ public ZoneServiceImpl(ZoneMapper zoneMapper, ZonePraiseMapper zonePraiseMapper, @Override public Response insertZone(ZoneRequest request) throws Exception { + log.info(request.toString()); Zone zone = request.getZone(); zoneMapper.insertZone(zone); - List zoneImgList = request.saveImage(zone.getId(), uploadFolder, fileUtils, imageUtils); - zoneImgList.forEach(zoneMapper::insertZoneImg); + if (request.getFiles() != null) { + List zoneImgList = request.saveImage(zone.getId(), uploadFolder, fileUtils, imageUtils); + zoneImgList.forEach(zoneMapper::insertZoneImg); + } return new Response(); } @Override - public Response getZone(Integer userId,GetZoneRequest request) throws Exception { + public Response viewSpace(Integer userId, GetZoneRequest request) throws Exception { log.info(request.toString()); List responses = new ArrayList<>(); int curPage = request.getCurPage(); @@ -81,11 +86,7 @@ public Response getZone(Integer userId,GetZoneRequest request) throws Exception UserInfoResponse userInfo = userInfoMapper.findInfoByUserId(zone.getUserId()); List praise = zonePraiseMapper.selectZonePraise(zone.getId()); List favoriteUser = new ArrayList<>(); - praise.forEach(o-> { - UserInfoResponse response = userInfoMapper.findInfoByUserId(o); - response.addAvatarUrl(fileUrl); - favoriteUser.add(response); - }); + praise.forEach(o -> favoriteUser.add(UserInfoResponse.userInfoResponse(userInfoMapper, o, fileUrl))); userInfo.addAvatarUrl(fileUrl); ZoneResponse response = ZoneResponse.builder().comment(zoneCommentMapper.count(zone.getId())) .userInfo(userInfo).favoriteUser(favoriteUser).build(); @@ -100,6 +101,11 @@ public Response getZone(Integer userId,GetZoneRequest request) throws Exception curPage, request.getPageSize())); } + @Override + public Response viewUpdateSpace(Integer id) throws Exception { + return null; + } + @Override public Response deleteZone(Integer userId, Integer zoneId) throws Exception { if(zoneMapper.deleteZone(userId,zoneId) < 1) { diff --git a/src/main/java/com/jryyy/forum/utils/EmailUtils.java b/src/main/java/com/jryyy/forum/utils/EmailUtils.java index 1a79f88..64314d4 100644 --- a/src/main/java/com/jryyy/forum/utils/EmailUtils.java +++ b/src/main/java/com/jryyy/forum/utils/EmailUtils.java @@ -2,7 +2,6 @@ import com.jryyy.forum.constant.GlobalStatus; import com.jryyy.forum.exception.GlobalException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; @@ -32,10 +31,10 @@ public EmailUtils(JavaMailSender mailSender) { /** * 不带附件放送email - * @param to 发送到 - * @param title 标题 - * @param content 内容 - * @throws Exception 异常 + * @param to 发送到 + * @param title 标题 + * @param content 内容 + * @throws Exception 异常 */ public void sendSimpleMail(String to, String title, String content) throws Exception { SimpleMailMessage message = new SimpleMailMessage(); @@ -72,6 +71,5 @@ public void sendAttachmentsMail(String to, String title, String content, List ((Comparable) ((Map.Entry) (o1)).getValue()).compareTo(((Map.Entry) (o2)).getValue())); + list.sort((o1, o2) -> ((Comparable) ((Map.Entry) (o1)).getValue()).compareTo(((Map.Entry) (o2)).getValue())); Map.Entry me = (Map.Entry) list.get(list.size() - 1); int[] rgb = getRgbArr((Integer) me.getKey()); - return "#" + Integer.toHexString(rgb[0]) + "" + Integer.toHexString(rgb[1]) + "" + Integer.toHexString(rgb[2]); + return "0xff" + Integer.toHexString(rgb[0]) + "" + Integer.toHexString(rgb[1]) + "" + Integer.toHexString(rgb[2]); } /** * 获取RGB + * * @param pixel 像素点 * @return RGB */ @@ -42,8 +51,9 @@ private static int[] getRgbArr(int pixel) { /** * 转变为灰色 - * @param rgbArr RGB - * @return 灰度 + * + * @param rgbArr RGB + * @return 灰度 */ private static boolean isGray(int[] rgbArr) { int rgDiff = rgbArr[0] - rgbArr[1]; @@ -58,20 +68,23 @@ private static boolean isGray(int[] rgbArr) { /** * 主题颜色 - * @param image 图片 - * @return 主题颜色 + * + * @param image 图片 + * @return 主题颜色 */ public String dominantColor(BufferedImage image) { int height = image.getHeight(); int width = image.getWidth(); + boolean white = true; Map m = new HashMap<>(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int rgb = image.getRGB(i, j); int[] rgbArr = getRgbArr(rgb); if (!isGray(rgbArr)) { + white = false; Integer counter = m.get(rgb); - if (counter == null){ + if (counter == null) { counter = 0; } counter++; @@ -79,6 +92,9 @@ public String dominantColor(BufferedImage image) { } } } - return getMostCommonColour(m); + + return white ? "0xffffffff" : getMostCommonColour(m); } + + } diff --git a/src/main/java/com/jryyy/forum/utils/security/SecurityUtils.java b/src/main/java/com/jryyy/forum/utils/security/SecurityUtils.java deleted file mode 100644 index 5c32735..0000000 --- a/src/main/java/com/jryyy/forum/utils/security/SecurityUtils.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.jryyy.forum.utils.security; - - -import com.jryyy.forum.constant.GlobalStatus; -import com.jryyy.forum.exception.GlobalException; -import com.jryyy.forum.model.User; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.method.HandlerMethod; -import java.lang.reflect.Method; - -/** - * 安全工具 - * @author JrYYY - */ -public class SecurityUtils { - - /** - * 拦截对象 - */ - private UserLoginToken userLoginToken; - - private User user; - - public static SecurityUtils create(HandlerMethod handlerMethod){ - return new SecurityUtils(handlerMethod); - } - - private SecurityUtils(HandlerMethod handlerMethod){ - - } - - - - /** - * 身份验证 - * @param token 用户令牌 - * @throws GlobalException {@link GlobalStatus} - */ - public SecurityUtils authenticationToken(String token, TokenUtils tokenUtils) throws GlobalException { - if (userLoginToken != null) { } - return this; - } - - /** - * 验证用户 - * - * @param userId 用户id - * @return {@link SecurityUtils} - * @throws GlobalException {@link GlobalStatus} unauthorizedAccess - */ - public SecurityUtils validationUser(String userId) throws GlobalException { - - - return this; - } - - /** - * 冻结 - * @return {@link SecurityUtils} - * @throws GlobalException {@link GlobalStatus} accountHasBeenFrozen - */ - public SecurityUtils validationLock(RedisTemplate redisTemplate)throws GlobalException{ - - return this; - } - - /** - * 验证权限 - * @throws GlobalException {@link GlobalStatus} - */ - public void validationRole() throws GlobalException{ - - } - - - -} diff --git a/src/main/java/com/jryyy/forum/utils/sql/generation/SqlGenerator.java b/src/main/java/com/jryyy/forum/utils/sql/generation/SqlGenerator.java index 6a82e13..7f3e6d8 100644 --- a/src/main/java/com/jryyy/forum/utils/sql/generation/SqlGenerator.java +++ b/src/main/java/com/jryyy/forum/utils/sql/generation/SqlGenerator.java @@ -1,9 +1,11 @@ package com.jryyy.forum.utils.sql.generation; import com.jryyy.forum.utils.sql.condition.Id; + import java.lang.reflect.Field; /** + * 未启用 * @author OU */ public class SqlGenerator { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5542539..a22da36 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,10 +2,11 @@ spring: # 配置数据库 datasource: driver-class-name: com.mysql.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/forum?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull + url: jdbc:mysql://127.0.0.1:3306/forum?useSSL=false&allowMultiQueries=true username: root password: 10086 - + hikari: + connection-init-sql: SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci #配置redis缓存 redis: host: 127.0.0.1 @@ -61,13 +62,13 @@ token: effectiveTime: 8640000 secret: hjijfvbw859 + alipay: appID: 2088102180418544 - merchantPrivateKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlE0ynRLHjTPe6v+JHzyosMnav6sLq2Qew1mkLKjKsezwKV/Xxv3n2AV/yUOfEQEMzP2q6oAAgjfhmJHYrVmIUim6LnxQLY2vIuB7WVQ0Y2ENRqqZ2NFhfvcRp5DkVlreOxC7MDlbfN5+yGVDSX48cnEWzrcwUCD6WeGSfkhcvtXTfYVRw0iASCayIcRLDq86TUelt2qBVfous6iSPgDUBHzxidlYZDxB2f6lIn1I92ABnJfgrtIgbDhqF/NVlWCXj+ox79j/TR9gQvCMxsoOkzkJMqEl8jkEj3O/GrciQyw6VKAyUZNpfma7WaICFQFKeVHCO7z94xoElOygg0u3uwIDAQAB + merchantPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCUTTKdEseNM97q/4kfPKiwydq/qwurZB7DWaQsqMqx7PApX9fG/efYBX/JQ58RAQzM/arqgACCN+GYkditWYhSKboufFAtja8i4HtZVDRjYQ1GqpnY0WF+9xGnkORWWt47ELswOVt83n7IZUNJfjxycRbOtzBQIPpZ4ZJ+SFy+1dN9hVHDSIBIJrIhxEsOrzpNR6W3aoFV+i6zqJI+ANQEfPGJ2VhkPEHZ/qUifUj3YAGcl+Cu0iBsOGoX81WVYJeP6jHv2P9NH2BC8IzGyg6TOQkyoSXyOQSPc78atyJDLDpUoDJRk2l+ZrtZogIVAUp5UcI7vP3jGgSU7KCDS7e7AgMBAAECggEADLXlHaNLaSXF+Fw4c23ug2B5mC3fzSvCmzmmoZFB9if5mYI2az69zT0Da8uY6Ysufq9LI9geswp5EmuFp63hyjD7XRqYgJ8BILset1RJPS9HRQRANV4Uvh4M7FC10VTucR+I+6Qe3D/xm9laAAWKxsA8lTEMOgHpkySLOrmXAWAOsmd5aHQkvdhoe3KwIbAedY426KNbmDrUKSe+Dswz9F8xp0ci2YdGZX4RtttdWGScpay5Lef+VkgLTYwRCjv7ubItmAUxXU1HgB2YgMwv2A15WgvNsRISILoHp6b3QKerecaJAQfn2imyW0m1ttXDXJF6JdZxK68whD5tjGegqQKBgQDXxQKRbNr+FKhkFC4oW9/G1q5+Upp6+qxikSJFfkv/scaiyztdxHG54bW8JP/8mKxuI/XQjVtR7XtG5IRLFFYJzDUSaVJqY+Vq1WJw/7LBKlYvUIn7EIhfWDlCUdIFeZwCrGzZ0OMNsaiEWHEB2XZN/tTmtZ+db/jVU0PmSAdNvQKBgQCv89fCTPfp7rZk2Pvs/i54Ws/S5xoe5TKGczLLhDfHw3XRBlFQgSiOxXJInKMSUTaDjVpsnwSVDo8f8CWXaT/hIzGIP/vgaGZEe/PlnZXiEUZTLr38w7Y9/tgGqpqw+NRBnixh9OlhIQiSM+oVrIyp4TklBgT+Rf43/MA1YqMG1wKBgH/pD6usT2peTrD9cZuFU3RpognK6D9NSVIpXZq600ziU7IALtJYeV7LWlQNzx8sVtP4R2n50pAP64vMPkzP4m1ufGvMugnN7JvXocMBIjP26B6mbRXD6EQ1ZcRWAt4yCHVhSCob9e4RSqgiUePZyZNVJVsbgmLvlSDJerASNRo1AoGAK0X3TGwNlNUGuqq62sBwwVzkO+Rmgi6wTGzMk00DQvgJY8z/9qKtTN+2ibEsUfbzR0teb9R0Fgysmpg/Rou2EDLNncrOsZQ7gqBRjalCEYVaHF8kjqO7kGe6zXjr7pZj7XdvRvAq7Z5oMzzdV1NGjQk9OqPOWpLwQOjChN6rZaUCgYEAumX3c48ULXPZbzeMnFvioujPbCzXUCIbNA/+E3jkrRyzpJCYZ72gGjKuAunm+Hpoii+0p1j7YCA3er0mLnjLqWH8TX2G16HhTh1ihherR6ffwZ+wTwdo0X3ZN+k1qoOdGP1tkGgbaxo3PzSPJvv0gGhOMoGeNKI0sMNrSq1zXTs= alipayPublicKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEyWlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FTFY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB gatewayUrl: https://openapi.alipaydev.com/gateway.do - sysServiceProviderId: 1234 - notifyUrl: http://XXXX.com + notifyUrl: http://xxxxx # Logging logging: diff --git a/src/test/java/com/jryyy/forum/MapJsonTest.java b/src/test/java/com/jryyy/forum/MapJsonTest.java index b82b528..eeec398 100644 --- a/src/test/java/com/jryyy/forum/MapJsonTest.java +++ b/src/test/java/com/jryyy/forum/MapJsonTest.java @@ -3,4 +3,8 @@ public class MapJsonTest { + public static void main(String[] args) { + + } + } diff --git a/src/test/java/com/jryyy/forum/StringTest.java b/src/test/java/com/jryyy/forum/StringTest.java index 59ec528..f51fe80 100644 --- a/src/test/java/com/jryyy/forum/StringTest.java +++ b/src/test/java/com/jryyy/forum/StringTest.java @@ -1,10 +1,8 @@ package com.jryyy.forum; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.TypeReference; -import com.jryyy.forum.constant.KayOrUrl; import com.jryyy.forum.dao.ZoneMapper; -import com.jryyy.forum.model.ZoneImg; +import com.jryyy.forum.service.UserInfoService; +import com.jryyy.forum.service.WordService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -12,10 +10,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.test.context.junit4.SpringRunner; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - @RunWith(SpringRunner.class) @SpringBootTest public class StringTest { @@ -24,51 +18,80 @@ public class StringTest { ZoneMapper userZoneMapper; @Autowired - RedisTemplate redisTemplate; + UserInfoService userInfoService; - @Test - public void testRedis() throws Exception { - System.out.println(redisTemplate.opsForHash().get(KayOrUrl.ONLINE_USER_LIST_KEY, KayOrUrl.userKey(1040))); - } + @Autowired + WordService wordMemoryService; - @Test - public void test() throws Exception { - List zoneImgs = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - zoneImgs.add(ZoneImg.builder().zoneId(1011).imgUrl("测试").build()); - } - for (ZoneImg z : zoneImgs - ) { - System.out.println(z.toString()); - } - //userZoneMapper.insertZoneImg(zoneImgs); - } + @Autowired + RedisTemplate redisTemplate; @Test public void test1() { - String str = "{\"test1\":{\"name\":\"zhangsan\"},\"test2\":{\"name\":\"lisi\"},\"test3\":{\"name\":\"wanger\"}}"; - HashMap nameMap = - JSON.parseObject(str, new TypeReference>() { - }); - - HashMap map = getHashList(str, new TypeReference>() { - }); - - System.out.println(nameMap.toString()); - - //其中Map中key为String类型,value为 NameEntity类型的实体 - } - - public T getHashList(String str, TypeReference obj) { - - if (str != null) { - return JSON.parseObject(str, obj.getType()); - } - return null; } - - +// @Test +// public void testEmoji()throws Exception{ +// userInfoMapper.findAllUserId().forEach( +// o->userInfoMapper.updateUsername(o,KayOrUrl.username(o)) +// ); +// } + +// +// @Test +// public void testRedis() throws Exception { +// wordMemoryService.getWordLibrary(1010); +// } +// +// @Test +// public void test()throws Exception{ +// System.out.println(wordMemoryService.memory(1010,true)); +// } + + +// +// @Test +// public void redis()throws Exception{ +// System.out.println( +// Objects.requireNonNull(redisTemplate.opsForList() +// .size(KayOrUrl.unrecordedWordsKey(1040))) +// .getClass() +// ); +// } +// +// @Test +// public void test() throws Exception { +// List zoneImgs = new ArrayList<>(); +// for (int i = 0; i < 3; i++) { +// zoneImgs.add(ZoneImg.builder().zoneId(1011).imgUrl("测试").build()); +// } +// for (ZoneImg z : zoneImgs +// ) { +// System.out.println(z.toString()); +// } +// //userZoneMapper.insertZoneImg(zoneImgs); +// } +// +// @Test +// public void test1() { +// String str = "{\"test1\":{\"name\":\"zhangsan\"},\"test2\":{\"name\":\"lisi\"},\"test3\":{\"name\":\"wanger\"}}"; +// +// HashMap nameMap = +// JSON.parseObject(str, new TypeReference>() { +// }); +// +// HashMap map = getHashList(str, new TypeReference>() { +// }); +// +// System.out.println(nameMap.toString()); +// +// //其中Map中key为String类型,value为 NameEntity类型的实体 +// } +// +// public T getHashList(String str, TypeReference obj) { +// if (str != null) { return JSON.parseObject(str, obj.getType()); } +// return null; +// } } diff --git a/src/test/java/com/jryyy/forum/Vocabulary.java b/src/test/java/com/jryyy/forum/Vocabulary.java new file mode 100644 index 0000000..6fb9e5a --- /dev/null +++ b/src/test/java/com/jryyy/forum/Vocabulary.java @@ -0,0 +1,53 @@ +package com.jryyy.forum; + +import org.junit.Test; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Vocabulary { + + + @Test + public void test() { + StringBuilder sql = new StringBuilder("insert into thesaurus(English,Chinese)values"); + try { + File file = new File("E:\\LearningProject\\Forum\\大学英语词汇.txt"); + String regex2 = "^[a-zA-Z]+ "; + String regex3 = " .+$"; + InputStreamReader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); + // 建立一个对象,它把文件内容转成计算机能读懂的语言 + BufferedReader br = new BufferedReader(reader); + + String line = br.readLine(); + int n = 1; + while (line != null && !"".equals(line)) { + + String e = getWord(line, regex2); + String c = getWord(line, regex3); + // 一次读入一行数据 + line = br.readLine(); + if ((line != null && line.equals(""))) { + sql.append(String.format("('%s','%s');", e, c)); + } else { + sql.append(String.format("('%s','%s'),", e, c)); + } + n++; + } + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println(sql); + } + + private String getWord(String s, String regex) { + Matcher matcher = Pattern.compile(regex).matcher(s); + if (matcher.find()) { + return matcher.group().trim(); + } + return null; + } + +} diff --git "a/\345\244\247\345\255\246\350\213\261\350\257\255\350\257\215\346\261\207.txt" "b/\345\244\247\345\255\246\350\213\261\350\257\255\350\257\215\346\261\207.txt" index 910218c..f537d59 100644 --- "a/\345\244\247\345\255\246\350\213\261\350\257\255\350\257\215\346\261\207.txt" +++ "b/\345\244\247\345\255\246\350\213\261\350\257\255\350\257\215\346\261\207.txt" @@ -1,9 +1,4 @@ -abandon -ability -aboardabroad absenceabsent a.不在场的;缺乏的 -absolute a.绝对的;纯粹的 -absolutely ad.完全地;绝对地 -absorb vt.吸收;使专心 +absorb vt.吸收;使专心 abstract a.抽象的 n.摘要 abundant a.丰富的;大量的 abuse vt.滥用;虐待 n.滥用 @@ -3655,12 +3650,6 @@ zeal n.热心,热情,热忱 zealous a.热心的,热情的 zebra n.斑马 zero n.零;零点,零度 -zone n.地区,区域,范围 - - - - - - +zone n.地区,区域,范围