├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── kevin │ │ ├── config │ │ ├── LuceneConfig.java │ │ ├── SwaggerConfig.java │ │ └── WebSocketConfig.java │ │ ├── interceptor │ │ └── WebSocketInterceptor.java │ │ ├── mirs │ │ ├── dao │ │ │ ├── EmailVerifyDao.java │ │ │ ├── FriendDao.java │ │ │ ├── MovieDao.java │ │ │ ├── RegisterSessionDao.java │ │ │ ├── TestDao.java │ │ │ ├── UserDao.java │ │ │ ├── UserRecommendedFriendsDao.java │ │ │ └── UserRecommendedMoviesDao.java │ │ ├── dto │ │ │ └── MIRSResult.java │ │ ├── entity │ │ │ ├── EmailTemplate.java │ │ │ ├── EmailVerify.java │ │ │ ├── Friend.java │ │ │ ├── Movie.java │ │ │ ├── OAuthUser.java │ │ │ ├── RegisterSession.java │ │ │ ├── User.java │ │ │ ├── UserRecommendedFriends.java │ │ │ └── UserRecommendedMovies.java │ │ ├── enums │ │ │ ├── EVChannelEnum.java │ │ │ ├── EVStatusEnum.java │ │ │ ├── EVTypeEnum.java │ │ │ ├── MovieColumnEnum.java │ │ │ └── RSStatusEnum.java │ │ ├── jobs │ │ │ └── Jobs.java │ │ ├── recommendation │ │ │ ├── MahoutTest.java │ │ │ ├── RecommendFriends.java │ │ │ ├── RecommendFriendsBySimilarity.java │ │ │ ├── RecommendMovies.java │ │ │ ├── RecommendMoviesByPerson.java │ │ │ └── RecommendationController.java │ │ ├── service │ │ │ ├── EmailService.java │ │ │ ├── LuceneService.java │ │ │ ├── MovieService.java │ │ │ ├── RecommendService.java │ │ │ ├── SearchService.java │ │ │ ├── SockJSHandler.java │ │ │ ├── SocketHandler.java │ │ │ └── UserService.java │ │ ├── utils │ │ │ ├── EncryptionUtils.java │ │ │ ├── FormatUtils.java │ │ │ ├── IPUtils.java │ │ │ └── LuceneUtils.java │ │ ├── vo │ │ │ ├── LoginInfo.java │ │ │ ├── LoginUser.java │ │ │ ├── RegisterInfo.java │ │ │ ├── RegisterUser.java │ │ │ ├── SimpleMovie.java │ │ │ ├── SimpleUserMessage.java │ │ │ ├── SuggestionMovie.java │ │ │ ├── Url.java │ │ │ └── UserProfile.java │ │ └── web │ │ │ ├── AccountsController.java │ │ │ ├── AuthenticationController.java │ │ │ ├── CaptchaController.java │ │ │ ├── HomeController.java │ │ │ ├── InspectionController.java │ │ │ ├── MovieController.java │ │ │ ├── OAuthController.java │ │ │ ├── SearchController.java │ │ │ └── WebSocketController.java │ │ ├── oauth │ │ ├── api │ │ │ ├── GitHubApi.java │ │ │ ├── QQApi.java │ │ │ └── WeiXinApi.java │ │ ├── config │ │ │ ├── GitHubConfig.java │ │ │ ├── OAuthTypes.java │ │ │ ├── QQConfig.java │ │ │ ├── WeiBoConfig.java │ │ │ └── WeiXinConfig.java │ │ └── service │ │ │ ├── CustomOAuthService.java │ │ │ ├── GithubOAuthService.java │ │ │ ├── OAuthServiceDecorator.java │ │ │ ├── OAuthServices.java │ │ │ ├── QQOAuthService.java │ │ │ ├── SinaWeiboOAuthService.java │ │ │ └── WeixinOAuthService.java │ │ └── shiro │ │ └── realm │ │ └── LoginRealm.java ├── resources │ ├── junit │ │ └── spring-test.xml │ ├── logback.xml │ ├── mapper │ │ ├── EmailVerifyDao.xml │ │ ├── FriendDao.xml │ │ ├── MovieDao.xml │ │ ├── RegisterSessionDao.xml │ │ ├── TestDao.xml │ │ ├── UserDao.xml │ │ ├── UserRecommendedFriendsDao.xml │ │ └── UserRecommendedMoviesDao.xml │ ├── mybatis-config.xml │ ├── properties │ │ ├── jdbc-example.properties │ │ ├── mail-example.properties │ │ └── oauth-prod.properties │ ├── recommendation │ │ └── test.csv │ └── spring │ │ ├── spring-dao.xml │ │ ├── spring-service.xml │ │ ├── spring-shiro.xml │ │ └── spring-web.xml ├── sql │ ├── mirs.sql │ └── mirs_movie.sql └── webapp │ └── WEB-INF │ ├── html │ └── swagger │ │ ├── css │ │ ├── print.css │ │ ├── reset.css │ │ ├── screen.css │ │ ├── style.css │ │ └── typography.css │ │ ├── fonts │ │ ├── DroidSans-Bold.ttf │ │ └── DroidSans.ttf │ │ ├── images │ │ ├── collapse.gif │ │ ├── expand.gif │ │ ├── explorer_icons.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ ├── logo_small.png │ │ ├── pet_store_api.png │ │ ├── throbber.gif │ │ └── wordnik_api.png │ │ ├── index.html │ │ ├── lang │ │ ├── ca.js │ │ ├── en.js │ │ ├── es.js │ │ ├── fr.js │ │ ├── geo.js │ │ ├── it.js │ │ ├── ja.js │ │ ├── ko-kr.js │ │ ├── pl.js │ │ ├── pt.js │ │ ├── ru.js │ │ ├── tr.js │ │ ├── translator.js │ │ └── zh-cn.js │ │ ├── lib │ │ ├── backbone-min.js │ │ ├── es5-shim.js │ │ ├── handlebars-4.0.5.js │ │ ├── highlight.9.1.0.pack.js │ │ ├── highlight.9.1.0.pack_extended.js │ │ ├── jquery-1.8.0.min.js │ │ ├── jquery.ba-bbq.min.js │ │ ├── jquery.slideto.min.js │ │ ├── jquery.wiggle.min.js │ │ ├── js-yaml.min.js │ │ ├── jsoneditor.min.js │ │ ├── lodash.min.js │ │ ├── marked.js │ │ ├── object-assign-pollyfill.js │ │ ├── sanitize-html.min.js │ │ └── swagger-oauth.js │ │ ├── o2c.html │ │ ├── swagger-ui.js │ │ └── swagger-ui.min.js │ └── web.xml └── test └── main └── com └── kevin ├── lucene └── LuceneTest.java └── mirs ├── dao ├── EmailVerifyDaoTest.java ├── FriendDaoTest.java ├── MovieDaoTest.java ├── RegisterSessionDaoTest.java ├── UserDaoTest.java ├── UserRecommendedFriendsDaoTest.java └── UserRecommendedMoviesDaoTest.java ├── service ├── EmailServiceTest.java ├── LuceneServiceTest.java ├── RecommendServiceTest.java └── SearchServiceTest.java └── utils ├── EncryptionUtilsTest.java └── FormatUtilsTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | # IDEA 2 | .idea 3 | *.iml 4 | *.ipr 5 | *.iws 6 | out 7 | 8 | *.log 9 | target/ 10 | 11 | lib 12 | 13 | # 配置文件 14 | src/main/resources/properties/jdbc-prod.properties 15 | src/main/resources/properties/mail-prod.properties 16 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/config/LuceneConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.config; 2 | 3 | import org.apache.lucene.analysis.Analyzer; 4 | import org.apache.lucene.document.Document; 5 | import org.apache.lucene.index.DirectoryReader; 6 | import org.apache.lucene.index.IndexReader; 7 | import org.apache.lucene.index.IndexWriter; 8 | import org.apache.lucene.index.IndexWriterConfig; 9 | import org.apache.lucene.search.IndexSearcher; 10 | import org.apache.lucene.store.Directory; 11 | import org.apache.lucene.store.FSDirectory; 12 | import org.lionsoul.jcseg.analyzer.v5x.JcsegAnalyzer5X; 13 | import org.lionsoul.jcseg.tokenizer.core.JcsegTaskConfig; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.Lazy; 17 | import org.springframework.context.annotation.Scope; 18 | 19 | import java.io.IOException; 20 | import java.nio.file.Path; 21 | import java.nio.file.Paths; 22 | 23 | 24 | @Configuration 25 | @Lazy 26 | public class LuceneConfig { 27 | 28 | String WIN_INDEX_PATH = "c:temp/mirs/indexes/"; 29 | String DEFAULT_INDEX_PATH = "/tmp/mirs/indexes/"; 30 | 31 | @Bean 32 | public Analyzer analyzer() { 33 | System.out.println("------------初始化analyzer-------------"); 34 | // 如果需要使用特定的分词算法,可通过构造函数来指定: 35 | // Analyzer analyzer = new ChineseWordAnalyzer(SegmentationAlgorithm.FullSegmentation); 36 | // 如不指定,默认使用双向最大匹配算法:SegmentationAlgorithm.BidirectionalMaximumMatching 37 | // 可用的分词算法参见枚举类:SegmentationAlgorithm 38 | // return new ChineseWordAnalyzer(); 39 | // return new StandardAnalyzer(); 40 | return new JcsegAnalyzer5X(JcsegTaskConfig.COMPLEX_MODE); 41 | } 42 | 43 | 44 | @Bean 45 | public Directory directory() throws IOException { 46 | System.out.println("--------------初始化directory----------"); 47 | String indexPath; 48 | if(System.getProperty("os.name").substring(0, 3).equals("Win")){ 49 | indexPath = WIN_INDEX_PATH; 50 | } else { 51 | indexPath = DEFAULT_INDEX_PATH; 52 | } 53 | Path path = Paths.get(indexPath); 54 | return FSDirectory.open(path); 55 | } 56 | 57 | 58 | private IndexWriterConfig config() { 59 | return new IndexWriterConfig(analyzer()); 60 | } 61 | 62 | 63 | @Bean 64 | public IndexWriter indexWriter() throws IOException { 65 | System.out.println("--------------初始化indexWriter----------"); 66 | return new IndexWriter(directory(), config()); 67 | } 68 | 69 | 70 | private IndexReader indexReader() throws IOException { 71 | return DirectoryReader.open(directory()); 72 | } 73 | 74 | 75 | @Bean 76 | public IndexSearcher indexSearcher() throws IOException { 77 | System.out.println("--------------初始化indexSearcher----------"); 78 | return new IndexSearcher(indexReader()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.config; 2 | 3 | import com.mangofactory.swagger.configuration.SpringSwaggerConfig; 4 | import com.mangofactory.swagger.models.dto.ApiInfo; 5 | import com.mangofactory.swagger.plugin.EnableSwagger; 6 | import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | @EnableSwagger 13 | public class SwaggerConfig { 14 | 15 | 16 | private SpringSwaggerConfig springSwaggerConfig; 17 | 18 | @Autowired 19 | public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) { 20 | this.springSwaggerConfig = springSwaggerConfig; 21 | } 22 | 23 | /** 24 | * 自定义实现 customImplementation 25 | * @return 26 | */ 27 | @Bean 28 | public SwaggerSpringMvcPlugin customImplementation(){ 29 | return new SwaggerSpringMvcPlugin(this.springSwaggerConfig) 30 | .apiInfo(apiInfo()) 31 | .includePatterns(".*?"); 32 | } 33 | 34 | /** 35 | * title; 36 | description; 37 | terms of serviceUrl; 38 | contact email; 39 | license type; 40 | license url; 41 | * @return 42 | */ 43 | private ApiInfo apiInfo(){ 44 | ApiInfo apiInfo = new ApiInfo( 45 | "标题 title", 46 | "描述 description", 47 | "termsOfServiceUrl", 48 | "联系邮箱 contact email", 49 | "许可证的类型 license type", 50 | "许可证的链接 license url" 51 | ); 52 | return apiInfo; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.config; 2 | 3 | 4 | import com.kevin.mirs.service.SockJSHandler; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 7 | import org.springframework.web.socket.config.annotation.*; 8 | 9 | import javax.annotation.Resource; 10 | 11 | 12 | @Configuration 13 | @EnableWebSocketMessageBroker 14 | public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { 15 | 16 | @Resource 17 | SockJSHandler sockJSHander; 18 | 19 | @Override 20 | public void configureMessageBroker(MessageBrokerRegistry config) { 21 | config.enableSimpleBroker("/topic", "/user"); 22 | config.setApplicationDestinationPrefixes("/app"); 23 | config.setUserDestinationPrefix("/user"); 24 | } 25 | 26 | @Override 27 | public void registerStompEndpoints(StompEndpointRegistry registry) { 28 | registry.addEndpoint("/courier") 29 | .setAllowedOrigins("*") 30 | .setHandshakeHandler(sockJSHander) 31 | .withSockJS(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/interceptor/WebSocketInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.kevin.interceptor; 2 | 3 | 4 | import com.kevin.mirs.service.UserService; 5 | import org.springframework.http.server.ServerHttpRequest; 6 | import org.springframework.http.server.ServerHttpResponse; 7 | import org.springframework.http.server.ServletServerHttpRequest; 8 | import org.springframework.web.socket.WebSocketHandler; 9 | import org.springframework.web.socket.server.HandshakeInterceptor; 10 | 11 | import javax.servlet.http.HttpSession; 12 | import java.util.Map; 13 | 14 | /** 15 | * Websocket 拦截器 16 | */ 17 | public class WebSocketInterceptor implements HandshakeInterceptor{ 18 | 19 | @Override 20 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, 21 | WebSocketHandler handler, Exception exception) { 22 | 23 | } 24 | 25 | /** 26 | * 将HttpSession中对象放入WebSocketSession中 27 | */ 28 | @Override 29 | public boolean beforeHandshake(ServerHttpRequest request, 30 | ServerHttpResponse response, WebSocketHandler handler, 31 | Map map) throws Exception { 32 | if(request instanceof ServerHttpRequest){ 33 | ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; 34 | HttpSession session = servletRequest.getServletRequest().getSession(); 35 | if(session!=null){ 36 | //区分socket连接以定向发送消息 37 | map.put("id", session.getAttribute(UserService.USER_ID)); 38 | } 39 | } 40 | return true; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/EmailVerifyDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.sql.Timestamp; 7 | 8 | @Repository 9 | public interface EmailVerifyDao { 10 | 11 | 12 | /** 13 | * 添加一条邮件验证记录 14 | * @param email 邮件 15 | * @param createTime 创建时间 16 | * @param expireTime 过期时间 17 | * @param channel 验证渠道 18 | * @param verifyCode 验证码 19 | * @param verifyType 验证类型 20 | * @param requestIp 请求IP 21 | * return 1:添加成功;0:添加失败 22 | */ 23 | int add(@Param("email") String email, 24 | @Param("createTime") Timestamp createTime, 25 | @Param("expireTime") Timestamp expireTime, 26 | @Param("channel") Character channel, 27 | @Param("verifyCode") String verifyCode, 28 | @Param("verifyType") Character verifyType, 29 | @Param("requestIp") String requestIp); 30 | 31 | /** 32 | * 通过email更新注册状态 33 | * @param email 邮箱 34 | * @param status 状态 35 | * @return 1:更新成功;0:更新失败 36 | */ 37 | int updateStatusByEmail(@Param("email") String email, 38 | @Param("status") Character status); 39 | 40 | /** 41 | * 根据时间戳批量更新信息 42 | * @param expireTime 注册信息过期时间 43 | * @param status 状态 44 | * @return 更新的条数 45 | */ 46 | int updateStatusByExpireTime(@Param("expireTime")Timestamp expireTime, 47 | @Param("status") Character status); 48 | 49 | /** 50 | * 根据邮箱获取最近的一条注册信息 51 | * @param email 邮箱 52 | * @return 该注册邮箱的失效时间 53 | */ 54 | Timestamp getExpireTimeByEmail(@Param("email") String email); 55 | 56 | 57 | /** 58 | * 通过注册状态获取注册过期时间 59 | * @param status 注册状态 60 | * @param orderBy 排序方式 61 | * @param limit 限制条数 62 | * @param offset 偏移量 63 | * @return 时间戳 或者 null 64 | */ 65 | Timestamp getExpireTimeByStatus(@Param("status") Character status, 66 | @Param("orderBy") String orderBy, 67 | @Param("limit") int limit, 68 | @Param("offset") int offset); 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/FriendDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.entity.Friend; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.ArrayList; 8 | 9 | @Repository 10 | public interface FriendDao { 11 | 12 | /** 13 | * 添加一条朋友记录的信息 14 | * @param uid 用户ID 15 | * @param ufid 用户好友ID 16 | * @return 1:添加成功; 0:添加失败 17 | */ 18 | int addFriendRecord(@Param("uid") int uid, @Param("ufid") int ufid); 19 | 20 | 21 | 22 | ArrayList getAllFriend(); 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/RegisterSessionDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.sql.Timestamp; 8 | 9 | @Repository 10 | public interface RegisterSessionDao { 11 | 12 | /** 13 | * 添加一条注册信息 14 | * @param createTime 注册信息创建时间 15 | * @param email 注册邮箱 16 | * @param clientIp 注册ip 17 | * @param expireTime 注册信息失效时间 18 | * @return 1:成功;0:失败 19 | */ 20 | int add(@Param("createTime") Timestamp createTime, 21 | @Param("email") String email, 22 | @Param("clientIp") String clientIp, 23 | @Param("expireTime") Timestamp expireTime); 24 | 25 | 26 | /** 27 | * 通过email更新注册状态 28 | * @param email 邮箱 29 | * @param status 状态 30 | * @return 1:更新成功;0:更新失败 31 | */ 32 | int updateStatusByEmail(@Param("email") String email, 33 | @Param("status") Character status); 34 | 35 | 36 | /** 37 | * 根据时间戳批量更新信息 38 | * @param expireTime 注册信息过期时间 39 | * @param status 状态 40 | * @return 更新的条数 41 | */ 42 | int updateStatusByExpireTime(@Param("expireTime")Timestamp expireTime, 43 | @Param("status") Character status); 44 | 45 | /** 46 | * 根据邮箱获取最近的一条注册信息 47 | * @param email 邮箱 48 | * @return 该注册邮箱的失效时间 49 | */ 50 | Timestamp getExpireTimeByEmail(@Param("email") String email); 51 | 52 | 53 | /** 54 | * 通过注册状态获取注册过期时间 55 | * @param status 注册状态 56 | * @param orderBy 排序方式 57 | * @param limit 限制条数 58 | * @param offset 偏移量 59 | * @return 时间戳 或者 null 60 | */ 61 | Timestamp getExpireTimeByStatus(@Param("status") Character status, 62 | @Param("orderBy") String orderBy, 63 | @Param("limit") int limit, 64 | @Param("offset") int offset); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/TestDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | 4 | public class TestDao { 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | 4 | import com.kevin.mirs.entity.User; 5 | import com.kevin.mirs.vo.UserProfile; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.sql.Timestamp; 10 | 11 | @Repository 12 | public interface UserDao { 13 | 14 | /** 15 | * 添加注册用户 16 | * @param user 用户实体 17 | * @return 影响的数目,1:添加成功(同时设置user的id属性),0:用户名/邮箱已存在 18 | */ 19 | int addUser(User user); 20 | 21 | 22 | /** 23 | * 通过用户ID更新用户名 24 | * @param id 用户ID 25 | * @param username 新用户名 26 | * @return 更新的数目,1:更新成功,0:更新失败 27 | */ 28 | int updateUsernameByUserId(@Param("id") int id, @Param("username") String username); 29 | 30 | 31 | /** 32 | * 通过用户ID更新用户密码 33 | * @param id 用户ID 34 | * @param password 新密码 35 | * @return 更新的数目,1:更新成功,0:更新失败 36 | */ 37 | int updateUserPasswordByUserId(@Param("id") int id, @Param("password") String password); 38 | 39 | 40 | /** 41 | * 通过用户ID更新用户加密盐值 42 | * @param id 用户ID 43 | * @param salt 新密码 44 | * @return 更新的数目,1:更新成功,0:更新失败 45 | */ 46 | int updateUserSaltByUserId(@Param("id") int id, @Param("salt") String salt); 47 | 48 | 49 | /** 50 | * 通过用户ID更新用户头像地址,似乎没用 51 | * @param id 用户ID 52 | * @param avatar 头像地址 53 | * @return 更新的数目,1:更新成功,0:更新失败 54 | */ 55 | int updateUserAvatarByUserId(@Param("id") int id, @Param("avatar") String avatar); 56 | 57 | 58 | /** 59 | * 通过用户ID更新用户邮箱 60 | * @param id 用户ID 61 | * @param email 新邮箱 62 | * @return 更新的数目,1:更新成功,0:更新失败 63 | */ 64 | int updateUserEmailByUserId(@Param("id") int id, @Param("email") String email); 65 | 66 | 67 | /** 68 | * 通过用户ID更新用户格言 69 | * @param id 用户ID 70 | * @param bio 新格言 71 | * @return 更新的数目,1:更新成功,0:更新失败 72 | */ 73 | int updateUserBioByUserId(@Param("id") int id, @Param("bio") String bio); 74 | 75 | 76 | /** 77 | * 通过用户ID更新用户地址 78 | * @param id 用户ID 79 | * @param location 新地址 80 | * @return 更新的数目,1:更新成功,0:更新失败 81 | */ 82 | int updateUserLocationByUserId(@Param("id") int id, @Param("location") String location); 83 | 84 | 85 | /** 86 | * 通过用户ID更新用户大学学校信息 87 | * @param id 用户ID 88 | * @param university 新学校 89 | * @return 更新的数目,1:更新成功,0:更新失败 90 | */ 91 | int updateUserUniversityByUserId(@Param("id") int id, @Param("university") String university); 92 | 93 | 94 | /** 95 | * 通过用户ID更新用户专业信息 96 | * @param id 用户ID 97 | * @param major 新专业 98 | * @return 更新的数目,1:更新成功,0:更新失败 99 | */ 100 | int updateUserMajorByUserId(@Param("id") int id, @Param("major") String major); 101 | 102 | 103 | /** 104 | * 通过用户ID更新上次登录信息 105 | * @param id 用户ID 106 | * @param time 登录时间 107 | * @param ip 登录IP 108 | * @return 更新的数目,1:更新成功,0:更新失败 109 | */ 110 | int updateUserLoginInfoByUserId(@Param("id") int id, @Param("time") Timestamp time, @Param("ip") String ip); 111 | 112 | 113 | /** 114 | * 根据用户名获得用户信息 115 | * @param username 用户名 116 | * @return 如果用户存在,返回用户实体,否则,返回NULL 117 | */ 118 | User getUserByUsername(@Param("username") String username); 119 | 120 | 121 | /** 122 | * 根据邮箱获得用户信息 123 | * @param email 邮箱 124 | * @return 如果用户存在,返回用户实体,否则,返回NULL 125 | */ 126 | User getUserByUserEmail(@Param("email") String email); 127 | 128 | 129 | /** 130 | * 检查用户名是否被注册 131 | * @param username 用户名 132 | * @return 1:已被注册;0:未被注册 133 | */ 134 | int checkUsername(@Param("username") String username); 135 | 136 | 137 | /** 138 | * 检查邮箱是否被注册 139 | * @param email 邮箱 140 | * @return 1:已被注册;0:未被注册 141 | */ 142 | int checkUserEmail(@Param("email") String email); 143 | 144 | 145 | /** 146 | * 通过用户ID得到用户信息 147 | * @param id 用户id 148 | * @return 成功:UserProfile; 失败:null 149 | */ 150 | UserProfile getUserProfileByUserId(@Param("id") int id); 151 | 152 | 153 | /** 154 | * 更新用户信息 155 | * @param userProfile 用户信息 156 | * @return 更新的数目,1:更新成功,0:更新失败 157 | */ 158 | int updateUserProfile(UserProfile userProfile); 159 | 160 | 161 | /** 162 | * 通过用户ID得到用户密码和盐 163 | * @param id 用户id 164 | * @return User 165 | */ 166 | User getUserPasswordByUserId(@Param("id") int id); 167 | 168 | 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/UserRecommendedFriendsDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.google.common.collect.HashMultimap; 4 | import com.kevin.mirs.entity.UserRecommendedFriends; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.HashMap; 9 | 10 | 11 | @Repository 12 | public interface UserRecommendedFriendsDao { 13 | 14 | int addUserRecommendedFriends(@Param("uid") int uid, 15 | @Param("rfids") long[] rfids); 16 | 17 | Integer[] getUserRecommendedFriends(@Param("uid") int uid); 18 | 19 | boolean clearUserRecommendedFriends(@Param("uid") int uid); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dao/UserRecommendedMoviesDao.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.entity.UserRecommendedMovies; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface UserRecommendedMoviesDao { 12 | 13 | int addUserRecommendedMovies(@Param("uid") int uid, 14 | @Param("rms")List rms); 15 | 16 | List getUserRecommendedMovies(@Param("uid") int uid); 17 | 18 | boolean clearUserRecommendedMovies(@Param("uid") int uid); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/dto/MIRSResult.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dto; 2 | 3 | 4 | public class MIRSResult { 5 | 6 | private boolean success; 7 | 8 | private T data; 9 | 10 | private String error; 11 | 12 | public MIRSResult(boolean success, T data) { 13 | this.success = success; 14 | this.data = data; 15 | } 16 | 17 | public MIRSResult(boolean success, String error) { 18 | this.success = success; 19 | this.error = error; 20 | } 21 | 22 | public boolean isSuccess() { 23 | return success; 24 | } 25 | 26 | public void setSuccess(boolean success) { 27 | this.success = success; 28 | } 29 | 30 | public T getData() { 31 | return data; 32 | } 33 | 34 | public void setData(T data) { 35 | this.data = data; 36 | } 37 | 38 | public String getError() { 39 | return error; 40 | } 41 | 42 | public void setError(String error) { 43 | this.error = error; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/EmailTemplate.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | public class EmailTemplate { 5 | 6 | private Integer id; 7 | private String title; 8 | private String content; 9 | private Integer sort; 10 | private String description; 11 | private String uniqueIdentity; 12 | 13 | public Integer getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Integer id) { 18 | this.id = id; 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | public String getContent() { 30 | return content; 31 | } 32 | 33 | public void setContent(String content) { 34 | this.content = content; 35 | } 36 | 37 | public Integer getSort() { 38 | return sort; 39 | } 40 | 41 | public void setSort(Integer sort) { 42 | this.sort = sort; 43 | } 44 | 45 | public String getDescription() { 46 | return description; 47 | } 48 | 49 | public void setDescription(String description) { 50 | this.description = description; 51 | } 52 | 53 | public String getUniqueIdentity() { 54 | return uniqueIdentity; 55 | } 56 | 57 | public void setUniqueIdentity(String uniqueIdentity) { 58 | this.uniqueIdentity = uniqueIdentity; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "EmailTemplate{" + 64 | "id=" + id + 65 | ", title='" + title + '\'' + 66 | ", content='" + content + '\'' + 67 | ", sort=" + sort + 68 | ", description='" + description + '\'' + 69 | ", uniqueIdentity='" + uniqueIdentity + '\'' + 70 | '}'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/EmailVerify.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | import java.sql.Timestamp; 5 | 6 | public class EmailVerify { 7 | 8 | private Integer id; 9 | private String email; 10 | private Timestamp createTime; 11 | private Timestamp expireTime; 12 | private Character channel; 13 | private String verifyCode; 14 | private Character verifyType; 15 | private String requestIp; 16 | private Character status; 17 | private String parameter1; 18 | private String parameter2; 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public void setEmail(String email) { 33 | this.email = email; 34 | } 35 | 36 | public Timestamp getCreateTime() { 37 | return createTime; 38 | } 39 | 40 | public void setCreateTime(Timestamp createTime) { 41 | this.createTime = createTime; 42 | } 43 | 44 | public Timestamp getExpireTime() { 45 | return expireTime; 46 | } 47 | 48 | public void setExpireTime(Timestamp expireTime) { 49 | this.expireTime = expireTime; 50 | } 51 | 52 | public Character getChannel() { 53 | return channel; 54 | } 55 | 56 | public void setChannel(Character channel) { 57 | this.channel = channel; 58 | } 59 | 60 | public String getVerifyCode() { 61 | return verifyCode; 62 | } 63 | 64 | public void setVerifyCode(String verifyCode) { 65 | this.verifyCode = verifyCode; 66 | } 67 | 68 | public Character getVerifyType() { 69 | return verifyType; 70 | } 71 | 72 | public void setVerifyType(Character verifyType) { 73 | this.verifyType = verifyType; 74 | } 75 | 76 | public String getRequestIp() { 77 | return requestIp; 78 | } 79 | 80 | public void setRequestIp(String requestIp) { 81 | this.requestIp = requestIp; 82 | } 83 | 84 | public Character getStatus() { 85 | return status; 86 | } 87 | 88 | public void setStatus(Character status) { 89 | this.status = status; 90 | } 91 | 92 | public String getParameter1() { 93 | return parameter1; 94 | } 95 | 96 | public void setParameter1(String parameter1) { 97 | this.parameter1 = parameter1; 98 | } 99 | 100 | public String getParameter2() { 101 | return parameter2; 102 | } 103 | 104 | public void setParameter2(String parameter2) { 105 | this.parameter2 = parameter2; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "EmailVerify{" + 111 | "id=" + id + 112 | ", email='" + email + '\'' + 113 | ", createTime=" + createTime + 114 | ", expireTime=" + expireTime + 115 | ", channel=" + channel + 116 | ", verifyCode='" + verifyCode + '\'' + 117 | ", verifyType=" + verifyType + 118 | ", requestIp='" + requestIp + '\'' + 119 | ", status=" + status + 120 | ", parameter1='" + parameter1 + '\'' + 121 | ", parameter2='" + parameter2 + '\'' + 122 | '}'; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/Friend.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | public class Friend { 5 | 6 | Integer id; 7 | Integer uid; 8 | Integer ufid; 9 | 10 | public Friend(Integer id, Integer uid, Integer ufid) { 11 | this.id = id; 12 | this.uid = uid; 13 | this.ufid = ufid; 14 | } 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public Integer getUid() { 25 | return uid; 26 | } 27 | 28 | public void setUid(Integer uid) { 29 | this.uid = uid; 30 | } 31 | 32 | public Integer getUfid() { 33 | return ufid; 34 | } 35 | 36 | public void setUfid(Integer ufid) { 37 | this.ufid = ufid; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "Friend{" + 43 | "id=" + id + 44 | ", uid=" + uid + 45 | ", ufid=" + ufid + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/OAuthUser.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | public class OAuthUser { 5 | 6 | private Integer id; 7 | private User user; 8 | private String oAuthType; 9 | private String oAuthId; 10 | private String oAuthAccessToken; 11 | private Integer oAuthAccessExpires; 12 | private String oAuthScope; 13 | 14 | public OAuthUser() { 15 | } 16 | 17 | public Integer getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Integer id) { 22 | this.id = id; 23 | } 24 | 25 | public User getUser() { 26 | return user; 27 | } 28 | 29 | public void setUser(User user) { 30 | this.user = user; 31 | } 32 | 33 | public String getoAuthType() { 34 | return oAuthType; 35 | } 36 | 37 | public void setoAuthType(String oAuthType) { 38 | this.oAuthType = oAuthType; 39 | } 40 | 41 | public String getoAuthId() { 42 | return oAuthId; 43 | } 44 | 45 | public void setoAuthId(String oAuthId) { 46 | this.oAuthId = oAuthId; 47 | } 48 | 49 | public String getoAuthAccessToken() { 50 | return oAuthAccessToken; 51 | } 52 | 53 | public void setoAuthAccessToken(String oAuthAccessToken) { 54 | this.oAuthAccessToken = oAuthAccessToken; 55 | } 56 | 57 | public Integer getoAuthAccessExpires() { 58 | return oAuthAccessExpires; 59 | } 60 | 61 | public void setoAuthAccessExpires(Integer oAuthAccessExpires) { 62 | this.oAuthAccessExpires = oAuthAccessExpires; 63 | } 64 | 65 | public String getoAuthScope() { 66 | return oAuthScope; 67 | } 68 | 69 | public void setoAuthScope(String oAuthScope) { 70 | this.oAuthScope = oAuthScope; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "OAuthUser{" + 76 | "id=" + id + 77 | ", user=" + user + 78 | ", oAuthType='" + oAuthType + '\'' + 79 | ", oAuthId='" + oAuthId + '\'' + 80 | ", oAuthAccessToken='" + oAuthAccessToken + '\'' + 81 | ", oAuthAccessExpires=" + oAuthAccessExpires + 82 | ", oAuthScope='" + oAuthScope + '\'' + 83 | '}'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/RegisterSession.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | import java.sql.Timestamp; 5 | 6 | public class RegisterSession { 7 | 8 | private Integer id; 9 | private Timestamp createTime; 10 | private String email; 11 | private Character status; 12 | private String clientIp; 13 | private Timestamp expireTime; 14 | 15 | public Integer getId() { 16 | return id; 17 | } 18 | 19 | public void setId(Integer id) { 20 | this.id = id; 21 | } 22 | 23 | public Timestamp getCreateTime() { 24 | return createTime; 25 | } 26 | 27 | public void setCreateTime(Timestamp createTime) { 28 | this.createTime = createTime; 29 | } 30 | 31 | public String getEmail() { 32 | return email; 33 | } 34 | 35 | public void setEmail(String email) { 36 | this.email = email; 37 | } 38 | 39 | public Character getStatus() { 40 | return status; 41 | } 42 | 43 | public void setStatus(Character status) { 44 | this.status = status; 45 | } 46 | 47 | public String getClientIp() { 48 | return clientIp; 49 | } 50 | 51 | public void setClientIp(String clientIp) { 52 | this.clientIp = clientIp; 53 | } 54 | 55 | public Timestamp getExpireTime() { 56 | return expireTime; 57 | } 58 | 59 | public void setExpireTime(Timestamp expireTime) { 60 | this.expireTime = expireTime; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "RegisterSession{" + 66 | "id=" + id + 67 | ", createTime=" + createTime + 68 | ", email='" + email + '\'' + 69 | ", status=" + status + 70 | ", clientIp='" + clientIp + '\'' + 71 | ", expireTime=" + expireTime + 72 | '}'; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/UserRecommendedFriends.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | /** 4 | * Created by 昊 on 2016/11/7. 5 | */ 6 | public class UserRecommendedFriends { 7 | private Integer id; 8 | private Integer uid; 9 | private Integer rfid; 10 | 11 | public UserRecommendedFriends(Integer id, Integer uid, Integer rfid) { 12 | this.id = id; 13 | this.uid = uid; 14 | this.rfid = rfid; 15 | } 16 | 17 | public int getId() { 18 | return id; 19 | } 20 | 21 | public int getUid() { 22 | return uid; 23 | } 24 | 25 | public int getRfid() { 26 | return rfid; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "UserRecommendedFriends{" + 32 | "id=" + id + 33 | ", uid=" + uid + 34 | ", rfid=" + rfid + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/entity/UserRecommendedMovies.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.entity; 2 | 3 | 4 | public class UserRecommendedMovies { 5 | private int id; 6 | private int uid; 7 | private int rmid; 8 | private float rmv; 9 | 10 | UserRecommendedMovies(){} 11 | public UserRecommendedMovies(Integer id, Integer uid, Integer rmid, Float rmv) { 12 | this.id = id; 13 | this.uid = uid; 14 | this.rmid = rmid; 15 | this.rmv = rmv; 16 | } 17 | 18 | public int getId() { return id; } 19 | 20 | public int getUid() { 21 | return uid; 22 | } 23 | 24 | public int getRmid() { 25 | return rmid; 26 | } 27 | 28 | public float getRmv() { 29 | return rmv; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "UserRecommendedMovies{" + 35 | "uid=" + uid + 36 | ", rmid=" + rmid + 37 | ", rmv=" + rmv + 38 | '}'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/enums/EVChannelEnum.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.enums; 2 | 3 | /** 4 | * 邮件验证状态枚举 5 | */ 6 | public enum EVChannelEnum { 7 | WEB('1', "网页版") 8 | ; 9 | 10 | 11 | private Character channel; 12 | private String description; 13 | 14 | EVChannelEnum(Character channel, String description) { 15 | this.channel = channel; 16 | this.description = description; 17 | } 18 | 19 | public Character getChannel() { 20 | return channel; 21 | } 22 | 23 | public String getDescription() { 24 | return description; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/enums/EVStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.enums; 2 | 3 | /** 4 | * 邮件验证状态枚举 5 | */ 6 | public enum EVStatusEnum { 7 | ING('1', "正在验证"), 8 | EXPIRED('2', "验证超时"), 9 | FAILED('3', "验证失败"), 10 | SUCCESS('4', "验证成功") 11 | ; 12 | 13 | 14 | private Character status; 15 | private String description; 16 | 17 | EVStatusEnum(Character status, String description) { 18 | this.status = status; 19 | this.description = description; 20 | } 21 | 22 | public Character getStatus() { 23 | return status; 24 | } 25 | 26 | public String getDescription() { 27 | return description; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/enums/EVTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.enums; 2 | 3 | /** 4 | * 邮件验证状态枚举 5 | */ 6 | public enum EVTypeEnum { 7 | REG('1', "注册"), 8 | RESET('2', "找回密码"), 9 | UNUSUAL_LOGIN('3', "异地登陆") 10 | ; 11 | 12 | 13 | private Character type; 14 | private String description; 15 | 16 | EVTypeEnum(Character type, String description) { 17 | this.type = type; 18 | this.description = description; 19 | } 20 | 21 | public Character getType() { 22 | return type; 23 | } 24 | 25 | public String getDescription() { 26 | return description; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/enums/MovieColumnEnum.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.enums; 2 | 3 | /** 4 | * 将Movie的列名与数字对应起来,保证数据安全 5 | */ 6 | public enum MovieColumnEnum { 7 | ID(1, "id", 1.0F), 8 | DOUBAN_ID(2, "douban_id", 1.0F), 9 | NAME(3, "name", 10.0F), 10 | DOUBAN_RATING(4, "douban_rating", 1.0F), 11 | IMDB_RATING(5, "imdb_rating", 1.0F), 12 | RELEASE_YEAR(6, "release_year", 1.0F), 13 | DIRECTORS(7, "directors", 8.0F), 14 | SCREENWRITERS(8, "screenwriters", 7.0F), 15 | ACTORS(9, "actors", 6.0F), 16 | TYPES(10, "types", 2.0F), 17 | OFFICIAL_WEBSITE(11, "official_website", 1.0F), 18 | ORIGIN_PLACE(12, "origin_place", 2.0F), 19 | RELEASE_DATE(13, "release_date", 1.0F), 20 | LANGUAGES(14, "languages", 2.0F), 21 | RUNTIME(15, "runtime", 1.0F), 22 | ANOTHER_NAMES(16, "another_names", 9.0F), 23 | IMDB_LINK(17, "imdb_link", 1.0F), 24 | COVER_LINK(18, "cover_link", 1.0F), 25 | SYNOPSIS(19, "synopsis", 3.0F), 26 | STILLS_PHOTOS_LINKS(20, "stills_photos_links", 1.0F), 27 | POSTER_PHOTOS_LINKS(21, "poster_photos_links", 1.0F), 28 | WALLPAPER_PHOTOS_LINKS(22, "wallpaper_photos_links", 1.0F), 29 | AWARDS(24, "awards", 2.0F), 30 | ALSO_LIKE_MOVIES(25, "also_like_movies", 1.0F), 31 | REVIEWS(26, "reviews", 2.0F), 32 | SHORT_POP_COMMENTS(27, "short_pop_comments", 2.0F); 33 | 34 | 35 | private int index; 36 | private String name; 37 | private float boost;//权重 38 | 39 | MovieColumnEnum(int index, String column, float boost) { 40 | this.index = index; 41 | this.name = column; 42 | this.boost = boost; 43 | } 44 | 45 | public int getIndex() { 46 | return index; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public float getBoost() { 54 | return boost; 55 | } 56 | 57 | 58 | public static String columnOf(int index) { 59 | for (MovieColumnEnum movieColumnEnum : values()) { 60 | if(movieColumnEnum.getIndex() == index) { 61 | return movieColumnEnum.getName(); 62 | } 63 | } 64 | return null; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/enums/RSStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.enums; 2 | 3 | 4 | /** 5 | * 注册状态枚举 6 | */ 7 | public enum RSStatusEnum { 8 | ING('1', "正在注册"), 9 | EXPIRED('2', "注册超时"), 10 | FAILED('3', "注册失败"), 11 | SUCCESS('4', "注册成功") 12 | ; 13 | 14 | 15 | private Character status; 16 | private String description; 17 | 18 | RSStatusEnum(Character status, String description) { 19 | this.status = status; 20 | this.description = description; 21 | } 22 | 23 | public Character getStatus() { 24 | return status; 25 | } 26 | 27 | public String getDescription() { 28 | return description; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/jobs/Jobs.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.jobs; 2 | 3 | 4 | import com.kevin.mirs.dao.EmailVerifyDao; 5 | import com.kevin.mirs.dao.RegisterSessionDao; 6 | import com.kevin.mirs.enums.EVStatusEnum; 7 | import com.kevin.mirs.enums.RSStatusEnum; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.scheduling.annotation.Async; 11 | import org.springframework.scheduling.annotation.EnableAsync; 12 | import org.springframework.scheduling.annotation.EnableScheduling; 13 | import org.springframework.scheduling.annotation.Scheduled; 14 | import org.springframework.stereotype.Component; 15 | 16 | import javax.annotation.Resource; 17 | import java.sql.Timestamp; 18 | import java.util.Date; 19 | 20 | @Component 21 | @EnableAsync 22 | @EnableScheduling 23 | public class Jobs { 24 | 25 | private static final int LIMIT = 1; 26 | private static final String ORDER_BY = "expire_time"; 27 | 28 | // 5分钟 29 | private static final long RST = 5 * 60 * 1000; 30 | private static final long EVT = 5 * 60 * 1000; 31 | 32 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 33 | 34 | @Resource 35 | RegisterSessionDao registerSessionDao; 36 | 37 | @Resource 38 | EmailVerifyDao emailVerifyDao; 39 | 40 | @Async 41 | @Scheduled(fixedRate = RST) 42 | // 每隔5分钟定时执行 43 | protected void isRegisterSessionExpired() { 44 | logger.info("--------------------开始定时任务:规整数据库的注册信息------------------------"); 45 | 46 | int offset = 0; 47 | int total = 0; 48 | Timestamp expireTime = null; 49 | while (null != (expireTime = registerSessionDao.getExpireTimeByStatus(RSStatusEnum.ING.getStatus(), ORDER_BY, LIMIT, offset))) { 50 | offset++; 51 | // 如果超时,则更新状态 52 | if (expireTime.getTime() < new Date().getTime()) { 53 | total += registerSessionDao.updateStatusByExpireTime( 54 | expireTime, 55 | RSStatusEnum.FAILED.getStatus()); 56 | } 57 | } 58 | 59 | logger.info("--------------------完成定时任务:规整数据库的注册信息------------------------"); 60 | logger.info("--------------------共更新了" + total + "条信息"); 61 | } 62 | 63 | @Async 64 | @Scheduled(fixedRate = EVT) 65 | protected void isEmailVerifyExpired() { 66 | logger.info("--------------------开始定时任务:规整数据库的邮件验证信息------------------------"); 67 | 68 | int offset = 0; 69 | int total = 0; 70 | Timestamp expireTime = null; 71 | while (null != (expireTime = emailVerifyDao.getExpireTimeByStatus(EVStatusEnum.ING.getStatus(), ORDER_BY, LIMIT, offset))) { 72 | offset++; 73 | // 如果超时,则更新状态 74 | if (expireTime.getTime() < new Date().getTime()) { 75 | total += emailVerifyDao.updateStatusByExpireTime( 76 | expireTime, 77 | EVStatusEnum.FAILED.getStatus()); 78 | } 79 | } 80 | 81 | logger.info("--------------------完成定时任务:规整数据库的邮件验证信息------------------------"); 82 | logger.info("--------------------共更新了" + total + "条信息"); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/MahoutTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | 4 | import org.apache.mahout.cf.taste.impl.model.file.FileDataModel; 5 | import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood; 6 | import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender; 7 | import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity; 8 | import org.apache.mahout.cf.taste.model.DataModel; 9 | import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; 10 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 11 | import org.apache.mahout.cf.taste.recommender.Recommender; 12 | import org.apache.mahout.cf.taste.similarity.UserSimilarity; 13 | 14 | import java.io.File; 15 | import java.util.List; 16 | 17 | 18 | public class MahoutTest { 19 | 20 | public static void main(String[] args) { 21 | try { 22 | // 从文件加载数据 23 | DataModel model = new FileDataModel(new File("src/main/resources/recommendation/test.csv")); 24 | // 指定用户相似度计算方法,这里采用皮尔森相关度 25 | UserSimilarity similarity = new PearsonCorrelationSimilarity(model); 26 | // 指定用户邻居数量,这里为20 27 | UserNeighborhood neighborhood = new NearestNUserNeighborhood(20, similarity, model); 28 | // 构建用户推荐系统 29 | Recommender recommender = new GenericUserBasedRecommender(model, neighborhood, similarity); 30 | // 得到指定用户的推荐结果,这里是得到用户1的两个推荐 31 | List recommendedItemList = recommender.recommend(1,2); 32 | //打印推荐结果 33 | for(RecommendedItem recommendedItem : recommendedItemList) { 34 | System.out.println(recommendedItem); 35 | } 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/RecommendFriends.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | import org.apache.mahout.cf.taste.model.DataModel; 4 | import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; 5 | import org.apache.mahout.cf.taste.recommender.Recommender; 6 | import org.apache.mahout.cf.taste.similarity.UserSimilarity; 7 | 8 | /** 9 | * Created by 昊 on 2016/11/5. 10 | */ 11 | public interface RecommendFriends { 12 | long[] recommendFriends(long uid, int frdnum); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/RecommendFriendsBySimilarity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood; 4 | import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity; 5 | import org.apache.mahout.cf.taste.model.DataModel; 6 | import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; 7 | import org.apache.mahout.cf.taste.similarity.UserSimilarity; 8 | 9 | /** 10 | * Created by 昊 on 2016/11/5. 11 | */ 12 | public class RecommendFriendsBySimilarity implements RecommendFriends{ 13 | private DataModel model; 14 | private UserSimilarity similarity; 15 | private UserNeighborhood neighborhood; 16 | public RecommendFriendsBySimilarity(DataModel model){ 17 | this.model = model; 18 | try { 19 | similarity = new PearsonCorrelationSimilarity(model); 20 | } catch (Exception e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | @Override 26 | public long[] recommendFriends(long uid, int frdnum){ 27 | long[] neighbors = new long[frdnum]; 28 | try { 29 | neighborhood = new NearestNUserNeighborhood(frdnum, similarity, model); 30 | neighbors = neighborhood.getUserNeighborhood(uid); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } 34 | return neighbors; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/RecommendMovies.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 昊 on 2016/11/5. 9 | */ 10 | public interface RecommendMovies { 11 | List recommendMovies(int uid, int itemNum); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/RecommendMoviesByPerson.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood; 4 | import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender; 5 | import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity; 6 | import org.apache.mahout.cf.taste.model.DataModel; 7 | import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; 8 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 9 | import org.apache.mahout.cf.taste.recommender.Recommender; 10 | import org.apache.mahout.cf.taste.similarity.UserSimilarity; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by 昊 on 2016/11/5. 17 | */ 18 | public class RecommendMoviesByPerson implements RecommendMovies{ 19 | private DataModel model; 20 | private UserSimilarity similarity; 21 | private UserNeighborhood neighborhood; 22 | private Recommender recommender; 23 | public RecommendMoviesByPerson(DataModel model, int frdN){ 24 | this.model = model; 25 | try { 26 | similarity = new PearsonCorrelationSimilarity(model); 27 | neighborhood = new NearestNUserNeighborhood(frdN, similarity, model); 28 | recommender = new GenericUserBasedRecommender(model, neighborhood, similarity); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | 34 | @Override 35 | public List recommendMovies(int uid, int itemNum){ 36 | List recommendedItemList = new ArrayList(itemNum); 37 | try { 38 | recommendedItemList = recommender.recommend(uid,itemNum); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | return recommendedItemList; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/recommendation/RecommendationController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.recommendation; 2 | 3 | 4 | import org.apache.mahout.cf.taste.impl.model.file.FileDataModel; 5 | import org.apache.mahout.cf.taste.model.DataModel; 6 | 7 | 8 | import java.io.*; 9 | 10 | public class RecommendationController { 11 | 12 | public static void main(String[] args){ 13 | try{ 14 | // MysqlDataSource dataSource = new MysqlDataSource(); 15 | // dataSource.setServerName("localhost"); 16 | // dataSource.setUser("root"); 17 | // dataSource.setPassword("12345678"); 18 | // dataSource.setDatabaseName("mirs"); 19 | // JDBCDataModel model = new MySQLJDBCDataModel(dataSource, "mirs_user_movie", "uid", "mid", "score", null); 20 | DataModel model = new FileDataModel(new File("E:/AppServ/www/mirs/target/classes/recommendation/test.csv")); 21 | RecommendFriends recommendFriends = new RecommendFriendsBySimilarity(model); 22 | RecommendMovies recommendMovies = new RecommendMoviesByPerson(model, 20); 23 | long[] friends = recommendFriends.recommendFriends(1, 3); 24 | //List recommendedItemList = recommendMovies.recommendMovies(1,2); 25 | //urmv.clearUserRecommendedMovies(); 26 | //urfd.clearUserRecommendedFriends(); 27 | //System.out.println(urmv.addUserRecommendedMovies(1,recommendedItemList)); 28 | //System.out.println(urfd.addUserRecommendedFriends(1,friends)); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/service/EmailService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.mail.MailSendException; 7 | import org.springframework.mail.SimpleMailMessage; 8 | import org.springframework.mail.javamail.JavaMailSenderImpl; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | 13 | 14 | @Service 15 | public class EmailService { 16 | 17 | private static final String SUBJECT = "来自电影智能推荐系统的邮件"; 18 | 19 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 20 | 21 | @Resource 22 | private JavaMailSenderImpl sender; 23 | 24 | // TODO: 2016/11/23 按照不同的邮件类型封装不同的方法:注册,找回密码等 25 | 26 | public boolean sendVerificationEmail(String sendTo, String verification) { 27 | 28 | logger.info("--------------------sendVerificationEmail:" + sendTo + "--------------------"); 29 | 30 | // 构建简单邮件对象,见名知意 31 | SimpleMailMessage smm = new SimpleMailMessage(); 32 | // 设定邮件参数 33 | smm.setFrom(sender.getUsername()); 34 | smm.setTo(sendTo); 35 | smm.setSubject(SUBJECT); 36 | smm.setText("您的验证码是:" + verification + "\n如果不是本人操作,请忽略此信息。"); 37 | 38 | try { 39 | sender.send(smm); 40 | } catch (MailSendException e) { 41 | e.printStackTrace(); 42 | logger.info("--------------------sendVerificationEmail failed--------------------"); 43 | 44 | return false; 45 | } 46 | logger.info("--------------------sendVerificationEmail:" + sendTo + " succeed--------------------"); 47 | return true; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/service/MovieService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import com.kevin.mirs.dao.MovieDao; 4 | import com.kevin.mirs.entity.Movie; 5 | import com.kevin.mirs.enums.MovieColumnEnum; 6 | import com.kevin.mirs.vo.SimpleMovie; 7 | import com.kevin.mirs.vo.SuggestionMovie; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.ArrayList; 14 | 15 | @Service 16 | public class MovieService { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Resource 21 | MovieDao movieDao; 22 | 23 | 24 | public Movie getMovieByMovieId(int id) { 25 | 26 | logger.info("--------------------getMovieByMovieId--------------------"); 27 | 28 | Movie movie = null; 29 | try { 30 | movie = movieDao.getMovieById(id); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } 34 | return movie; 35 | } 36 | 37 | public ArrayList getTodayMovies() { 38 | 39 | logger.info("--------------------getTodayMovies--------------------"); 40 | 41 | int limit = 6; 42 | ArrayList suggestionMovies = null; 43 | 44 | try { 45 | suggestionMovies = movieDao.getRandomSimpleMovies(limit); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | return suggestionMovies; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/service/RecommendService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import com.kevin.mirs.dao.UserRecommendedFriendsDao; 4 | import com.kevin.mirs.dao.UserRecommendedMoviesDao; 5 | import com.kevin.mirs.entity.UserRecommendedMovies; 6 | import com.kevin.mirs.recommendation.RecommendFriends; 7 | import com.kevin.mirs.recommendation.RecommendFriendsBySimilarity; 8 | import com.kevin.mirs.recommendation.RecommendMovies; 9 | import com.kevin.mirs.recommendation.RecommendMoviesByPerson; 10 | import java.util.List; 11 | 12 | 13 | import org.apache.mahout.cf.taste.impl.model.jdbc.MySQLJDBCDataModel; 14 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 15 | import org.springframework.stereotype.Service; 16 | 17 | import javax.annotation.Resource; 18 | 19 | 20 | @Service 21 | public class RecommendService{ 22 | @Resource 23 | UserRecommendedMoviesDao rm; 24 | 25 | @Resource 26 | UserRecommendedFriendsDao rf; 27 | 28 | @Resource 29 | MySQLJDBCDataModel data; 30 | 31 | 32 | public List getRealTimeRecommendedMovies(int uid){ 33 | RecommendMovies recommendMovies = new RecommendMoviesByPerson(data, 20); 34 | rm.clearUserRecommendedMovies(uid); 35 | rm.addUserRecommendedMovies(uid, recommendMovies.recommendMovies(uid,2)); 36 | return recommendMovies.recommendMovies(uid,2); 37 | } 38 | 39 | public int addRecommendedMovies(int uid){ 40 | List recommendedMovies = getRealTimeRecommendedMovies(uid); 41 | rm.clearUserRecommendedMovies(uid); 42 | return rm.addUserRecommendedMovies(uid, recommendedMovies); 43 | } 44 | 45 | public List getRecommendedMoviesFromDB(int uid){ 46 | return rm.getUserRecommendedMovies(uid); 47 | } 48 | 49 | public long[] getRealTimeRecommendedFriends(int uid){ 50 | RecommendFriends recommendFriends = new RecommendFriendsBySimilarity(data); 51 | rf.clearUserRecommendedFriends(uid); 52 | rf.addUserRecommendedFriends(uid, recommendFriends.recommendFriends(uid, 10)); 53 | return recommendFriends.recommendFriends(uid, 10); 54 | } 55 | 56 | public int addRecommendedFriends(int uid){ 57 | long[] recommendedFriends = getRealTimeRecommendedFriends(uid); 58 | rf.clearUserRecommendedFriends(uid); 59 | return rf.addUserRecommendedFriends(uid, recommendedFriends); 60 | } 61 | 62 | public Integer[] getRecommendedFriendsFromDB(int uid){ 63 | return rf.getUserRecommendedFriends(uid); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/service/SockJSHandler.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.server.ServerHttpRequest; 7 | import org.springframework.http.server.ServerHttpResponse; 8 | import org.springframework.http.server.ServletServerHttpRequest; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.web.socket.WebSocketHandler; 11 | import org.springframework.web.socket.WebSocketSession; 12 | import org.springframework.web.socket.server.HandshakeFailureException; 13 | import org.springframework.web.socket.server.HandshakeHandler; 14 | 15 | import javax.servlet.http.HttpSession; 16 | import java.util.ArrayList; 17 | import java.util.Map; 18 | 19 | @Service 20 | public class SockJSHandler implements HandshakeHandler { 21 | 22 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 23 | private static final ArrayList users = new ArrayList(); 24 | 25 | @Override 26 | public boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, Map map) throws HandshakeFailureException { 27 | ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; 28 | HttpSession session = servletRequest.getServletRequest().getSession(); 29 | users.add(session); 30 | System.out.println(session); 31 | return true; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/service/SocketHandler.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.socket.*; 8 | 9 | import java.io.IOException; 10 | import java.util.ArrayList; 11 | 12 | @Service 13 | public class SocketHandler implements WebSocketHandler { 14 | 15 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 16 | private static final ArrayList users = new ArrayList(); 17 | 18 | 19 | @Override 20 | public void afterConnectionEstablished(WebSocketSession session) 21 | throws Exception { 22 | logger.info("成功建立socket连接"); 23 | users.add(session); 24 | String id = session.getAttributes().get("id").toString(); 25 | if(id != null){ 26 | session.sendMessage(new TextMessage("我们已经成功建立soket通信了")); 27 | } 28 | 29 | } 30 | 31 | @Override 32 | public void handleMessage(WebSocketSession arg0, WebSocketMessage arg1) 33 | throws Exception { 34 | // TODO Auto-generated method stub 35 | 36 | } 37 | 38 | @Override 39 | public void handleTransportError(WebSocketSession session, Throwable error) 40 | throws Exception { 41 | if(session.isOpen()){ 42 | session.close(); 43 | } 44 | logger.error("连接出现错误:"+error.toString()); 45 | users.remove(session); 46 | } 47 | 48 | @Override 49 | public void afterConnectionClosed(WebSocketSession session, CloseStatus arg1) 50 | throws Exception { 51 | logger.debug("连接已关闭"); 52 | users.remove(session); 53 | } 54 | 55 | @Override 56 | public boolean supportsPartialMessages() { 57 | return false; 58 | } 59 | 60 | /** 61 | * 给所有在线用户发送消息 62 | * 63 | * @param message 64 | */ 65 | public void sendMessageToUsers(TextMessage message) { 66 | for (WebSocketSession user : users) { 67 | try { 68 | if (user.isOpen()) { 69 | user.sendMessage(message); 70 | } 71 | } catch (IOException e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | } 76 | 77 | /** 78 | * 给某个用户发送消息 79 | * 80 | * @param id 81 | * @param message 82 | */ 83 | public void sendMessageToUser(String id, TextMessage message) { 84 | for (WebSocketSession user : users) { 85 | if (user.getAttributes().get("id").equals(id)) { 86 | try { 87 | if (user.isOpen()) { 88 | user.sendMessage(message); 89 | } 90 | } catch (IOException e) { 91 | e.printStackTrace(); 92 | } 93 | break; 94 | } 95 | } 96 | } 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/utils/EncryptionUtils.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | 4 | import org.apache.shiro.crypto.hash.Sha512Hash; 5 | 6 | import java.util.Random; 7 | 8 | public class EncryptionUtils { 9 | 10 | private static final int VERIFICATION_LENGTH = 6; 11 | 12 | public static String getSalt(int length) { 13 | String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 14 | Random random = new Random(); 15 | StringBuffer buf = new StringBuffer(); 16 | for (int i = 0; i < length; i++) { 17 | int num = random.nextInt(str.length()); 18 | buf.append(str.charAt(num)); 19 | } 20 | return buf.toString(); 21 | } 22 | 23 | public static String SHA512Encode(String content, String salt) { 24 | return new Sha512Hash(content, salt, 100).toString(); 25 | } 26 | 27 | public static String getVerification() { 28 | return getSalt(VERIFICATION_LENGTH); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/utils/FormatUtils.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | 7 | public class FormatUtils { 8 | 9 | public static boolean emailFormat(String email) 10 | { 11 | boolean tag = true; 12 | String regex = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$"; 13 | Pattern pattern = Pattern.compile(regex); 14 | final Matcher mat = pattern.matcher(email); 15 | if (!mat.find()) { 16 | tag = false; 17 | } 18 | return tag; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/utils/IPUtils.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | 9 | public class IPUtils { 10 | 11 | /** 12 | * 获取访问者IP 13 | * 14 | * 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。 15 | * 16 | * 本方法先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割), 17 | * 如果还不存在则调用Request .getRemoteAddr()。 18 | * 19 | * @param request 20 | * @return 21 | */ 22 | public static String getIpAddr(HttpServletRequest request){ 23 | String ip = request.getHeader("X-Real-IP"); 24 | if (!StringUtils.isBlank(ip) && !"unknown".equalsIgnoreCase(ip)) { 25 | return ip; 26 | } 27 | ip = request.getHeader("X-Forwarded-For"); 28 | if (!StringUtils.isBlank(ip) && !"unknown".equalsIgnoreCase(ip)) { 29 | // 多次反向代理后会有多个IP值,第一个为真实IP。 30 | int index = ip.indexOf(','); 31 | if (index != -1) { 32 | return ip.substring(0, index); 33 | } else { 34 | return ip; 35 | } 36 | } else { 37 | return request.getRemoteAddr(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/utils/LuceneUtils.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | 4 | import org.apache.commons.beanutils.BeanUtils; 5 | import org.apache.lucene.document.Document; 6 | import org.apache.lucene.document.Field; 7 | import org.apache.lucene.document.TextField; 8 | 9 | import javax.annotation.Resource; 10 | 11 | public class LuceneUtils { 12 | 13 | @Resource 14 | Document document; 15 | 16 | //将JavaBean转成Document对象 17 | public static Document javabean2document(Object obj) throws Exception{ 18 | //创建Document对象 19 | Document document = new Document(); 20 | //获取obj引用的对象字节码 21 | Class clazz = obj.getClass(); 22 | //通过对象字节码获取私有的属性 23 | java.lang.reflect.Field[] reflectFields = clazz.getDeclaredFields(); 24 | //迭代 25 | for(java.lang.reflect.Field reflectField : reflectFields){ 26 | //反射 27 | reflectField.setAccessible(true); 28 | //获取字段名 29 | String name = reflectField.getName(); 30 | //获取字段值 31 | String value = reflectField.get(obj).toString(); 32 | //加入到Document对象中去,这时javabean的属性与document对象的属性相同 33 | document.add(new Field(name, value, TextField.TYPE_STORED)); 34 | } 35 | //返回document对象 36 | return document; 37 | } 38 | 39 | //将Document对象转换成JavaBean对象 40 | public static T document2javabean(Document document,Class clazz) throws Exception{ 41 | T obj = clazz.newInstance(); 42 | java.lang.reflect.Field[] reflectFields = clazz.getDeclaredFields(); 43 | for(java.lang.reflect.Field reflectField : reflectFields){ 44 | reflectField.setAccessible(true); 45 | String name = reflectField.getName(); 46 | String value = document.get(name); 47 | BeanUtils.setProperty(obj, name, value); 48 | } 49 | return obj; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/LoginInfo.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class LoginInfo { 5 | 6 | private String username; 7 | private String token; 8 | 9 | public LoginInfo(String username, String token) { 10 | this.username = username; 11 | this.token = token; 12 | } 13 | 14 | public String getUsername() { 15 | return username; 16 | } 17 | 18 | public String getToken() { 19 | return token; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "LoginInfo{" + 25 | "username='" + username + '\'' + 26 | ", token='" + token + '\'' + 27 | '}'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class LoginUser { 5 | 6 | private String username; 7 | private String password; 8 | private String captcha; 9 | 10 | // FIXME: 2016/11/20 奇怪,不加上默认构造器就出错 11 | public LoginUser() { 12 | } 13 | 14 | public LoginUser(String username, String password, String captcha) { 15 | this.username = username; 16 | this.password = password; 17 | this.captcha = captcha; 18 | } 19 | 20 | public String getUsername() { 21 | return username; 22 | } 23 | 24 | public String getPassword() { 25 | return password; 26 | } 27 | 28 | public String getCaptcha() { 29 | return captcha; 30 | } 31 | 32 | public void setUsername(String username) { 33 | this.username = username; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | 40 | public void setCaptcha(String captcha) { 41 | this.captcha = captcha; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "LoginUser{" + 47 | "username='" + username + '\'' + 48 | ", password='" + password + '\'' + 49 | ", captcha='" + captcha + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/RegisterInfo.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | import java.sql.Timestamp; 5 | 6 | public class RegisterInfo { 7 | 8 | private String username; 9 | private String email; 10 | private String token; 11 | private Timestamp registerTime; 12 | private String registerIp; 13 | 14 | public RegisterInfo(String username, String email, String token, Timestamp registerTime, String registerIp) { 15 | this.username = username; 16 | this.email = email; 17 | this.token = token; 18 | this.registerTime = registerTime; 19 | this.registerIp = registerIp; 20 | } 21 | 22 | public String getUsername() { 23 | return username; 24 | } 25 | 26 | public String getEmail() { 27 | return email; 28 | } 29 | 30 | public String getToken() { 31 | return token; 32 | } 33 | 34 | public Timestamp getRegisterTime() { 35 | return registerTime; 36 | } 37 | 38 | public String getRegisterIp() { 39 | return registerIp; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "RegisterInfo{" + 45 | "username='" + username + '\'' + 46 | ", email='" + email + '\'' + 47 | ", token='" + token + '\'' + 48 | ", registerTime=" + registerTime + 49 | ", registerIp='" + registerIp + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/RegisterUser.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class RegisterUser { 5 | 6 | private String username; 7 | private String email; 8 | private String password; 9 | private String verification; 10 | 11 | public RegisterUser() { 12 | } 13 | 14 | public RegisterUser(String username, String email, String password, String verification) { 15 | this.username = username; 16 | this.email = email; 17 | this.password = password; 18 | this.verification = verification; 19 | } 20 | 21 | public String getUsername() { 22 | return username; 23 | } 24 | 25 | public String getEmail() { 26 | return email; 27 | } 28 | 29 | public String getPassword() { 30 | return password; 31 | } 32 | 33 | public String getVerification() { 34 | return verification; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "RegisterUser{" + 40 | "username='" + username + '\'' + 41 | ", email='" + email + '\'' + 42 | ", password='" + password + '\'' + 43 | ", verification='" + verification + '\'' + 44 | '}'; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/SimpleMovie.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class SimpleMovie { 5 | 6 | private Integer id; 7 | private String name; 8 | private String doubanRating; 9 | private String imdbRating; 10 | private String releaseYear; 11 | private String directors; 12 | private String screenwriters; 13 | private String actors; 14 | private String types; 15 | private String originPlace; 16 | private String languages; 17 | private String runtime; 18 | private String coverLink; 19 | private String synopsis; 20 | 21 | public SimpleMovie(Integer id, String name, String doubanRating, String imdbRating, String releaseYear, String directors, String screenwriters, String actors, String types, String originPlace, String languages, String runtime, String coverLink, String synopsis) { 22 | this.id = id; 23 | this.name = name; 24 | this.doubanRating = doubanRating; 25 | this.imdbRating = imdbRating; 26 | this.releaseYear = releaseYear; 27 | this.directors = directors; 28 | this.screenwriters = screenwriters; 29 | this.actors = actors; 30 | this.types = types; 31 | this.originPlace = originPlace; 32 | this.languages = languages; 33 | this.runtime = runtime; 34 | this.coverLink = coverLink; 35 | this.synopsis = synopsis; 36 | } 37 | 38 | public Integer getId() { 39 | return id; 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public String getDoubanRating() { 47 | return doubanRating; 48 | } 49 | 50 | public String getImdbRating() { 51 | return imdbRating; 52 | } 53 | 54 | public String getReleaseYear() { 55 | return releaseYear; 56 | } 57 | 58 | public String getDirectors() { 59 | return directors; 60 | } 61 | 62 | public String getScreenwriters() { 63 | return screenwriters; 64 | } 65 | 66 | public String getActors() { 67 | return actors; 68 | } 69 | 70 | public String getTypes() { 71 | return types; 72 | } 73 | 74 | public String getOriginPlace() { 75 | return originPlace; 76 | } 77 | 78 | public String getLanguages() { 79 | return languages; 80 | } 81 | 82 | public String getRuntime() { 83 | return runtime; 84 | } 85 | 86 | public String getCoverLink() { 87 | return coverLink; 88 | } 89 | 90 | public String getSynopsis() { 91 | return synopsis; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return "SimpleMovie{" + 97 | "id=" + id + 98 | ", name='" + name + '\'' + 99 | ", doubanRating='" + doubanRating + '\'' + 100 | ", imdbRating='" + imdbRating + '\'' + 101 | ", releaseYear='" + releaseYear + '\'' + 102 | ", directors='" + directors + '\'' + 103 | ", screenwriters='" + screenwriters + '\'' + 104 | ", actors='" + actors + '\'' + 105 | ", types='" + types + '\'' + 106 | ", originPlace='" + originPlace + '\'' + 107 | ", languages='" + languages + '\'' + 108 | ", runtime='" + runtime + '\'' + 109 | ", coverLink='" + coverLink + '\'' + 110 | ", synopsis='" + synopsis + '\'' + 111 | '}'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/SimpleUserMessage.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class SimpleUserMessage { 5 | 6 | private String from; 7 | private String to; 8 | private int type; 9 | private String content; 10 | 11 | public SimpleUserMessage() { 12 | } 13 | 14 | public SimpleUserMessage(String from, String to, int type, String content) { 15 | this.from = from; 16 | this.to = to; 17 | this.type = type; 18 | this.content = content; 19 | } 20 | 21 | public String getFrom() { 22 | return from; 23 | } 24 | 25 | public void setFrom(String from) { 26 | this.from = from; 27 | } 28 | 29 | public String getTo() { 30 | return to; 31 | } 32 | 33 | public void setTo(String to) { 34 | this.to = to; 35 | } 36 | 37 | public int getType() { 38 | return type; 39 | } 40 | 41 | public void setType(int type) { 42 | this.type = type; 43 | } 44 | 45 | public String getContent() { 46 | return content; 47 | } 48 | 49 | public void setContent(String content) { 50 | this.content = content; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return "SimpleUserMessage{" + 56 | "from='" + from + '\'' + 57 | ", to='" + to + '\'' + 58 | ", type=" + type + 59 | ", content='" + content + '\'' + 60 | '}'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/SuggestionMovie.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class SuggestionMovie { 5 | 6 | private final String URL_PERFIX = ""; 7 | 8 | private String url; 9 | private String name; 10 | private String pic; 11 | 12 | public SuggestionMovie(Integer id, String name, String pic) { 13 | this.url = URL_PERFIX + id; 14 | this.name = name; 15 | this.pic = pic; 16 | } 17 | 18 | 19 | public String getUrl() { 20 | return url; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | 28 | public String getPic() { 29 | return pic; 30 | } 31 | 32 | 33 | @Override 34 | public String toString() { 35 | return "SuggestionMovie{" + 36 | "url='" + url + '\'' + 37 | ", name='" + name + '\'' + 38 | ", pic='" + pic + '\'' + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/Url.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | public class Url { 5 | 6 | private String url; 7 | 8 | public Url(String url) { 9 | this.url = url; 10 | } 11 | 12 | public String getUrl() { 13 | return url; 14 | } 15 | 16 | public void setUrl(String url) { 17 | this.url = url; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "Url{" + 23 | "url='" + url + '\'' + 24 | '}'; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/vo/UserProfile.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.vo; 2 | 3 | 4 | import java.sql.Timestamp; 5 | 6 | public class UserProfile { 7 | 8 | private Integer id; 9 | private String username; 10 | private String email; 11 | private String bio; 12 | private String location; 13 | private String university; 14 | private String major; 15 | 16 | public UserProfile() { 17 | } 18 | 19 | public UserProfile(Integer id, String username, String email, String bio, String location, String university, String major) { 20 | this.id = id; 21 | this.username = username; 22 | this.email = email; 23 | this.bio = bio; 24 | this.location = location; 25 | this.university = university; 26 | this.major = major; 27 | } 28 | 29 | public Integer getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Integer id) { 34 | this.id = id; 35 | } 36 | 37 | public String getUsername() { 38 | return username; 39 | } 40 | 41 | public void setUsername(String username) { 42 | this.username = username; 43 | } 44 | 45 | public String getEmail() { 46 | return email; 47 | } 48 | 49 | public void setEmail(String email) { 50 | this.email = email; 51 | } 52 | 53 | public String getBio() { 54 | return bio; 55 | } 56 | 57 | public void setBio(String bio) { 58 | this.bio = bio; 59 | } 60 | 61 | public String getLocation() { 62 | return location; 63 | } 64 | 65 | public void setLocation(String location) { 66 | this.location = location; 67 | } 68 | 69 | public String getUniversity() { 70 | return university; 71 | } 72 | 73 | public void setUniversity(String university) { 74 | this.university = university; 75 | } 76 | 77 | public String getMajor() { 78 | return major; 79 | } 80 | 81 | public void setMajor(String major) { 82 | this.major = major; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "UserProfile{" + 88 | "id=" + id + 89 | ", username='" + username + '\'' + 90 | ", email='" + email + '\'' + 91 | ", bio='" + bio + '\'' + 92 | ", location='" + location + '\'' + 93 | ", university='" + university + '\'' + 94 | ", major='" + major + '\'' + 95 | '}'; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/CaptchaController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | 4 | import com.google.code.kaptcha.Constants; 5 | import com.google.code.kaptcha.Producer; 6 | import com.kevin.mirs.dto.MIRSResult; 7 | import com.wordnik.swagger.annotations.Api; 8 | import com.wordnik.swagger.annotations.ApiOperation; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.servlet.ModelAndView; 15 | 16 | import javax.imageio.ImageIO; 17 | import javax.servlet.ServletOutputStream; 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.servlet.http.HttpServletResponse; 20 | import java.awt.image.BufferedImage; 21 | import java.io.IOException; 22 | 23 | @Controller 24 | @RequestMapping(value = "/captcha") 25 | @Api(value = "/captcha", description = "验证码相关的接口") 26 | public class CaptchaController { 27 | 28 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 29 | 30 | @Autowired 31 | private Producer captchaProducer; 32 | 33 | /** 34 | * 生成带验证码的图片 35 | * 36 | * @param request 37 | * @param response 38 | * @return 验证码 39 | * @throws IOException 40 | */ 41 | @RequestMapping(value = "", method = RequestMethod.GET) 42 | @ApiOperation(value = "", notes = "生成带验证码的图片") 43 | public ModelAndView getCaptchaImage(HttpServletRequest request, 44 | HttpServletResponse response) throws IOException { 45 | logger.info("--------------------GET:/captcha--------------------"); 46 | 47 | 48 | response.setDateHeader("Expires", 0); 49 | response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 50 | response.addHeader("Cache-Control", "post-check=0, pre-check=0"); 51 | response.setHeader("Pragma", "no-cache"); 52 | response.setContentType("image/jpeg"); 53 | String capText = captchaProducer.createText(); 54 | 55 | request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText); 56 | logger.info("======生成了一个验证码,内容为:" + capText); 57 | BufferedImage bi = captchaProducer.createImage(capText); 58 | ServletOutputStream out = response.getOutputStream(); 59 | ImageIO.write(bi, "jpg", out); 60 | try { 61 | out.flush(); 62 | } finally { 63 | out.close(); 64 | } 65 | return null; 66 | } 67 | 68 | @ResponseBody 69 | @RequestMapping(value = "", method = RequestMethod.POST) 70 | @ApiOperation(value = "", notes = "检测输入的验证码是否正确") 71 | public MIRSResult checkCaptchaImage(@RequestParam(value = "captcha") String captcha, 72 | HttpServletRequest request) { 73 | logger.info("--------------------POST:/captcha--------------------"); 74 | 75 | String original =(String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); 76 | logger.info("======用户输入的验证码:" + captcha); 77 | logger.info("======正确的验证码:" + original); 78 | 79 | if(captcha.equals(original)) { 80 | return new MIRSResult(true, true); 81 | } 82 | 83 | return new MIRSResult(false, "验证码不正确!"); 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | import com.kevin.mirs.dao.EmailVerifyDao; 4 | import com.kevin.mirs.dao.RegisterSessionDao; 5 | import com.kevin.mirs.dto.MIRSResult; 6 | import com.kevin.mirs.enums.EVChannelEnum; 7 | import com.kevin.mirs.enums.EVTypeEnum; 8 | import com.kevin.mirs.service.EmailService; 9 | import com.kevin.mirs.service.UserService; 10 | import com.kevin.mirs.utils.EncryptionUtils; 11 | import com.kevin.mirs.utils.FormatUtils; 12 | import com.kevin.mirs.utils.IPUtils; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.RequestParam; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | 21 | import javax.annotation.Resource; 22 | import javax.servlet.http.HttpServletRequest; 23 | import java.sql.Timestamp; 24 | import java.util.Date; 25 | 26 | 27 | @Controller 28 | public class HomeController { 29 | 30 | 31 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 32 | 33 | @Resource 34 | UserService userService; 35 | 36 | @Resource 37 | EmailService emailService; 38 | 39 | @Resource 40 | RegisterSessionDao RSDao; 41 | 42 | @Resource 43 | EmailVerifyDao EVDao; 44 | 45 | @ResponseBody 46 | @RequestMapping(value = "/", method = RequestMethod.GET) 47 | public String index() { 48 | return "Restful services is up!"; 49 | } 50 | // 51 | // @RequestMapping(value = "/success", method = RequestMethod.GET) 52 | // public String success() { 53 | // return "success"; 54 | // } 55 | 56 | @ResponseBody 57 | @RequestMapping(value = "/email", method = RequestMethod.POST) 58 | public MIRSResult sendEmail (@RequestParam(value = "email") String email, 59 | HttpServletRequest request) { 60 | logger.info("--------------------POST:/email--------------------"); 61 | 62 | // TODO: 2016/11/23 考虑如何保证接口安全,不被恶意利用。比如加上验证码 63 | 64 | // 验证邮箱格式 65 | if(FormatUtils.emailFormat(email) == false) { 66 | return new MIRSResult(false, "邮件格式不正确!"); 67 | } 68 | 69 | // 验证是否注册 70 | if(userService.checkEmailRegistered(email) == 1) { 71 | return new MIRSResult(false, "此邮箱已被注册!"); 72 | } 73 | 74 | // 创建注册会话 75 | Date now = new Date(); 76 | Timestamp createTime = new Timestamp(now.getTime()); 77 | Timestamp expireTime = new Timestamp(now.getTime() + UserService.EXPIRED_TIME); 78 | String ip = IPUtils.getIpAddr(request); 79 | String verification = EncryptionUtils.getVerification(); 80 | 81 | // 设置验证码SESSION 82 | request.getSession().setAttribute(UserService.VERIFICATION, verification); 83 | 84 | RSDao.add(createTime, email, ip, expireTime); 85 | EVDao.add(email, createTime, expireTime, EVChannelEnum.WEB.getChannel(),verification, EVTypeEnum.REG.getType(), ip); 86 | 87 | // 发送邮件 88 | if (!emailService.sendVerificationEmail(email, verification)) { 89 | return new MIRSResult(false, "系统内部错误!"); 90 | } 91 | return new MIRSResult(true, true); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/InspectionController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | import com.kevin.mirs.dto.MIRSResult; 4 | import com.kevin.mirs.service.UserService; 5 | import com.wordnik.swagger.annotations.ApiOperation; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | 15 | @Controller 16 | @RequestMapping("/inspection") 17 | public class InspectionController { 18 | 19 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 20 | 21 | @Resource 22 | UserService userService; 23 | 24 | @ResponseBody 25 | @RequestMapping(value = "/username", method = RequestMethod.POST) 26 | @ApiOperation(value = "/username", notes = "检查用户名是否被注册") 27 | public MIRSResult inspectUserName(@RequestParam(value = "name") String name) { 28 | logger.info("--------------------POST:/inspection/username--------------------"); 29 | 30 | int registered = userService.checkUsernameRegistered(name); 31 | if (registered == 0) { 32 | return new MIRSResult(true, true); 33 | } else { 34 | return new MIRSResult(false, "用户名已存在!"); 35 | } 36 | } 37 | 38 | @ResponseBody 39 | @RequestMapping(value = "/userEmail", method = RequestMethod.POST) 40 | @ApiOperation(value = "/userEmail", notes = "检查用户邮箱是否被注册") 41 | public MIRSResult inspectUserEmail(@RequestParam(value = "email") String email) { 42 | logger.info("--------------------POST:/inspection/userEmail--------------------"); 43 | 44 | int registered = userService.checkEmailRegistered(email); 45 | if (registered == 0) { 46 | return new MIRSResult(true, true); 47 | } else { 48 | return new MIRSResult(false, "此邮箱已被注册!"); 49 | } 50 | } 51 | 52 | @ResponseBody 53 | @RequestMapping(value = "/verification", method = RequestMethod.POST) 54 | @ApiOperation(value = "/verification", notes = "检查用户输入的邮箱的验证码是否正确") 55 | public MIRSResult inspectVerification(@RequestParam(value = "verification") String verification, 56 | HttpServletRequest request) { 57 | logger.info("--------------------POST:/inspection/verification--------------------"); 58 | 59 | String originVerification = (String) request.getSession().getAttribute(UserService.VERIFICATION); 60 | 61 | if (originVerification.equals(verification)) { 62 | return new MIRSResult(true, true); 63 | } 64 | return new MIRSResult(false, "验证码不对哦!"); 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | import com.kevin.mirs.dto.MIRSResult; 4 | import com.kevin.mirs.entity.Movie; 5 | import com.kevin.mirs.service.MovieService; 6 | import com.kevin.mirs.vo.SimpleMovie; 7 | import com.wordnik.swagger.annotations.Api; 8 | import com.wordnik.swagger.annotations.ApiOperation; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.PathVariable; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.annotation.Resource; 18 | import java.util.ArrayList; 19 | 20 | @Controller 21 | @RequestMapping(value = "/movies") 22 | @Api(value = "/movies", description = "电影相关的接口") 23 | public class MovieController { 24 | 25 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 26 | 27 | @Resource 28 | MovieService movieService; 29 | 30 | 31 | @ResponseBody 32 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 33 | @ApiOperation(value = "/{id}", notes = "通过电影的ID查询电影信息") 34 | public MIRSResult getMovieByMovieId(@PathVariable(value = "id") int id) { 35 | logger.info("--------------------GET:/movies/" + id + "--------------------"); 36 | 37 | Movie movie = movieService.getMovieByMovieId(id); 38 | 39 | if(movie != null) { 40 | return new MIRSResult(true, movie); 41 | } else { 42 | return new MIRSResult(false, "系统无此电影!"); 43 | } 44 | } 45 | 46 | 47 | @ResponseBody 48 | @RequestMapping(value = "/today", method = RequestMethod.GET) 49 | @ApiOperation(value = "/today", notes = "获得每日的首页电影推荐") 50 | public MIRSResult> getTodayMovies() { 51 | logger.info("--------------------GET:/movies/today--------------------"); 52 | 53 | ArrayList simpleMovies = movieService.getTodayMovies(); 54 | 55 | if(simpleMovies != null) { 56 | return new MIRSResult>(true, simpleMovies); 57 | } else { 58 | return new MIRSResult>(false, "获取每日电影时发生错误!"); 59 | } 60 | 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/OAuthController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | import com.kevin.mirs.vo.Url; 4 | import com.kevin.mirs.dto.MIRSResult; 5 | import com.kevin.mirs.entity.OAuthUser; 6 | import com.kevin.oauth.service.CustomOAuthService; 7 | import com.kevin.oauth.service.OAuthServices; 8 | import com.mangofactory.swagger.annotations.ApiIgnore; 9 | import com.wordnik.swagger.annotations.Api; 10 | import com.wordnik.swagger.annotations.ApiOperation; 11 | import org.scribe.model.Token; 12 | import org.scribe.model.Verifier; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import javax.annotation.Resource; 19 | 20 | @Controller 21 | @RequestMapping("/oauth") 22 | @Api(value = "/oauth", description = "第三方授权认证相关的接口") 23 | public class OAuthController { 24 | 25 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 26 | 27 | @Resource 28 | OAuthServices oAuthServices; 29 | 30 | @ResponseBody 31 | @RequestMapping(value = "/{type}", 32 | method = RequestMethod.POST) 33 | @ApiOperation(value = "{type}", notes = "用于获得第三方授权认证的URL") 34 | public MIRSResult oAuthUrl(@PathVariable(value = "type") String type) { 35 | logger.info("--------------------POST:/oauth/" + type + "--------------------"); 36 | 37 | CustomOAuthService oAuthService = oAuthServices.getoAuthServiceByType(type); 38 | 39 | if (oAuthService != null) { 40 | return new MIRSResult(true, new Url(oAuthService.getAuthorizationUrl())); 41 | } else { 42 | return new MIRSResult(false, "没有此认证方式!"); 43 | } 44 | 45 | } 46 | 47 | 48 | @RequestMapping(value = "/{type}/callback", method = RequestMethod.GET) 49 | @ApiIgnore 50 | public String oAuthCallback(@RequestParam(value = "code", required = true) String code, 51 | @PathVariable(value = "type") String type) { 52 | 53 | logger.info("--------------------GET:/oauth/" + type + "/callback--------------------"); 54 | 55 | CustomOAuthService oAuthService = oAuthServices.getoAuthServiceByType(type); 56 | Token accessToken = oAuthService.getAccessToken(null, new Verifier(code)); 57 | OAuthUser oAuthInfo = oAuthService.getOAuthUser(accessToken); 58 | //判断用户是否已经注册,如果没有,则重定向到注册界面,否则,返回登录成功的界面 59 | // OAuthUser oAuthUser = oauthUserRepository.findByOAuthTypeAndOAuthId(oAuthInfo.getoAuthType(), oAuthInfo.getoAuthId()); 60 | // if(oAuthUser == null){ 61 | // model.addAttribute("oAuthInfo", oAuthInfo); 62 | // return "register"; 63 | // } 64 | // request.getSession().setAttribute("oauthUser", oAuthUser); 65 | // return "redirect:/success"; 66 | // return new MIRSResult(true, oAuthInfo); 67 | return "success"; 68 | } 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/SearchController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | import com.kevin.mirs.dto.MIRSResult; 4 | import com.kevin.mirs.service.SearchService; 5 | import com.kevin.mirs.vo.SimpleMovie; 6 | import com.kevin.mirs.vo.SuggestionMovie; 7 | import com.wordnik.swagger.annotations.Api; 8 | import com.wordnik.swagger.annotations.ApiOperation; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import javax.annotation.Resource; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | @Controller 19 | @RequestMapping("/searches") 20 | @Api(value = "/searches", description = "搜索相关的接口") 21 | public class SearchController { 22 | 23 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 24 | 25 | @Resource 26 | SearchService searchService; 27 | 28 | @ResponseBody 29 | @RequestMapping(value = "/suggestions", method = RequestMethod.GET) 30 | @ApiOperation(value = "/suggestions", notes = "搜索电影时的提示信息") 31 | public List getSuggestions(@RequestParam(value = "keyword") String keyword, 32 | @RequestParam(value = "limit", required = false, defaultValue = "6") int limit) { 33 | logger.info("--------------------GET:/searches/suggestions--------------------"); 34 | logger.info("--------------------keyword:" + keyword + ";limit:" + limit + "--------------------"); 35 | 36 | return searchService.getSuggestionMovies(keyword, limit); 37 | } 38 | 39 | @ResponseBody 40 | @RequestMapping(value = "/movies", method = RequestMethod.GET) 41 | @ApiOperation(value = "/movies", notes = "搜索电影") 42 | public MIRSResult> searchMoives(@RequestParam(value = "keywords") String keywords, 43 | @RequestParam(value = "type") int type, 44 | @RequestParam(value = "sort", required = false, defaultValue = "1") int sort, 45 | @RequestParam(value = "limit", required = false, defaultValue = "10") int limit, 46 | @RequestParam(value = "offset", required = false, defaultValue = "0") int offset) { 47 | logger.info("--------------------GET:/searches/movies--------------------"); 48 | 49 | ArrayList results = searchService.searchMoives(keywords, type, sort, limit, offset); 50 | 51 | if (results != null) { 52 | return new MIRSResult<>(true, results); 53 | } 54 | 55 | return new MIRSResult<>(false, "出问题了哦~"); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/mirs/web/WebSocketController.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.web; 2 | 3 | 4 | import com.kevin.mirs.dto.MIRSResult; 5 | import com.kevin.mirs.service.SockJSHandler; 6 | import com.kevin.mirs.vo.SimpleUserMessage; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.messaging.handler.annotation.MessageMapping; 11 | import org.springframework.messaging.handler.annotation.SendTo; 12 | import org.springframework.messaging.simp.SimpMessagingTemplate; 13 | import org.springframework.messaging.simp.annotation.SendToUser; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.ResponseBody; 19 | 20 | import javax.annotation.Resource; 21 | 22 | @Controller 23 | public class WebSocketController { 24 | 25 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 26 | 27 | @Resource 28 | SockJSHandler sockJSHandler; 29 | 30 | private SimpMessagingTemplate template; 31 | 32 | @Autowired 33 | public WebSocketController(SimpMessagingTemplate template) { 34 | this.template = template; 35 | } 36 | 37 | @MessageMapping("/hello") 38 | @SendTo("/topic/system-messages") 39 | public SimpleUserMessage broadcast(SimpleUserMessage message) throws Exception { 40 | return message; 41 | } 42 | 43 | /** 44 | * 这里用的是@SendToUser,这就是发送给单一客户端的标志。本例中, 45 | * 客户端接收一对一消息的主题应该是“/user/” + 用户Id + “/message” ,这里的用户id可以是一个普通的字符串,只要每个用户端都使用自己的id并且服务端知道每个用户的id就行。 46 | * 47 | * @return 48 | */ 49 | @MessageMapping("/message") 50 | @SendToUser("/message") 51 | public SimpleUserMessage endToEndMessage(SimpleUserMessage message) throws Exception { 52 | return message; 53 | } 54 | 55 | @ResponseBody 56 | @RequestMapping(value = "/send", method = RequestMethod.POST) 57 | public MIRSResult send(@RequestBody SimpleUserMessage message) { 58 | 59 | // TODO 验证相关信息 60 | if(message.getType() == 0) { 61 | template.convertAndSend("/topic/system-messages", message); 62 | } else { 63 | template.convertAndSendToUser(message.getTo(), "/message", message); 64 | } 65 | return new MIRSResult(true, true); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/api/GitHubApi.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.api; 2 | 3 | 4 | import org.scribe.builder.api.DefaultApi20; 5 | import org.scribe.model.OAuthConfig; 6 | import org.scribe.utils.OAuthEncoder; 7 | 8 | public class GitHubApi extends DefaultApi20 { 9 | 10 | private static final String AUTHORIZE_URL = "https://github.com/login/oauth/authorize?client_id=%s&redirect_uri=%s&state=%s"; 11 | private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=%s"; 12 | private static final String ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token?state=%s"; 13 | 14 | private final String githubState; 15 | 16 | public GitHubApi(String state){ 17 | this.githubState = state; 18 | } 19 | 20 | @Override 21 | public String getAuthorizationUrl(OAuthConfig config) { 22 | if (config.hasScope()){ 23 | return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), 24 | githubState, OAuthEncoder.encode(config.getScope())); 25 | } 26 | else{ 27 | return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), githubState); 28 | } 29 | } 30 | 31 | @Override 32 | public String getAccessTokenEndpoint() { 33 | return String.format(ACCESS_TOKEN_URL, githubState); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/api/QQApi.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.api; 2 | 3 | 4 | import org.scribe.builder.api.DefaultApi20; 5 | import org.scribe.model.OAuthConfig; 6 | import org.scribe.utils.OAuthEncoder; 7 | 8 | public class QQApi extends DefaultApi20 { 9 | 10 | private static final String AUTHORIZE_URL = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%s&redirect_uri=%s&state=%s"; 11 | private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=%s"; 12 | private static final String ACCESS_TOKEN_URL = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&state=%s"; 13 | 14 | private final String qqState; 15 | 16 | public QQApi(String state){ 17 | this.qqState = state; 18 | } 19 | 20 | @Override 21 | public String getAuthorizationUrl(OAuthConfig config) { 22 | if (config.hasScope()){ 23 | return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), 24 | qqState, OAuthEncoder.encode(config.getScope())); 25 | } 26 | else{ 27 | return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()), qqState); 28 | } 29 | } 30 | 31 | @Override 32 | public String getAccessTokenEndpoint() { 33 | return String.format(ACCESS_TOKEN_URL, qqState); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/api/WeiXinApi.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.api; 2 | 3 | 4 | import com.kevin.oauth.service.WeixinOAuthService; 5 | import org.scribe.builder.api.DefaultApi20; 6 | import org.scribe.model.OAuthConfig; 7 | import org.scribe.oauth.OAuthService; 8 | import org.scribe.utils.OAuthEncoder; 9 | 10 | public class WeiXinApi extends DefaultApi20 { 11 | 12 | private static final String AUTHORIZE_URL = "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&state=esfadsgsad34fwdef&scope=snsapi_login#wechat_redirect"; 13 | private static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?grant_type=authorization_code"; 14 | 15 | @Override 16 | public String getAuthorizationUrl(OAuthConfig config) { 17 | return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback())); 18 | } 19 | 20 | @Override 21 | public String getAccessTokenEndpoint() { 22 | return ACCESS_TOKEN_URL; 23 | } 24 | 25 | @Override 26 | public OAuthService createService(OAuthConfig config){ 27 | return new WeixinOAuthService(this, config); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/config/GitHubConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.config; 2 | 3 | 4 | import com.kevin.oauth.api.GitHubApi; 5 | import com.kevin.oauth.service.GithubOAuthService; 6 | import com.kevin.oauth.service.OAuthServiceDecorator; 7 | import org.scribe.builder.ServiceBuilder; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class GitHubConfig { 14 | 15 | @Value("${oAuth.callbackUrl}") String CALLBACK_URL; 16 | @Value("${oAuth.host}") String host; 17 | 18 | @Value("${oAuth.github.status}") String status; 19 | @Value("${oAuth.github.clientId}") String clientId; 20 | @Value("${oAuth.github.clientSecret}") String clientSecret; 21 | 22 | 23 | 24 | @Bean 25 | public GitHubApi githubApi(){ 26 | return new GitHubApi(status); 27 | } 28 | 29 | @Bean 30 | public OAuthServiceDecorator getGithubOAuthService(){ 31 | return new GithubOAuthService(new ServiceBuilder() 32 | .provider(githubApi()) 33 | .apiKey(clientId) 34 | .apiSecret(clientSecret) 35 | .callback(String.format(CALLBACK_URL, host, OAuthTypes.GITHUB)) 36 | .build()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/config/OAuthTypes.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.config; 2 | 3 | 4 | public class OAuthTypes { 5 | 6 | public static final String GITHUB = "github"; 7 | public static final String SINA_WEIBO = "weibo"; 8 | public static final String WEIXIN = "weixin"; 9 | public static final String QQ = "qq"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/config/QQConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.config; 2 | 3 | 4 | import com.kevin.oauth.api.QQApi; 5 | import com.kevin.oauth.service.OAuthServiceDecorator; 6 | import com.kevin.oauth.service.QQOAuthService; 7 | import org.scribe.builder.ServiceBuilder; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class QQConfig { 14 | 15 | @Value("${oAuth.callbackUrl}") String CALLBACK_URL; 16 | @Value("${oAuth.host}") String host; 17 | @Value("${oAuth.qq.status}") String status; 18 | @Value("${oAuth.qq.appId}") String qqAppId; 19 | @Value("${oAuth.qq.appKey}") String qqAppKey; 20 | 21 | 22 | 23 | @Bean 24 | public QQApi qqApi(){ 25 | return new QQApi(status); 26 | } 27 | 28 | 29 | @Bean 30 | public OAuthServiceDecorator getQQOAuthService(){ 31 | return new QQOAuthService(new ServiceBuilder() 32 | .provider(qqApi()) 33 | .apiKey(qqAppId) 34 | .apiSecret(qqAppKey) 35 | .callback(String.format(CALLBACK_URL, host,OAuthTypes.QQ)) 36 | .build()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/config/WeiBoConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.config; 2 | 3 | 4 | import com.kevin.oauth.service.OAuthServiceDecorator; 5 | import com.kevin.oauth.service.SinaWeiboOAuthService; 6 | import org.scribe.builder.ServiceBuilder; 7 | import org.scribe.builder.api.SinaWeiboApi20; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class WeiBoConfig { 14 | 15 | @Value("${oAuth.callbackUrl}") String CALLBACK_URL; 16 | @Value("${oAuth.host}") String host; 17 | 18 | @Value("${oAuth.weibo.appkey}") String sinaAppKey; 19 | @Value("${oAuth.weibo.appSecret}") String sinaAppSecret; 20 | 21 | 22 | @Bean 23 | public OAuthServiceDecorator getSinaOAuthService(){ 24 | return new SinaWeiboOAuthService(new ServiceBuilder() 25 | .provider(SinaWeiboApi20.class) 26 | .apiKey(sinaAppKey) 27 | .apiSecret(sinaAppSecret) 28 | .callback(String.format(CALLBACK_URL, host, OAuthTypes.SINA_WEIBO)) 29 | .build()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/config/WeiXinConfig.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.config; 2 | 3 | 4 | import com.kevin.oauth.api.WeiXinApi; 5 | import com.kevin.oauth.service.CustomOAuthService; 6 | import org.scribe.builder.ServiceBuilder; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class WeiXinConfig { 13 | 14 | @Value("${oAuth.callbackUrl}") String CALLBACK_URL; 15 | @Value("${oAuth.host}") String host; 16 | 17 | @Value("${oAuth.weixin.appId}") String weixinAppId; 18 | @Value("${oAuth.weixin.appSecret}") String weixinAppSecret; 19 | 20 | 21 | @Bean 22 | public CustomOAuthService getWeixinOAuthService(){ 23 | return (CustomOAuthService) new ServiceBuilder() 24 | .provider(WeiXinApi.class) 25 | .apiKey(weixinAppId) 26 | .apiSecret(weixinAppSecret) 27 | .scope("snsapi_login") 28 | .callback(String.format(CALLBACK_URL, host, OAuthTypes.WEIXIN)) 29 | .build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/CustomOAuthService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.kevin.mirs.entity.OAuthUser; 5 | import org.scribe.model.Token; 6 | import org.scribe.oauth.OAuthService; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public interface CustomOAuthService extends OAuthService{ 11 | 12 | String getoAuthType(); 13 | String getAuthorizationUrl(); 14 | OAuthUser getOAuthUser(Token accessToken); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/GithubOAuthService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | import com.alibaba.fastjson.JSONPath; 6 | import com.kevin.mirs.entity.OAuthUser; 7 | import com.kevin.mirs.entity.User; 8 | import com.kevin.oauth.config.OAuthTypes; 9 | import org.scribe.model.OAuthRequest; 10 | import org.scribe.model.Response; 11 | import org.scribe.model.Token; 12 | import org.scribe.model.Verb; 13 | import org.scribe.oauth.OAuthService; 14 | 15 | public class GithubOAuthService extends OAuthServiceDecorator{ 16 | 17 | private static final String PROTECTED_RESOURCE_URL = "https://api.github.com/user"; 18 | 19 | public GithubOAuthService(OAuthService oAuthService) { 20 | super(oAuthService, OAuthTypes.GITHUB); 21 | } 22 | 23 | 24 | public OAuthUser getOAuthUser(Token accessToken) { 25 | OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); 26 | this.signRequest(accessToken, request); 27 | Response response = request.send(); 28 | OAuthUser oAuthUser = new OAuthUser(); 29 | oAuthUser.setoAuthType(getoAuthType()); 30 | Object result = JSON.parse(response.getBody()); 31 | //TODO 32 | oAuthUser.setoAuthId(JSONPath.eval(result, "$.id").toString()); 33 | oAuthUser.setUser(new User()); 34 | oAuthUser.getUser().setUsername(JSONPath.eval(result, "$.login").toString()); 35 | return oAuthUser; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/OAuthServiceDecorator.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import org.scribe.model.OAuthRequest; 5 | import org.scribe.model.Token; 6 | import org.scribe.model.Verifier; 7 | import org.scribe.oauth.OAuthService; 8 | 9 | public abstract class OAuthServiceDecorator implements CustomOAuthService { 10 | 11 | private final OAuthService oAuthService; 12 | private final String oAuthType; 13 | private final String authorizationUrl; 14 | 15 | public OAuthServiceDecorator(OAuthService oAuthService, String type) { 16 | super(); 17 | this.oAuthService = oAuthService; 18 | this.oAuthType = type; 19 | this.authorizationUrl = oAuthService.getAuthorizationUrl(null); 20 | } 21 | 22 | public Token getRequestToken() { 23 | return oAuthService.getRequestToken(); 24 | } 25 | 26 | public Token getAccessToken(Token requestToken, Verifier verifier) { 27 | return oAuthService.getAccessToken(requestToken, verifier); 28 | } 29 | 30 | public void signRequest(Token accessToken, OAuthRequest request) { 31 | oAuthService.signRequest(accessToken, request); 32 | } 33 | 34 | public String getVersion() { 35 | return oAuthService.getVersion(); 36 | } 37 | 38 | public String getAuthorizationUrl(Token requestToken) { 39 | return oAuthService.getAuthorizationUrl(requestToken); 40 | } 41 | 42 | public String getoAuthType() { 43 | return oAuthType; 44 | } 45 | 46 | public String getAuthorizationUrl(){ 47 | return authorizationUrl; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/OAuthServices.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.kevin.oauth.config.*; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | 9 | 10 | @Service 11 | public class OAuthServices { 12 | 13 | @Resource 14 | GitHubConfig gitHubConfig; 15 | 16 | @Resource 17 | QQConfig qqConfig; 18 | 19 | @Resource 20 | WeiXinConfig weiXinConfig; 21 | 22 | @Resource 23 | WeiBoConfig weiBoConfig; 24 | 25 | 26 | public CustomOAuthService getoAuthServiceByType(String type) { 27 | if(OAuthTypes.GITHUB.equals(type)){ 28 | return gitHubConfig.getGithubOAuthService(); 29 | }else if(OAuthTypes.QQ.equals(type)) { 30 | return qqConfig.getQQOAuthService(); 31 | }else if (OAuthTypes.WEIXIN.equals(type)) { 32 | return weiXinConfig.getWeixinOAuthService(); 33 | }else if (OAuthTypes.SINA_WEIBO.equals(type)) { 34 | return weiBoConfig.getSinaOAuthService(); 35 | }else { 36 | return null; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/QQOAuthService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.kevin.mirs.entity.OAuthUser; 5 | import com.kevin.mirs.entity.User; 6 | import com.kevin.oauth.config.OAuthTypes; 7 | import org.scribe.model.OAuthRequest; 8 | import org.scribe.model.Response; 9 | import org.scribe.model.Token; 10 | import org.scribe.model.Verb; 11 | import org.scribe.oauth.OAuthService; 12 | 13 | public class QQOAuthService extends OAuthServiceDecorator { 14 | 15 | private static final String PROTECTED_RESOURCE_URL = "https://graph.qq.com/oauth2.0/me"; 16 | 17 | public QQOAuthService(OAuthService oAuthService) { 18 | super(oAuthService, OAuthTypes.QQ); 19 | } 20 | 21 | public OAuthUser getOAuthUser(Token accessToken) { 22 | OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); 23 | this.signRequest(accessToken, request); 24 | Response response = request.send(); 25 | OAuthUser oAuthUser = new OAuthUser(); 26 | oAuthUser.setoAuthType(getoAuthType()); 27 | //TODO 28 | oAuthUser.setoAuthId(response.getBody()); 29 | oAuthUser.setUser(new User()); 30 | return oAuthUser; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/SinaWeiboOAuthService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | import com.alibaba.fastjson.JSONPath; 6 | import com.kevin.mirs.entity.OAuthUser; 7 | import com.kevin.mirs.entity.User; 8 | import com.kevin.oauth.config.OAuthTypes; 9 | import org.scribe.model.OAuthRequest; 10 | import org.scribe.model.Response; 11 | import org.scribe.model.Token; 12 | import org.scribe.model.Verb; 13 | import org.scribe.oauth.OAuthService; 14 | 15 | public class SinaWeiboOAuthService extends OAuthServiceDecorator { 16 | 17 | private static final String PROTECTED_RESOURCE_URL = "https://api.weibo.com/oauth2/get_token_info"; 18 | 19 | public SinaWeiboOAuthService(OAuthService oAuthService) { 20 | super(oAuthService, OAuthTypes.SINA_WEIBO); 21 | } 22 | 23 | public OAuthUser getOAuthUser(Token accessToken) { 24 | OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL); 25 | this.signRequest(accessToken, request); 26 | Response response = request.send(); 27 | OAuthUser oAuthUser = new OAuthUser(); 28 | oAuthUser.setoAuthType(getoAuthType()); 29 | //TODO 30 | oAuthUser.setoAuthId(JSONPath.eval(JSON.parse(response.getBody()), "$.uid").toString()); 31 | oAuthUser.setUser(new User()); 32 | return oAuthUser; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/com/kevin/oauth/service/WeixinOAuthService.java: -------------------------------------------------------------------------------- 1 | package com.kevin.oauth.service; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | import com.alibaba.fastjson.JSONPath; 6 | import com.kevin.mirs.entity.OAuthUser; 7 | import com.kevin.mirs.entity.User; 8 | import com.kevin.oauth.config.OAuthTypes; 9 | import org.scribe.builder.api.DefaultApi20; 10 | import org.scribe.model.*; 11 | import org.scribe.oauth.OAuth20ServiceImpl; 12 | 13 | public class WeixinOAuthService extends OAuth20ServiceImpl implements CustomOAuthService { 14 | 15 | private final DefaultApi20 api; 16 | private final OAuthConfig config; 17 | private final String authorizationUrl; 18 | 19 | public WeixinOAuthService(DefaultApi20 api, OAuthConfig config) { 20 | super(api, config); 21 | this.api = api; 22 | this.config = config; 23 | this.authorizationUrl = getAuthorizationUrl(null); 24 | } 25 | 26 | public Token getAccessToken(Token requestToken, Verifier verifier){ 27 | OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint()); 28 | request.addQuerystringParameter("appid", config.getApiKey()); 29 | request.addQuerystringParameter("secret", config.getApiSecret()); 30 | request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue()); 31 | if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope()); 32 | Response response = request.send(); 33 | String responceBody = response.getBody(); 34 | Object result = JSON.parse(responceBody); 35 | return new Token(JSONPath.eval(result, "$.access_token").toString(), "", responceBody); 36 | } 37 | 38 | public OAuthUser getOAuthUser(Token accessToken) { 39 | OAuthUser oAuthUser = new OAuthUser(); 40 | oAuthUser.setoAuthType(getoAuthType()); 41 | Object result = JSON.parse(accessToken.getRawResponse()); 42 | //TODO 43 | oAuthUser.setoAuthId(JSONPath.eval(result, "$.openid").toString()); 44 | oAuthUser.setUser(new User()); 45 | return oAuthUser; 46 | } 47 | 48 | 49 | public String getoAuthType() { 50 | return OAuthTypes.WEIXIN; 51 | } 52 | 53 | 54 | public String getAuthorizationUrl() { 55 | return authorizationUrl; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/com/kevin/shiro/realm/LoginRealm.java: -------------------------------------------------------------------------------- 1 | package com.kevin.shiro.realm; 2 | 3 | 4 | import org.apache.shiro.authc.*; 5 | import org.apache.shiro.authz.AuthorizationInfo; 6 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 7 | import org.apache.shiro.realm.AuthorizingRealm; 8 | import org.apache.shiro.subject.PrincipalCollection; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import java.util.Arrays; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class LoginRealm extends AuthorizingRealm { 18 | 19 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 20 | 21 | private Map usernamePasswords; 22 | private Map> usernameRoles; 23 | 24 | public LoginRealm() { 25 | usernamePasswords = new HashMap(); 26 | usernameRoles = new HashMap>(); 27 | 28 | usernamePasswords.put("admin", "password"); 29 | usernamePasswords.put("register", "password"); 30 | 31 | usernameRoles.put("admin", Arrays.asList("Register", "Admin")); 32 | usernameRoles.put("register", Arrays.asList("Register")); 33 | } 34 | 35 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 36 | 37 | // 用户需要提供 principals (身份)和 credentials(证明)给 shiro,从而应用能验证用户身份 38 | // 最常见的 principals 和 credentials 组合就是用户名/密码了 39 | // String username = (String) principals.fromRealm(getName()).iterator().next(); 40 | String username = (String) principals.getPrimaryPrincipal(); 41 | 42 | // Authentication 成功后查询用户授权信息. 43 | List roles = queryRoles(username); 44 | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); 45 | 46 | logger.debug("Username: {}, Roles: {}", username, roles); 47 | 48 | if (roles != null && !roles.isEmpty()) { 49 | // info.addStringPermissions(permissions); 50 | info.addRoles(roles); 51 | } 52 | 53 | return info; 54 | 55 | } 56 | 57 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { 58 | UsernamePasswordToken upToken = (UsernamePasswordToken) token; 59 | String username = upToken.getUsername(); // 通过表单接收的用户名 60 | 61 | logger.info("--------------username: " + username); 62 | logger.info("--------------token: " + token); 63 | 64 | 65 | // User user = userMapper.findUserById(1); 66 | // System.out.println(user); 67 | 68 | // 取得预先定义的用户名密码对 69 | return new SimpleAuthenticationInfo(username, queryPassword(username), getName()); 70 | } 71 | 72 | private String queryPassword(String username) { 73 | return usernamePasswords.get(username); 74 | } 75 | 76 | private List queryRoles(String username) { 77 | return usernameRoles.get(username); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/mapper/EmailVerifyDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | INSERT INTO mirs_email_verify(email, create_time, expire_time, channel, verify_code, verify_type, request_ip) 7 | VALUES (#{email}, #{createTime}, #{expireTime}, #{channel}, #{verifyCode}, #{verifyType}, #{requestIp}) 8 | 9 | 10 | 11 | UPDATE mirs_email_verify 12 | SET status = #{status} 13 | WHERE email = #{email} 14 | ORDER BY expire_time DESC 15 | LIMIT 1 16 | 17 | 18 | 19 | UPDATE mirs_email_verify 20 | SET status = #{status} 21 | WHERE expire_time = #{expireTime} 22 | 23 | 24 | 31 | 32 | 40 | -------------------------------------------------------------------------------- /src/main/resources/mapper/FriendDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | INSERT IGNORE INTO mirs_friend(uid, ufid) VALUES (#{uid}, #{ufid}) 9 | 10 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/mapper/RegisterSessionDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | INSERT INTO mirs_register_session(create_time, email, client_ip, expire_time) 7 | VALUES (#{createTime}, #{email}, #{clientIp}, #{expireTime}) 8 | 9 | 10 | 11 | UPDATE mirs_register_session 12 | SET status = #{status} 13 | WHERE email = #{email} 14 | ORDER BY expire_time DESC 15 | LIMIT 1 16 | 17 | 18 | 19 | UPDATE mirs_register_session 20 | SET status = #{status} 21 | WHERE expire_time = #{expireTime} 22 | 23 | 24 | 31 | 32 | 40 | -------------------------------------------------------------------------------- /src/main/resources/mapper/TestDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT ignore INTO mirs_user(username, password, salt, email, register_time, register_ip) 10 | VALUES (#{username}, #{password}, #{salt}, #{email}, #{registerTime}, #{registerIp}) 11 | 12 | 13 | 14 | UPDATE 15 | mirs_user 16 | SET 17 | username = #{username} 18 | WHERE 19 | id = #{id} 20 | AND status = 1 21 | 22 | 23 | 24 | UPDATE 25 | mirs_user 26 | SET 27 | password = #{password} 28 | WHERE 29 | id = #{id} 30 | AND status = 1 31 | 32 | 33 | UPDATE 34 | mirs_user 35 | SET 36 | salt = #{salt} 37 | WHERE 38 | id = #{id} 39 | AND status = 1 40 | 41 | 42 | UPDATE 43 | mirs_user 44 | SET 45 | avatar= #{avatar} 46 | WHERE 47 | id = #{id} 48 | AND status = 1 49 | 50 | 51 | UPDATE 52 | mirs_user 53 | SET 54 | email = #{email} 55 | WHERE 56 | id = #{id} 57 | AND status = 1 58 | 59 | 60 | UPDATE 61 | mirs_user 62 | SET 63 | bio = #{bio} 64 | WHERE 65 | id = #{id} 66 | AND status = 1 67 | 68 | 69 | UPDATE 70 | mirs_user 71 | SET 72 | location = #{location} 73 | WHERE 74 | id = #{id} 75 | AND status = 1 76 | 77 | 78 | UPDATE 79 | mirs_user 80 | SET 81 | university = #{university} 82 | WHERE 83 | id = #{id} 84 | AND status = 1 85 | 86 | 87 | UPDATE 88 | mirs_user 89 | SET 90 | major = #{major} 91 | WHERE 92 | id = #{id} 93 | AND status = 1 94 | 95 | 96 | UPDATE 97 | mirs_user 98 | SET 99 | last_login_time = #{time}, 100 | last_login_ip = #{ip} 101 | WHERE 102 | id = #{id} 103 | AND status = 1 104 | 105 | 106 | UPDATE 107 | mirs_user 108 | SET 109 | username = #{username}, 110 | email = #{email}, 111 | bio = #{bio}, 112 | location = #{location}, 113 | university = #{university}, 114 | major = #{major} 115 | WHERE 116 | id = #{id} 117 | AND status = 1 118 | 119 | 122 | 125 | 128 | 131 | 134 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserRecommendedFriendsDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | INSERT ignore INTO mirs_user_recommended_friends(uid, rfid) 9 | VALUES 10 | 11 | (#{uid}, #{rfid}) 12 | 13 | 14 | 15 | 16 | DELETE FROM mirs_user_recommended_friends 17 | WHERE uid = #{uid} 18 | 19 | 20 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserRecommendedMoviesDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | INSERT ignore INTO mirs_user_recommended_movies(uid, rmid, rmv) 9 | VALUES 10 | 11 | (#{uid}, #{rm.itemID}, #{rm.value}) 12 | 13 | 14 | 15 | 16 | DELETE FROM mirs_user_recommended_movies 17 | WHERE uid = #{uid} 18 | 19 | 20 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/properties/jdbc-example.properties: -------------------------------------------------------------------------------- 1 | # JDBC驱动,默认即可 2 | driver = com.mysql.cj.jdbc.Driver 3 | 4 | # 连接地址 5 | # characterEncoding=utf8 可以被自动识别为utf8mb4 connector版本大于5.1.13的不能加characterEncoding=utf8 6 | # refer: http://info.michael-simons.eu/2013/01/21/java-mysql-and-multi-byte-utf-8-support/ 7 | # For example, to use 4-byte UTF-8 character sets with Connector/J, configure the MySQL server with 8 | # character_set_server=utf8mb4, and leave characterEncoding out of the Connector/J connection string. 9 | # Connector/J will then autodetect the UTF-8 setting. 10 | # autoReconnect 解决因为缓存不能读取到DB最新配置的问题 11 | # rewriteBatchedStatements 批量操作 12 | url = jdbc:mysql://localhost:3306/mirs?useUnicode=true&autoReconnect=true&rewriteBatchedStatements=TRUE&serverTimezone=PRC 13 | 14 | # 数据库用户名 15 | user = 16 | 17 | # 数据库密码 18 | password = 19 | 20 | 21 | # 推荐系统部分 22 | preferenceTable = mirs_user_movie 23 | userIDColumn = uid 24 | itemIDColumn = mid 25 | preferenceColumn = score 26 | -------------------------------------------------------------------------------- /src/main/resources/properties/mail-example.properties: -------------------------------------------------------------------------------- 1 | # 主机 2 | mailHost = smtp.yeah.net 3 | 4 | # 发送用户名 5 | maillUsername = mirs_service@yeah.net 6 | 7 | # 口令 8 | mailPassword = D7Ke6do084d6mFe4 9 | 10 | # 发送账号 11 | mailFrom = mirs_service@yeah.net 12 | -------------------------------------------------------------------------------- /src/main/resources/properties/oauth-prod.properties: -------------------------------------------------------------------------------- 1 | #============================# 2 | #==== OAuth Settings ====# 3 | #============================# 4 | 5 | # 部署请自行修改下列配置 6 | 7 | # 通用设置 8 | oAuth.host = http://localhost:8080 9 | oAuth.callbackUrl = %s/oauth/%s/callback 10 | 11 | # GitHub 认证设置 12 | oAuth.github.status = 1h8k68be2449023j0df0la923jd6fa 13 | oAuth.github.clientId = 200f689343da855727ed 14 | oAuth.github.clientSecret = be5275d9b9764cd4d9e1889ad4cf3830281b42d2 15 | 16 | # QQ 认证设置 17 | oAuth.qq.status = state3245fg34fdge 18 | oAuth.qq.appId = 1105694353 19 | oAuth.qq.appKey = XYwzErJ8SCfWx2Tz 20 | 21 | # Weibo 认证设置 22 | oAuth.weibo.appkey = 234234235467 23 | oAuth.weibo.appSecret = fasfooefjdslfo 24 | 25 | # Weixin 认证设置 26 | oAuth.weixin.appId = 45045832 27 | oAuth.weixin.appSecret = aidsfjo90840dfhtry 28 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-dao.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-service.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | true 41 | ${mailFrom} 42 | true 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-shiro.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 47 | 48 | / = anon 49 | /accounts/unauthorized = anon 50 | /accounts/login = anon 51 | /accounts/logout = logout 52 | /accounts/register = anon 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ 2 | html, 3 | body, 4 | div, 5 | span, 6 | applet, 7 | object, 8 | iframe, 9 | h1, 10 | h2, 11 | h3, 12 | h4, 13 | h5, 14 | h6, 15 | p, 16 | blockquote, 17 | pre, 18 | a, 19 | abbr, 20 | acronym, 21 | address, 22 | big, 23 | cite, 24 | code, 25 | del, 26 | dfn, 27 | em, 28 | img, 29 | ins, 30 | kbd, 31 | q, 32 | s, 33 | samp, 34 | small, 35 | strike, 36 | strong, 37 | sub, 38 | sup, 39 | tt, 40 | var, 41 | b, 42 | u, 43 | i, 44 | center, 45 | dl, 46 | dt, 47 | dd, 48 | ol, 49 | ul, 50 | li, 51 | fieldset, 52 | form, 53 | label, 54 | legend, 55 | table, 56 | caption, 57 | tbody, 58 | tfoot, 59 | thead, 60 | tr, 61 | th, 62 | td, 63 | article, 64 | aside, 65 | canvas, 66 | details, 67 | embed, 68 | figure, 69 | figcaption, 70 | footer, 71 | header, 72 | hgroup, 73 | menu, 74 | nav, 75 | output, 76 | ruby, 77 | section, 78 | summary, 79 | time, 80 | mark, 81 | audio, 82 | video { 83 | margin: 0; 84 | padding: 0; 85 | border: 0; 86 | font-size: 100%; 87 | font: inherit; 88 | vertical-align: baseline; 89 | } 90 | /* HTML5 display-role reset for older browsers */ 91 | article, 92 | aside, 93 | details, 94 | figcaption, 95 | figure, 96 | footer, 97 | header, 98 | hgroup, 99 | menu, 100 | nav, 101 | section { 102 | display: block; 103 | } 104 | body { 105 | line-height: 1; 106 | } 107 | ol, 108 | ul { 109 | list-style: none; 110 | } 111 | blockquote, 112 | q { 113 | quotes: none; 114 | } 115 | blockquote:before, 116 | blockquote:after, 117 | q:before, 118 | q:after { 119 | content: ''; 120 | content: none; 121 | } 122 | table { 123 | border-collapse: collapse; 124 | border-spacing: 0; 125 | } 126 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/css/typography.css: -------------------------------------------------------------------------------- 1 | /* Google Font's Droid Sans */ 2 | @font-face { 3 | font-family: 'Droid Sans'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf'), format('truetype'); 7 | } 8 | /* Google Font's Droid Sans Bold */ 9 | @font-face { 10 | font-family: 'Droid Sans'; 11 | font-style: normal; 12 | font-weight: 700; 13 | src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf'), format('truetype'); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/fonts/DroidSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/fonts/DroidSans-Bold.ttf -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/collapse.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/collapse.gif -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/expand.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/expand.gif -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/explorer_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/explorer_icons.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/favicon-16x16.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/favicon-32x32.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/favicon.ico -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/logo_small.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/pet_store_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/pet_store_api.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/throbber.gif -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/images/wordnik_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QilinGu/mirs/4e57a15fdf5178877203b886582e754773089ee7/src/main/webapp/WEB-INF/html/swagger/images/wordnik_api.png -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Swagger UI 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 89 | 90 | 91 | 92 | 102 | 103 |
 
104 |
105 | 106 | 107 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/ca.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Advertència: Obsolet", 6 | "Implementation Notes":"Notes d'implementació", 7 | "Response Class":"Classe de la Resposta", 8 | "Status":"Estatus", 9 | "Parameters":"Paràmetres", 10 | "Parameter":"Paràmetre", 11 | "Value":"Valor", 12 | "Description":"Descripció", 13 | "Parameter Type":"Tipus del Paràmetre", 14 | "Data Type":"Tipus de la Dada", 15 | "Response Messages":"Missatges de la Resposta", 16 | "HTTP Status Code":"Codi d'Estatus HTTP", 17 | "Reason":"Raó", 18 | "Response Model":"Model de la Resposta", 19 | "Request URL":"URL de la Sol·licitud", 20 | "Response Body":"Cos de la Resposta", 21 | "Response Code":"Codi de la Resposta", 22 | "Response Headers":"Capçaleres de la Resposta", 23 | "Hide Response":"Amagar Resposta", 24 | "Try it out!":"Prova-ho!", 25 | "Show/Hide":"Mostrar/Amagar", 26 | "List Operations":"Llista Operacions", 27 | "Expand Operations":"Expandir Operacions", 28 | "Raw":"Cru", 29 | "can't parse JSON. Raw result":"no puc analitzar el JSON. Resultat cru", 30 | "Example Value":"Valor d'Exemple", 31 | "Model Schema":"Esquema del Model", 32 | "Model":"Model", 33 | "apply":"aplicar", 34 | "Username":"Nom d'usuari", 35 | "Password":"Contrasenya", 36 | "Terms of service":"Termes del servei", 37 | "Created by":"Creat per", 38 | "See more at":"Veure més en", 39 | "Contact the developer":"Contactar amb el desenvolupador", 40 | "api version":"versió de la api", 41 | "Response Content Type":"Tipus de Contingut de la Resposta", 42 | "fetching resource":"recollint recurs", 43 | "fetching resource list":"recollins llista de recursos", 44 | "Explore":"Explorant", 45 | "Show Swagger Petstore Example Apis":"Mostrar API d'Exemple Swagger Petstore", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"No es pot llegir del servidor. Potser no teniu la configuració de control d'accés apropiada.", 47 | "Please specify the protocol for":"Si us plau, especifiqueu el protocol per a", 48 | "Can't read swagger JSON from":"No es pot llegir el JSON de swagger des de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Finalitzada la càrrega del recurs informatiu. Renderitzant Swagger UI", 50 | "Unable to read api":"No es pot llegir l'api", 51 | "from path":"des de la ruta", 52 | "server returned":"el servidor ha retornat" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/en.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Warning: Deprecated", 6 | "Implementation Notes":"Implementation Notes", 7 | "Response Class":"Response Class", 8 | "Status":"Status", 9 | "Parameters":"Parameters", 10 | "Parameter":"Parameter", 11 | "Value":"Value", 12 | "Description":"Description", 13 | "Parameter Type":"Parameter Type", 14 | "Data Type":"Data Type", 15 | "Response Messages":"Response Messages", 16 | "HTTP Status Code":"HTTP Status Code", 17 | "Reason":"Reason", 18 | "Response Model":"Response Model", 19 | "Request URL":"Request URL", 20 | "Response Body":"Response Body", 21 | "Response Code":"Response Code", 22 | "Response Headers":"Response Headers", 23 | "Hide Response":"Hide Response", 24 | "Headers":"Headers", 25 | "Try it out!":"Try it out!", 26 | "Show/Hide":"Show/Hide", 27 | "List Operations":"List Operations", 28 | "Expand Operations":"Expand Operations", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"can't parse JSON. Raw result", 31 | "Example Value":"Example Value", 32 | "Model Schema":"Model Schema", 33 | "Model":"Model", 34 | "Click to set as parameter value":"Click to set as parameter value", 35 | "apply":"apply", 36 | "Username":"Username", 37 | "Password":"Password", 38 | "Terms of service":"Terms of service", 39 | "Created by":"Created by", 40 | "See more at":"See more at", 41 | "Contact the developer":"Contact the developer", 42 | "api version":"api version", 43 | "Response Content Type":"Response Content Type", 44 | "Parameter content type:":"Parameter content type:", 45 | "fetching resource":"fetching resource", 46 | "fetching resource list":"fetching resource list", 47 | "Explore":"Explore", 48 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 49 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.", 50 | "Please specify the protocol for":"Please specify the protocol for", 51 | "Can't read swagger JSON from":"Can't read swagger JSON from", 52 | "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI", 53 | "Unable to read api":"Unable to read api", 54 | "from path":"from path", 55 | "server returned":"server returned" 56 | }); 57 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/es.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Advertencia: Obsoleto", 6 | "Implementation Notes":"Notas de implementación", 7 | "Response Class":"Clase de la Respuesta", 8 | "Status":"Status", 9 | "Parameters":"Parámetros", 10 | "Parameter":"Parámetro", 11 | "Value":"Valor", 12 | "Description":"Descripción", 13 | "Parameter Type":"Tipo del Parámetro", 14 | "Data Type":"Tipo del Dato", 15 | "Response Messages":"Mensajes de la Respuesta", 16 | "HTTP Status Code":"Código de Status HTTP", 17 | "Reason":"Razón", 18 | "Response Model":"Modelo de la Respuesta", 19 | "Request URL":"URL de la Solicitud", 20 | "Response Body":"Cuerpo de la Respuesta", 21 | "Response Code":"Código de la Respuesta", 22 | "Response Headers":"Encabezados de la Respuesta", 23 | "Hide Response":"Ocultar Respuesta", 24 | "Try it out!":"Pruébalo!", 25 | "Show/Hide":"Mostrar/Ocultar", 26 | "List Operations":"Listar Operaciones", 27 | "Expand Operations":"Expandir Operaciones", 28 | "Raw":"Crudo", 29 | "can't parse JSON. Raw result":"no puede parsear el JSON. Resultado crudo", 30 | "Example Value":"Valor de Ejemplo", 31 | "Model Schema":"Esquema del Modelo", 32 | "Model":"Modelo", 33 | "apply":"aplicar", 34 | "Username":"Nombre de usuario", 35 | "Password":"Contraseña", 36 | "Terms of service":"Términos de Servicio", 37 | "Created by":"Creado por", 38 | "See more at":"Ver más en", 39 | "Contact the developer":"Contactar al desarrollador", 40 | "api version":"versión de la api", 41 | "Response Content Type":"Tipo de Contenido (Content Type) de la Respuesta", 42 | "fetching resource":"buscando recurso", 43 | "fetching resource list":"buscando lista del recurso", 44 | "Explore":"Explorar", 45 | "Show Swagger Petstore Example Apis":"Mostrar Api Ejemplo de Swagger Petstore", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"No se puede leer del servidor. Tal vez no tiene la configuración de control de acceso de origen (access-control-origin) apropiado.", 47 | "Please specify the protocol for":"Por favor, especificar el protocola para", 48 | "Can't read swagger JSON from":"No se puede leer el JSON de swagger desde", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Finalizada la carga del recurso de Información. Mostrando Swagger UI", 50 | "Unable to read api":"No se puede leer la api", 51 | "from path":"desde ruta", 52 | "server returned":"el servidor retornó" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/fr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Avertissement : Obsolète", 6 | "Implementation Notes":"Notes d'implémentation", 7 | "Response Class":"Classe de la réponse", 8 | "Status":"Statut", 9 | "Parameters":"Paramètres", 10 | "Parameter":"Paramètre", 11 | "Value":"Valeur", 12 | "Description":"Description", 13 | "Parameter Type":"Type du paramètre", 14 | "Data Type":"Type de données", 15 | "Response Messages":"Messages de la réponse", 16 | "HTTP Status Code":"Code de statut HTTP", 17 | "Reason":"Raison", 18 | "Response Model":"Modèle de réponse", 19 | "Request URL":"URL appelée", 20 | "Response Body":"Corps de la réponse", 21 | "Response Code":"Code de la réponse", 22 | "Response Headers":"En-têtes de la réponse", 23 | "Hide Response":"Cacher la réponse", 24 | "Headers":"En-têtes", 25 | "Try it out!":"Testez !", 26 | "Show/Hide":"Afficher/Masquer", 27 | "List Operations":"Liste des opérations", 28 | "Expand Operations":"Développer les opérations", 29 | "Raw":"Brut", 30 | "can't parse JSON. Raw result":"impossible de décoder le JSON. Résultat brut", 31 | "Example Value":"Exemple la valeur", 32 | "Model Schema":"Définition du modèle", 33 | "Model":"Modèle", 34 | "apply":"appliquer", 35 | "Username":"Nom d'utilisateur", 36 | "Password":"Mot de passe", 37 | "Terms of service":"Conditions de service", 38 | "Created by":"Créé par", 39 | "See more at":"Voir plus sur", 40 | "Contact the developer":"Contacter le développeur", 41 | "api version":"version de l'api", 42 | "Response Content Type":"Content Type de la réponse", 43 | "fetching resource":"récupération de la ressource", 44 | "fetching resource list":"récupération de la liste de ressources", 45 | "Explore":"Explorer", 46 | "Show Swagger Petstore Example Apis":"Montrer les Apis de l'exemple Petstore de Swagger", 47 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Impossible de lire à partir du serveur. Il se peut que les réglages access-control-origin ne soient pas appropriés.", 48 | "Please specify the protocol for":"Veuillez spécifier un protocole pour", 49 | "Can't read swagger JSON from":"Impossible de lire le JSON swagger à partir de", 50 | "Finished Loading Resource Information. Rendering Swagger UI":"Chargement des informations terminé. Affichage de Swagger UI", 51 | "Unable to read api":"Impossible de lire l'api", 52 | "from path":"à partir du chemin", 53 | "server returned":"réponse du serveur" 54 | }); 55 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/geo.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"ყურადღება: აღარ გამოიყენება", 6 | "Implementation Notes":"იმპლემენტაციის აღწერა", 7 | "Response Class":"რესპონს კლასი", 8 | "Status":"სტატუსი", 9 | "Parameters":"პარამეტრები", 10 | "Parameter":"პარამეტრი", 11 | "Value":"მნიშვნელობა", 12 | "Description":"აღწერა", 13 | "Parameter Type":"პარამეტრის ტიპი", 14 | "Data Type":"მონაცემის ტიპი", 15 | "Response Messages":"პასუხი", 16 | "HTTP Status Code":"HTTP სტატუსი", 17 | "Reason":"მიზეზი", 18 | "Response Model":"რესპონს მოდელი", 19 | "Request URL":"მოთხოვნის URL", 20 | "Response Body":"პასუხის სხეული", 21 | "Response Code":"პასუხის კოდი", 22 | "Response Headers":"პასუხის ჰედერები", 23 | "Hide Response":"დამალე პასუხი", 24 | "Headers":"ჰედერები", 25 | "Try it out!":"ცადე !", 26 | "Show/Hide":"გამოჩენა/დამალვა", 27 | "List Operations":"ოპერაციების სია", 28 | "Expand Operations":"ოპერაციები ვრცლად", 29 | "Raw":"ნედლი", 30 | "can't parse JSON. Raw result":"JSON-ის დამუშავება ვერ მოხერხდა. ნედლი პასუხი", 31 | "Example Value":"მაგალითი", 32 | "Model Schema":"მოდელის სტრუქტურა", 33 | "Model":"მოდელი", 34 | "Click to set as parameter value":"პარამეტრისთვის მნიშვნელობის მისანიჭებლად, დააკლიკე", 35 | "apply":"გამოყენება", 36 | "Username":"მოხმარებელი", 37 | "Password":"პაროლი", 38 | "Terms of service":"მომსახურების პირობები", 39 | "Created by":"შექმნა", 40 | "See more at":"ნახე ვრცლად", 41 | "Contact the developer":"დაუკავშირდი დეველოპერს", 42 | "api version":"api ვერსია", 43 | "Response Content Type":"პასუხის კონტენტის ტიპი", 44 | "Parameter content type:":"პარამეტრის კონტენტის ტიპი:", 45 | "fetching resource":"რესურსების მიღება", 46 | "fetching resource list":"რესურსების სიის მიღება", 47 | "Explore":"ნახვა", 48 | "Show Swagger Petstore Example Apis":"ნახე Swagger Petstore სამაგალითო Api", 49 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"სერვერთან დაკავშირება ვერ ხერხდება. შეამოწმეთ access-control-origin.", 50 | "Please specify the protocol for":"მიუთითეთ პროტოკოლი", 51 | "Can't read swagger JSON from":"swagger JSON წაკითხვა ვერ მოხერხდა", 52 | "Finished Loading Resource Information. Rendering Swagger UI":"რესურსების ჩატვირთვა სრულდება. Swagger UI რენდერდება", 53 | "Unable to read api":"api წაკითხვა ვერ მოხერხდა", 54 | "from path":"მისამართიდან", 55 | "server returned":"სერვერმა დააბრუნა" 56 | }); 57 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/it.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Attenzione: Deprecato", 6 | "Implementation Notes":"Note di implementazione", 7 | "Response Class":"Classe della risposta", 8 | "Status":"Stato", 9 | "Parameters":"Parametri", 10 | "Parameter":"Parametro", 11 | "Value":"Valore", 12 | "Description":"Descrizione", 13 | "Parameter Type":"Tipo di parametro", 14 | "Data Type":"Tipo di dato", 15 | "Response Messages":"Messaggi della risposta", 16 | "HTTP Status Code":"Codice stato HTTP", 17 | "Reason":"Motivo", 18 | "Response Model":"Modello di risposta", 19 | "Request URL":"URL della richiesta", 20 | "Response Body":"Corpo della risposta", 21 | "Response Code":"Oggetto della risposta", 22 | "Response Headers":"Intestazioni della risposta", 23 | "Hide Response":"Nascondi risposta", 24 | "Try it out!":"Provalo!", 25 | "Show/Hide":"Mostra/Nascondi", 26 | "List Operations":"Mostra operazioni", 27 | "Expand Operations":"Espandi operazioni", 28 | "Raw":"Grezzo (raw)", 29 | "can't parse JSON. Raw result":"non è possibile parsare il JSON. Risultato grezzo (raw).", 30 | "Model Schema":"Schema del modello", 31 | "Model":"Modello", 32 | "apply":"applica", 33 | "Username":"Nome utente", 34 | "Password":"Password", 35 | "Terms of service":"Condizioni del servizio", 36 | "Created by":"Creato da", 37 | "See more at":"Informazioni aggiuntive:", 38 | "Contact the developer":"Contatta lo sviluppatore", 39 | "api version":"versione api", 40 | "Response Content Type":"Tipo di contenuto (content type) della risposta", 41 | "fetching resource":"recuperando la risorsa", 42 | "fetching resource list":"recuperando lista risorse", 43 | "Explore":"Esplora", 44 | "Show Swagger Petstore Example Apis":"Mostra le api di esempio di Swagger Petstore", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Non è possibile leggere dal server. Potrebbe non avere le impostazioni di controllo accesso origine (access-control-origin) appropriate.", 46 | "Please specify the protocol for":"Si prega di specificare il protocollo per", 47 | "Can't read swagger JSON from":"Impossibile leggere JSON swagger da:", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Lettura informazioni risorse termianta. Swagger UI viene mostrata", 49 | "Unable to read api":"Impossibile leggere la api", 50 | "from path":"da cartella", 51 | "server returned":"il server ha restituito" 52 | }); 53 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/ja.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告: 廃止予定", 6 | "Implementation Notes":"実装メモ", 7 | "Response Class":"レスポンスクラス", 8 | "Status":"ステータス", 9 | "Parameters":"パラメータ群", 10 | "Parameter":"パラメータ", 11 | "Value":"値", 12 | "Description":"説明", 13 | "Parameter Type":"パラメータタイプ", 14 | "Data Type":"データタイプ", 15 | "Response Messages":"レスポンスメッセージ", 16 | "HTTP Status Code":"HTTPステータスコード", 17 | "Reason":"理由", 18 | "Response Model":"レスポンスモデル", 19 | "Request URL":"リクエストURL", 20 | "Response Body":"レスポンスボディ", 21 | "Response Code":"レスポンスコード", 22 | "Response Headers":"レスポンスヘッダ", 23 | "Hide Response":"レスポンスを隠す", 24 | "Headers":"ヘッダ", 25 | "Try it out!":"実際に実行!", 26 | "Show/Hide":"表示/非表示", 27 | "List Operations":"操作一覧", 28 | "Expand Operations":"操作の展開", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"JSONへ解釈できません. 未加工の結果", 31 | "Model Schema":"モデルスキーマ", 32 | "Model":"モデル", 33 | "apply":"実行", 34 | "Username":"ユーザ名", 35 | "Password":"パスワード", 36 | "Terms of service":"サービス利用規約", 37 | "Created by":"Created by", 38 | "See more at":"See more at", 39 | "Contact the developer":"開発者に連絡", 40 | "api version":"APIバージョン", 41 | "Response Content Type":"レスポンス コンテンツタイプ", 42 | "fetching resource":"リソースの取得", 43 | "fetching resource list":"リソース一覧の取得", 44 | "Explore":"Explore", 45 | "Show Swagger Petstore Example Apis":"SwaggerペットストアAPIの表示", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"サーバから読み込めません. 適切なaccess-control-origin設定を持っていない可能性があります.", 47 | "Please specify the protocol for":"プロトコルを指定してください", 48 | "Can't read swagger JSON from":"次からswagger JSONを読み込めません", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"リソース情報の読み込みが完了しました. Swagger UIを描画しています", 50 | "Unable to read api":"APIを読み込めません", 51 | "from path":"次のパスから", 52 | "server returned":"サーバからの返答" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/ko-kr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"경고:폐기예정됨", 6 | "Implementation Notes":"구현 노트", 7 | "Response Class":"응답 클래스", 8 | "Status":"상태", 9 | "Parameters":"매개변수들", 10 | "Parameter":"매개변수", 11 | "Value":"값", 12 | "Description":"설명", 13 | "Parameter Type":"매개변수 타입", 14 | "Data Type":"데이터 타입", 15 | "Response Messages":"응답 메세지", 16 | "HTTP Status Code":"HTTP 상태 코드", 17 | "Reason":"원인", 18 | "Response Model":"응답 모델", 19 | "Request URL":"요청 URL", 20 | "Response Body":"응답 본문", 21 | "Response Code":"응답 코드", 22 | "Response Headers":"응답 헤더", 23 | "Hide Response":"응답 숨기기", 24 | "Headers":"헤더", 25 | "Try it out!":"써보기!", 26 | "Show/Hide":"보이기/숨기기", 27 | "List Operations":"목록 작업", 28 | "Expand Operations":"전개 작업", 29 | "Raw":"원본", 30 | "can't parse JSON. Raw result":"JSON을 파싱할수 없음. 원본결과:", 31 | "Model Schema":"모델 스키마", 32 | "Model":"모델", 33 | "apply":"적용", 34 | "Username":"사용자 이름", 35 | "Password":"암호", 36 | "Terms of service":"이용약관", 37 | "Created by":"작성자", 38 | "See more at":"추가정보:", 39 | "Contact the developer":"개발자에게 문의", 40 | "api version":"api버전", 41 | "Response Content Type":"응답Content Type", 42 | "fetching resource":"리소스 가져오기", 43 | "fetching resource list":"리소스 목록 가져오기", 44 | "Explore":"탐색", 45 | "Show Swagger Petstore Example Apis":"Swagger Petstore 예제 보기", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"서버로부터 읽어들일수 없습니다. access-control-origin 설정이 올바르지 않을수 있습니다.", 47 | "Please specify the protocol for":"다음을 위한 프로토콜을 정하세요", 48 | "Can't read swagger JSON from":"swagger JSON 을 다음으로 부터 읽을수 없습니다", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"리소스 정보 불러오기 완료. Swagger UI 랜더링", 50 | "Unable to read api":"api를 읽을 수 없습니다.", 51 | "from path":"다음 경로로 부터", 52 | "server returned":"서버 응답함." 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/pl.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Uwaga: Wycofane", 6 | "Implementation Notes":"Uwagi Implementacji", 7 | "Response Class":"Klasa Odpowiedzi", 8 | "Status":"Status", 9 | "Parameters":"Parametry", 10 | "Parameter":"Parametr", 11 | "Value":"Wartość", 12 | "Description":"Opis", 13 | "Parameter Type":"Typ Parametru", 14 | "Data Type":"Typ Danych", 15 | "Response Messages":"Wiadomości Odpowiedzi", 16 | "HTTP Status Code":"Kod Statusu HTTP", 17 | "Reason":"Przyczyna", 18 | "Response Model":"Model Odpowiedzi", 19 | "Request URL":"URL Wywołania", 20 | "Response Body":"Treść Odpowiedzi", 21 | "Response Code":"Kod Odpowiedzi", 22 | "Response Headers":"Nagłówki Odpowiedzi", 23 | "Hide Response":"Ukryj Odpowiedź", 24 | "Headers":"Nagłówki", 25 | "Try it out!":"Wypróbuj!", 26 | "Show/Hide":"Pokaż/Ukryj", 27 | "List Operations":"Lista Operacji", 28 | "Expand Operations":"Rozwiń Operacje", 29 | "Raw":"Nieprzetworzone", 30 | "can't parse JSON. Raw result":"nie można przetworzyć pliku JSON. Nieprzetworzone dane", 31 | "Model Schema":"Schemat Modelu", 32 | "Model":"Model", 33 | "apply":"użyj", 34 | "Username":"Nazwa użytkownika", 35 | "Password":"Hasło", 36 | "Terms of service":"Warunki używania", 37 | "Created by":"Utworzone przez", 38 | "See more at":"Zobacz więcej na", 39 | "Contact the developer":"Kontakt z deweloperem", 40 | "api version":"wersja api", 41 | "Response Content Type":"Typ Zasobu Odpowiedzi", 42 | "fetching resource":"ładowanie zasobu", 43 | "fetching resource list":"ładowanie listy zasobów", 44 | "Explore":"Eksploruj", 45 | "Show Swagger Petstore Example Apis":"Pokaż Przykładowe Api Swagger Petstore", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Brak połączenia z serwerem. Może on nie mieć odpowiednich ustawień access-control-origin.", 47 | "Please specify the protocol for":"Proszę podać protokół dla", 48 | "Can't read swagger JSON from":"Nie można odczytać swagger JSON z", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Ukończono Ładowanie Informacji o Zasobie. Renderowanie Swagger UI", 50 | "Unable to read api":"Nie można odczytać api", 51 | "from path":"ze ścieżki", 52 | "server returned":"serwer zwrócił" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/pt.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Aviso: Depreciado", 6 | "Implementation Notes":"Notas de Implementação", 7 | "Response Class":"Classe de resposta", 8 | "Status":"Status", 9 | "Parameters":"Parâmetros", 10 | "Parameter":"Parâmetro", 11 | "Value":"Valor", 12 | "Description":"Descrição", 13 | "Parameter Type":"Tipo de parâmetro", 14 | "Data Type":"Tipo de dados", 15 | "Response Messages":"Mensagens de resposta", 16 | "HTTP Status Code":"Código de status HTTP", 17 | "Reason":"Razão", 18 | "Response Model":"Modelo resposta", 19 | "Request URL":"URL requisição", 20 | "Response Body":"Corpo da resposta", 21 | "Response Code":"Código da resposta", 22 | "Response Headers":"Cabeçalho da resposta", 23 | "Headers":"Cabeçalhos", 24 | "Hide Response":"Esconder resposta", 25 | "Try it out!":"Tente agora!", 26 | "Show/Hide":"Mostrar/Esconder", 27 | "List Operations":"Listar operações", 28 | "Expand Operations":"Expandir operações", 29 | "Raw":"Cru", 30 | "can't parse JSON. Raw result":"Falha ao analisar JSON. Resulto cru", 31 | "Model Schema":"Modelo esquema", 32 | "Model":"Modelo", 33 | "apply":"Aplicar", 34 | "Username":"Usuário", 35 | "Password":"Senha", 36 | "Terms of service":"Termos do serviço", 37 | "Created by":"Criado por", 38 | "See more at":"Veja mais em", 39 | "Contact the developer":"Contate o desenvolvedor", 40 | "api version":"Versão api", 41 | "Response Content Type":"Tipo de conteúdo da resposta", 42 | "fetching resource":"busca recurso", 43 | "fetching resource list":"buscando lista de recursos", 44 | "Explore":"Explorar", 45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Não é possível ler do servidor. Pode não ter as apropriadas configurações access-control-origin", 47 | "Please specify the protocol for":"Por favor especifique o protocolo", 48 | "Can't read swagger JSON from":"Não é possível ler o JSON Swagger de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Carregar informação de recurso finalizada. Renderizando Swagger UI", 50 | "Unable to read api":"Não foi possível ler api", 51 | "from path":"do caminho", 52 | "server returned":"servidor retornou" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/ru.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Предупреждение: Устарело", 6 | "Implementation Notes":"Заметки", 7 | "Response Class":"Пример ответа", 8 | "Status":"Статус", 9 | "Parameters":"Параметры", 10 | "Parameter":"Параметр", 11 | "Value":"Значение", 12 | "Description":"Описание", 13 | "Parameter Type":"Тип параметра", 14 | "Data Type":"Тип данных", 15 | "HTTP Status Code":"HTTP код", 16 | "Reason":"Причина", 17 | "Response Model":"Структура ответа", 18 | "Request URL":"URL запроса", 19 | "Response Body":"Тело ответа", 20 | "Response Code":"HTTP код ответа", 21 | "Response Headers":"Заголовки ответа", 22 | "Hide Response":"Спрятать ответ", 23 | "Headers":"Заголовки", 24 | "Response Messages":"Что может прийти в ответ", 25 | "Try it out!":"Попробовать!", 26 | "Show/Hide":"Показать/Скрыть", 27 | "List Operations":"Операции кратко", 28 | "Expand Operations":"Операции подробно", 29 | "Raw":"В сыром виде", 30 | "can't parse JSON. Raw result":"Не удается распарсить ответ:", 31 | "Example Value":"Пример", 32 | "Model Schema":"Структура", 33 | "Model":"Описание", 34 | "Click to set as parameter value":"Нажмите, чтобы испльзовать в качестве значения параметра", 35 | "apply":"применить", 36 | "Username":"Имя пользователя", 37 | "Password":"Пароль", 38 | "Terms of service":"Условия использования", 39 | "Created by":"Разработано", 40 | "See more at":"Еще тут", 41 | "Contact the developer":"Связаться с разработчиком", 42 | "api version":"Версия API", 43 | "Response Content Type":"Content Type ответа", 44 | "Parameter content type:":"Content Type параметра:", 45 | "fetching resource":"Получение ресурса", 46 | "fetching resource list":"Получение ресурсов", 47 | "Explore":"Показать", 48 | "Show Swagger Petstore Example Apis":"Показать примеры АПИ", 49 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, проблема с настройками доступа", 50 | "Please specify the protocol for":"Пожалуйста, укажите протокол для", 51 | "Can't read swagger JSON from":"Не получается прочитать swagger json из", 52 | "Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим", 53 | "Unable to read api":"Не удалось прочитать api", 54 | "from path":"по адресу", 55 | "server returned":"сервер сказал" 56 | }); 57 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/tr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Uyarı: Deprecated", 6 | "Implementation Notes":"Gerçekleştirim Notları", 7 | "Response Class":"Dönen Sınıf", 8 | "Status":"Statü", 9 | "Parameters":"Parametreler", 10 | "Parameter":"Parametre", 11 | "Value":"Değer", 12 | "Description":"Açıklama", 13 | "Parameter Type":"Parametre Tipi", 14 | "Data Type":"Veri Tipi", 15 | "Response Messages":"Dönüş Mesajı", 16 | "HTTP Status Code":"HTTP Statü Kodu", 17 | "Reason":"Gerekçe", 18 | "Response Model":"Dönüş Modeli", 19 | "Request URL":"İstek URL", 20 | "Response Body":"Dönüş İçeriği", 21 | "Response Code":"Dönüş Kodu", 22 | "Response Headers":"Dönüş Üst Bilgileri", 23 | "Hide Response":"Dönüşü Gizle", 24 | "Headers":"Üst Bilgiler", 25 | "Try it out!":"Dene!", 26 | "Show/Hide":"Göster/Gizle", 27 | "List Operations":"Operasyonları Listele", 28 | "Expand Operations":"Operasyonları Aç", 29 | "Raw":"Ham", 30 | "can't parse JSON. Raw result":"JSON çözümlenemiyor. Ham sonuç", 31 | "Model Schema":"Model Şema", 32 | "Model":"Model", 33 | "apply":"uygula", 34 | "Username":"Kullanıcı Adı", 35 | "Password":"Parola", 36 | "Terms of service":"Servis şartları", 37 | "Created by":"Oluşturan", 38 | "See more at":"Daha fazlası için", 39 | "Contact the developer":"Geliştirici ile İletişime Geçin", 40 | "api version":"api versiyon", 41 | "Response Content Type":"Dönüş İçerik Tipi", 42 | "fetching resource":"kaynak getiriliyor", 43 | "fetching resource list":"kaynak listesi getiriliyor", 44 | "Explore":"Keşfet", 45 | "Show Swagger Petstore Example Apis":"Swagger Petstore Örnek Api'yi Gör", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Sunucudan okuma yapılamıyor. Sunucu access-control-origin ayarlarınızı kontrol edin.", 47 | "Please specify the protocol for":"Lütfen istenen adres için protokol belirtiniz", 48 | "Can't read swagger JSON from":"Swagger JSON bu kaynaktan okunamıyor", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Kaynak baglantısı tamamlandı. Swagger UI gösterime hazırlanıyor", 50 | "Unable to read api":"api okunamadı", 51 | "from path":"yoldan", 52 | "server returned":"sunucuya dönüldü" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/translator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Translator for documentation pages. 5 | * 6 | * To enable translation you should include one of language-files in your index.html 7 | * after . 8 | * For example - 9 | * 10 | * If you wish to translate some new texts you should do two things: 11 | * 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too. 12 | * 2. Mark that text it templates this way New Phrase or . 13 | * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate. 14 | * 15 | */ 16 | window.SwaggerTranslator = { 17 | 18 | _words:[], 19 | 20 | translate: function(sel) { 21 | var $this = this; 22 | sel = sel || '[data-sw-translate]'; 23 | 24 | $(sel).each(function() { 25 | $(this).html($this._tryTranslate($(this).html())); 26 | 27 | $(this).val($this._tryTranslate($(this).val())); 28 | $(this).attr('title', $this._tryTranslate($(this).attr('title'))); 29 | }); 30 | }, 31 | 32 | _tryTranslate: function(word) { 33 | return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; 34 | }, 35 | 36 | learn: function(wordsMap) { 37 | this._words = wordsMap; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lang/zh-cn.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告:已过时", 6 | "Implementation Notes":"实现备注", 7 | "Response Class":"响应类", 8 | "Status":"状态", 9 | "Parameters":"参数", 10 | "Parameter":"参数", 11 | "Value":"值", 12 | "Description":"描述", 13 | "Parameter Type":"参数类型", 14 | "Data Type":"数据类型", 15 | "Response Messages":"响应消息", 16 | "HTTP Status Code":"HTTP状态码", 17 | "Reason":"原因", 18 | "Response Model":"响应模型", 19 | "Request URL":"请求URL", 20 | "Response Body":"响应体", 21 | "Response Code":"响应码", 22 | "Response Headers":"响应头", 23 | "Hide Response":"隐藏响应", 24 | "Headers":"头", 25 | "Try it out!":"试一下!", 26 | "Show/Hide":"显示/隐藏", 27 | "List Operations":"显示操作", 28 | "Expand Operations":"展开操作", 29 | "Raw":"原始", 30 | "can't parse JSON. Raw result":"无法解析JSON. 原始结果", 31 | "Model Schema":"模型架构", 32 | "Model":"模型", 33 | "apply":"应用", 34 | "Username":"用户名", 35 | "Password":"密码", 36 | "Terms of service":"服务条款", 37 | "Created by":"创建者", 38 | "See more at":"查看更多:", 39 | "Contact the developer":"联系开发者", 40 | "api version":"api版本", 41 | "Response Content Type":"响应Content Type", 42 | "fetching resource":"正在获取资源", 43 | "fetching resource list":"正在获取资源列表", 44 | "Explore":"浏览", 45 | "Show Swagger Petstore Example Apis":"显示 Swagger Petstore 示例 Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"无法从服务器读取。可能没有正确设置access-control-origin。", 47 | "Please specify the protocol for":"请指定协议:", 48 | "Can't read swagger JSON from":"无法读取swagger JSON于", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"已加载资源信息。正在渲染Swagger UI", 50 | "Unable to read api":"无法读取api", 51 | "from path":"从路径", 52 | "server returned":"服务器返回" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lib/highlight.9.1.0.pack_extended.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | (function () { 4 | var configure, highlightBlock; 5 | 6 | configure = hljs.configure; 7 | // "extending" hljs.configure method 8 | hljs.configure = function _configure (options) { 9 | var size = options.highlightSizeThreshold; 10 | 11 | // added highlightSizeThreshold option to set maximum size 12 | // of processed string. Set to null if not a number 13 | hljs.highlightSizeThreshold = size === +size ? size : null; 14 | 15 | configure.call(this, options); 16 | }; 17 | 18 | highlightBlock = hljs.highlightBlock; 19 | 20 | // "extending" hljs.highlightBlock method 21 | hljs.highlightBlock = function _highlightBlock (el) { 22 | var innerHTML = el.innerHTML; 23 | var size = hljs.highlightSizeThreshold; 24 | 25 | // check if highlightSizeThreshold is not set or element innerHTML 26 | // is less than set option highlightSizeThreshold 27 | if (size == null || size > innerHTML.length) { 28 | // proceed with hljs.highlightBlock 29 | highlightBlock.call(hljs, el); 30 | } 31 | }; 32 | 33 | })(); 34 | 35 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lib/jquery.ba-bbq.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 3 | * http://benalman.com/projects/jquery-bbq-plugin/ 4 | * 5 | * Copyright (c) 2010 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lib/jquery.slideto.min.js: -------------------------------------------------------------------------------- 1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery); 2 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lib/jquery.wiggle.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | jQuery Wiggle 3 | Author: WonderGroup, Jordan Thomas 4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html 5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License) 6 | */ 7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('
').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);} 8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});}; -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/lib/object-assign-pollyfill.js: -------------------------------------------------------------------------------- 1 | if (typeof Object.assign != 'function') { 2 | (function () { 3 | Object.assign = function (target) { 4 | 'use strict'; 5 | if (target === undefined || target === null) { 6 | throw new TypeError('Cannot convert undefined or null to object'); 7 | } 8 | 9 | var output = Object(target); 10 | for (var index = 1; index < arguments.length; index++) { 11 | var source = arguments[index]; 12 | if (source !== undefined && source !== null) { 13 | for (var nextKey in source) { 14 | if (Object.prototype.hasOwnProperty.call(source, nextKey)) { 15 | output[nextKey] = source[nextKey]; 16 | } 17 | } 18 | } 19 | } 20 | return output; 21 | }; 22 | })(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/swagger/o2c.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | contextConfigLocation 11 | classpath:spring/spring-*.xml 12 | 13 | 14 | 15 | 16 | mirs-dispather 17 | org.springframework.web.servlet.DispatcherServlet 18 | 19 | contextConfigLocation 20 | 21 | 22 | 1 23 | true 24 | 25 | 26 | 27 | mirs-dispather 28 | 29 | /* 30 | 31 | 32 | 33 | org.springframework.web.context.ContextLoaderListener 34 | 35 | 36 | 37 | 38 | CORS 39 | com.thetransactioncompany.cors.CORSFilter 40 | 41 | 42 | cors.allowOrigin 43 | * 44 | 45 | true 46 | 47 | 48 | CORS 49 | /* 50 | 51 | 52 | 53 | 54 | encoding 55 | org.springframework.web.filter.CharacterEncodingFilter 56 | 57 | encoding 58 | UTF-8 59 | 60 | true 61 | 62 | 63 | encoding 64 | /* 65 | 66 | 67 | 68 | 69 | shiroFilter 70 | org.springframework.web.filter.DelegatingFilterProxy 71 | 72 | targetFilterLifecycle 73 | true 74 | 75 | true 76 | 77 | 78 | shiroFilter 79 | /* 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/test/main/com/kevin/lucene/LuceneTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.lucene; 2 | 3 | 4 | import org.apache.lucene.analysis.Analyzer; 5 | import org.apache.lucene.analysis.standard.StandardAnalyzer; 6 | import org.apache.lucene.document.Document; 7 | import org.apache.lucene.document.Field; 8 | import org.apache.lucene.document.TextField; 9 | import org.apache.lucene.index.DirectoryReader; 10 | import org.apache.lucene.index.IndexWriter; 11 | import org.apache.lucene.index.IndexWriterConfig; 12 | import org.apache.lucene.queryparser.classic.ParseException; 13 | import org.apache.lucene.queryparser.classic.QueryParser; 14 | import org.apache.lucene.search.IndexSearcher; 15 | import org.apache.lucene.search.Query; 16 | import org.apache.lucene.search.ScoreDoc; 17 | import org.apache.lucene.store.Directory; 18 | import org.apache.lucene.store.FSDirectory; 19 | import org.apache.lucene.store.RAMDirectory; 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.springframework.test.context.ContextConfiguration; 23 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 24 | 25 | import javax.annotation.Resource; 26 | import java.io.IOException; 27 | import java.nio.file.Path; 28 | import java.nio.file.Paths; 29 | 30 | @RunWith(SpringJUnit4ClassRunner.class) 31 | // 告诉Junit Sping配置文件 32 | @ContextConfiguration({"classpath:junit/spring-test.xml"}) 33 | public class LuceneTest { 34 | 35 | @Resource 36 | Analyzer analyzer; 37 | 38 | @Resource 39 | IndexWriter indexWriter; 40 | 41 | @Resource 42 | Document document; 43 | 44 | @Resource 45 | IndexSearcher indexSearcher; 46 | 47 | 48 | @Test 49 | public void testLucene() throws IOException, ParseException { 50 | 51 | // Store the index in memory: 52 | // Directory directory = new RAMDirectory(); 53 | // To store an index on disk, use this instead: 54 | String text = "jcseg是使用Java开发的一款开源的中文分词器, 基于流行的mmseg算法实现," + 55 | "分词准确率高达98.4%, 支持中文人名识别, 同义词匹配, 停止词过滤等。" + 56 | "并且提供了最新版本的lucene,solr,elasticsearch分词接口。"; 57 | // document.add(new Field("fieldname", text, TextField.TYPE_STORED)); 58 | document.add(new Field("fieldname", "好烦", TextField.TYPE_STORED)); 59 | // indexWriter.deleteAll(); 60 | indexWriter.addDocument(document); 61 | 62 | // Now search the index: 63 | // Parse a simple query that searches for "text": 64 | QueryParser parser = new QueryParser("fieldname", analyzer); 65 | Query query = parser.parse("好烦"); 66 | ScoreDoc[] hits = indexSearcher.search(query, 1000).scoreDocs; 67 | //assertEquals(1, hits.length); 68 | System.out.println(1 == hits.length); 69 | // Iterate through the results: 70 | for (int i = 0; i < hits.length; i++) { 71 | Document hitDoc = indexSearcher.doc(hits[i].doc); 72 | //assertEquals("This is the text to be indexed.", hitDoc.get("fieldname")); 73 | System.out.println(hitDoc.get("fieldname")); 74 | } 75 | } 76 | 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/EmailVerifyDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.utils.EncryptionUtils; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import java.sql.Timestamp; 12 | import java.util.Date; 13 | 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(SpringJUnit4ClassRunner.class) 17 | // 告诉Junit Spring配置文件 18 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 19 | public class EmailVerifyDaoTest { 20 | 21 | @Resource 22 | EmailVerifyDao dao; 23 | 24 | @Test 25 | public void add() throws Exception { 26 | 27 | String e = "123@qq.com"; 28 | Timestamp ct = new Timestamp(new Date().getTime()); 29 | Timestamp et = new Timestamp(new Date().getTime() + 5000); 30 | char c = '1'; 31 | String v = EncryptionUtils.getVerification(); 32 | char vt = '1'; 33 | String ip = "1.1.1.1"; 34 | dao.add(e, ct, et, c, v, vt, ip); 35 | } 36 | 37 | @Test 38 | public void updateStatusByEmail() throws Exception { 39 | dao.updateStatusByEmail("123@qq.com", '2'); 40 | } 41 | 42 | @Test 43 | public void updateStatusByExpireTime() throws Exception { 44 | 45 | dao.updateStatusByExpireTime(new Timestamp(new Date().getTime()), '3'); 46 | } 47 | 48 | @Test 49 | public void getExpireTimeByEmail() throws Exception { 50 | System.out.println(dao.getExpireTimeByEmail("123@qq.com")); 51 | } 52 | 53 | @Test 54 | public void getExpireTimeByStatus() throws Exception { 55 | System.out.println(dao.getExpireTimeByStatus('1', "expire_time", 1, 0)); 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/FriendDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | // 告诉Junit Spring配置文件 14 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 15 | public class FriendDaoTest { 16 | 17 | @Resource 18 | FriendDao friendDao; 19 | 20 | @Test 21 | public void addFriendRecord() throws Exception { 22 | System.out.println(friendDao.addFriendRecord(1, 1)); 23 | } 24 | 25 | @Test 26 | public void getAllFriend() throws Exception { 27 | System.out.println(friendDao.getAllFriend()); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/RegisterSessionDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.enums.RSStatusEnum; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import javax.annotation.Resource; 10 | import java.sql.Timestamp; 11 | import java.util.Date; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | // 告诉Junit Spring配置文件 15 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 16 | public class RegisterSessionDaoTest { 17 | 18 | @Resource 19 | RegisterSessionDao registerSessionDao; 20 | 21 | @Test 22 | public void addRegisterSession() throws Exception { 23 | 24 | String email = "22@qq.com"; 25 | String ip = "12.12.12.12"; 26 | Timestamp ct = new Timestamp(new Date().getTime()); 27 | Timestamp et = new Timestamp(new Date().getTime() + 30 * 60 * 1000); 28 | 29 | System.out.println(registerSessionDao.add(ct, email, ip, et)); 30 | } 31 | 32 | @Test 33 | public void updateStatusByEmail() throws Exception { 34 | System.out.println(registerSessionDao.updateStatusByEmail( 35 | "22@qq.com", 36 | RSStatusEnum.EXPIRED.getStatus())); 37 | } 38 | 39 | @Test 40 | public void getExpireTimeByEmail() throws Exception { 41 | System.out.println( 42 | registerSessionDao.getExpireTimeByEmail("22@qq.com") 43 | ); 44 | } 45 | 46 | @Test 47 | public void getExpireTimeByStatus() throws Exception { 48 | System.out.println( 49 | registerSessionDao.getExpireTimeByStatus('1',"expire_time",1,2) 50 | ); 51 | } 52 | 53 | @Test 54 | public void updateStatusByExpireTime() throws Exception { 55 | Timestamp t = registerSessionDao.getExpireTimeByEmail("22@qq.com"); 56 | System.out.println(registerSessionDao.updateStatusByExpireTime(t, '3')); 57 | } 58 | 59 | 60 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.entity.User; 4 | import com.kevin.mirs.utils.EncryptionUtils; 5 | import com.kevin.mirs.vo.UserProfile; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.test.context.ContextConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | 13 | import javax.annotation.Resource; 14 | import java.sql.Timestamp; 15 | import java.util.Date; 16 | 17 | 18 | /** 19 | * 配置Spring和Junit整合,使得Junit启动时加载SpingIoC容器 20 | */ 21 | @RunWith(SpringJUnit4ClassRunner.class) 22 | // 告诉Junit Spring配置文件 23 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 24 | public class UserDaoTest { 25 | 26 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 27 | 28 | @Resource 29 | UserDao userDao; 30 | 31 | @Test 32 | public void addUser() throws Exception { 33 | 34 | String username = "test343"; 35 | String password = EncryptionUtils.getSalt(64); 36 | String salt = EncryptionUtils.getSalt(32); 37 | String email = "123434@qq.com"; 38 | Timestamp registerTime = new Timestamp(new Date().getTime()); 39 | String registerIp = "123.25.63.7"; 40 | 41 | User user = new User(username, password, salt, email, registerTime, registerIp); 42 | 43 | logger.info("--------create a user: " + user); 44 | 45 | logger.info("-------before insert user id: " + user.getId()); 46 | 47 | int result = userDao.addUser(user); 48 | 49 | logger.info("-------insert " + result + " user" ); 50 | logger.info("-------after insert user id: " + user.getId()); 51 | 52 | 53 | 54 | } 55 | 56 | @Test 57 | public void testTimestamp() throws Exception { 58 | 59 | Timestamp t1 = new Timestamp(new Date().getTime()); 60 | Thread.sleep(1); 61 | Timestamp t2 = new Timestamp(new Date().getTime()); 62 | 63 | if(t1.getTime() < t2.getTime()) { 64 | System.out.println(t1.getTime() + "\n" + t2.getTime()); 65 | } 66 | } 67 | 68 | @Test 69 | public void update() throws Exception { 70 | System.out.println(userDao.updateUsernameByUserId(1, "newte23st")); 71 | System.out.println(userDao.updateUserPasswordByUserId(1, "newtest")); 72 | System.out.println(userDao.updateUserAvatarByUserId(1, "/src/1.jpeg")); 73 | System.out.println(userDao.updateUserBioByUserId(1, "2333333")); 74 | System.out.println(userDao.updateUserLocationByUserId(1, "成都")); 75 | System.out.println(userDao.updateUserUniversityByUserId(1, "电子科技大学")); 76 | System.out.println(userDao.updateUserMajorByUserId(1, "软件技术")); 77 | System.out.println(userDao.updateUserLoginInfoByUserId(1, new Timestamp(new Date().getTime()), "1.1.1.1")); 78 | } 79 | 80 | @Test 81 | public void check() throws Exception { 82 | System.out.println(userDao.checkUserEmail("")); 83 | System.out.println(userDao.checkUserEmail("123@qq.com")); 84 | System.out.println(userDao.checkUsername("")); 85 | System.out.println(userDao.checkUsername("#$%564354*(^%")); 86 | 87 | } 88 | 89 | @Test 90 | public void get() throws Exception { 91 | System.out.println(userDao.getUserByUserEmail("123@qq.com")); 92 | User user = userDao.getUserByUserEmail("123@qq.com"); 93 | System.out.println(user.getStatus()); 94 | System.out.println(user.getAvatar() == null); 95 | // System.out.println(userDao.getUserByUserEmail("123@qq.com")); 96 | // System.out.println(userDao.getUserByUsername("")); 97 | // System.out.println(userDao.getUserByUsername("newte23st")); 98 | } 99 | 100 | @Test 101 | public void getUserProfileByUserId() throws Exception { 102 | System.out.println(userDao.getUserProfileByUserId(63)); 103 | } 104 | 105 | @Test 106 | public void updateUserProfile () throws Exception { 107 | UserProfile userProfile = new UserProfile(63, "123", "1@qq.com", "", "", "", ""); 108 | System.out.println(userDao.updateUserProfile(userProfile)); 109 | } 110 | 111 | @Test 112 | public void getUserPasswordByUserId() throws Exception { 113 | System.out.println(userDao.getUserPasswordByUserId(63)); 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/UserRecommendedFriendsDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import java.util.HashMap; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | @RunWith(SpringJUnit4ClassRunner.class) 15 | // 告诉Junit Spring配置文件 16 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 17 | 18 | public class UserRecommendedFriendsDaoTest { 19 | 20 | @Resource 21 | UserRecommendedFriendsDao userRecommendedFriendsDao; 22 | 23 | @Test 24 | public void addUserRecommendedFriends() throws Exception { 25 | long[] fids = {1,2,3}; 26 | System.out.println(userRecommendedFriendsDao.addUserRecommendedFriends(1, fids)); 27 | } 28 | 29 | @Test 30 | public void getUserRecommendedFriends() throws Exception { 31 | Integer[] friends = userRecommendedFriendsDao.getUserRecommendedFriends(1); 32 | for(Integer friend : friends) 33 | System.out.println(friend); 34 | } 35 | 36 | @Test 37 | public void clearUserRecommendedFriends() throws Exception { 38 | System.out.println(userRecommendedFriendsDao.clearUserRecommendedFriends(1)); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/dao/UserRecommendedMoviesDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.dao; 2 | 3 | import com.kevin.mirs.entity.UserRecommendedMovies; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.apache.ibatis.annotations.Param; 8 | import org.apache.mahout.cf.taste.impl.recommender.GenericRecommendedItem; 9 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | import javax.annotation.Resource; 16 | 17 | import java.util.ArrayList; 18 | 19 | import static org.junit.Assert.*; 20 | 21 | @RunWith(SpringJUnit4ClassRunner.class) 22 | // 告诉Junit Spring配置文件 23 | @ContextConfiguration({"classpath:spring/spring-dao.xml"}) 24 | public class UserRecommendedMoviesDaoTest { 25 | 26 | @Resource 27 | UserRecommendedMoviesDao userRecommendedMoviesDao; 28 | 29 | @Test 30 | public void addUserRecommendedMovies() throws Exception { 31 | 32 | List rms = new ArrayList(); 33 | RecommendedItem ri1 = new GenericRecommendedItem(1, 0.7f); 34 | RecommendedItem ri2 = new GenericRecommendedItem(2, 0.5f); 35 | RecommendedItem ri3 = new GenericRecommendedItem(3, 0.6f); 36 | rms.add(ri1); 37 | rms.add(ri2); 38 | rms.add(ri3); 39 | System.out.println(userRecommendedMoviesDao.addUserRecommendedMovies(1,rms)); 40 | 41 | } 42 | 43 | @Test 44 | public void getUserRecommendedMovies() throws Exception { 45 | List rms = userRecommendedMoviesDao.getUserRecommendedMovies(2); 46 | for(UserRecommendedMovies rm : rms) 47 | System.out.println(rm.getRmid() + " , " + rm.getRmv()); 48 | } 49 | 50 | @Test 51 | public void clearUserRecommendedMovies() throws Exception { 52 | 53 | System.out.println(userRecommendedMoviesDao.clearUserRecommendedMovies(2)); 54 | 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/service/EmailServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import com.kevin.mirs.utils.EncryptionUtils; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import javax.annotation.Resource; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | // 告诉Junit Sping配置文件 15 | @ContextConfiguration({"classpath:junit/spring-test.xml"}) 16 | public class EmailServiceTest { 17 | 18 | @Resource 19 | EmailService emailService; 20 | 21 | @Test 22 | public void sendVerificationEmail() throws Exception { 23 | 24 | String to = "1351650853@qq.com"; 25 | String verification = EncryptionUtils.getVerification(); 26 | 27 | System.out.println(emailService.sendVerificationEmail(to, verification)); 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/service/LuceneServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | // 告诉Junit Sping配置文件 14 | @ContextConfiguration({"classpath:junit/spring-test.xml"}) 15 | public class LuceneServiceTest { 16 | @Resource 17 | LuceneService luceneService; 18 | 19 | @Test 20 | public void indexMovie() throws Exception { 21 | long starTime=System.currentTimeMillis(); 22 | luceneService.indexMovie(); 23 | long endTime=System.currentTimeMillis(); 24 | System.out.println(endTime - starTime); 25 | } 26 | 27 | 28 | @Test 29 | public void deleteAllIndexes() throws Exception { 30 | luceneService.deleteAllIndexes(); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/service/RecommendServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import com.kevin.mirs.entity.UserRecommendedMovies; 4 | import org.apache.mahout.cf.taste.recommender.RecommendedItem; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.test.context.ContextConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | import javax.annotation.Resource; 11 | 12 | import java.util.List; 13 | 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(SpringJUnit4ClassRunner.class) 17 | // 告诉Junit Sping配置文件 18 | @ContextConfiguration({"classpath:junit/spring-test.xml"}) 19 | public class RecommendServiceTest { 20 | @Resource 21 | RecommendService recommendService; 22 | 23 | @Test 24 | public void getRealTimeRecommendedMovies() throws Exception { 25 | List recommendedItemList = recommendService.getRealTimeRecommendedMovies(2); 26 | for(RecommendedItem rmitem : recommendedItemList) 27 | System.out.println(rmitem); 28 | } 29 | 30 | @Test 31 | public void addRecommendedMovies() throws Exception { 32 | System.out.println(recommendService.addRecommendedMovies(2)); 33 | 34 | } 35 | 36 | @Test 37 | public void getRecommendedMoviesFromDB() throws Exception { 38 | List rms = recommendService.getRecommendedMoviesFromDB(2); 39 | for(UserRecommendedMovies rm : rms) 40 | System.out.println(rm.getRmid() + " , " + rm.getRmv()); 41 | } 42 | 43 | @Test 44 | public void getRecommendedFriends() throws Exception { 45 | long[] friends = recommendService.getRealTimeRecommendedFriends(2); 46 | for(long friend : friends) 47 | System.out.println(friend); 48 | } 49 | 50 | @Test 51 | public void addRecommendedFriends() throws Exception { 52 | System.out.println(recommendService.addRecommendedFriends(2)); 53 | } 54 | 55 | @Test 56 | public void getRecommendedFriendsFromDB() throws Exception { 57 | Integer[] friends = recommendService.getRecommendedFriendsFromDB(1); 58 | for(Integer friend : friends) 59 | System.out.println(friend); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/service/SearchServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @RunWith(SpringJUnit4ClassRunner.class) 11 | // 告诉Junit Sping配置文件 12 | @ContextConfiguration({"classpath:junit/spring-test.xml"}) 13 | public class SearchServiceTest { 14 | 15 | @Resource 16 | SearchService searchService; 17 | 18 | @Test 19 | public void searchMovie() throws Exception { 20 | // System.out.println(searchService.getSuggestionMovies("人妖")); 21 | System.out.println(searchService.getSuggestionMovies("1", 1)); 22 | } 23 | 24 | 25 | 26 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/utils/EncryptionUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | 8 | public class EncryptionUtilsTest { 9 | @Test 10 | public void SHA512Encode() throws Exception { 11 | 12 | System.out.println(EncryptionUtils.SHA512Encode("234", "23")); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/test/main/com/kevin/mirs/utils/FormatUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.mirs.utils; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | 8 | public class FormatUtilsTest { 9 | @Test 10 | public void emailFormat() throws Exception { 11 | 12 | System.out.println(FormatUtils.emailFormat("1@q5.com")); 13 | System.out.println(FormatUtils.emailFormat("1q.com")); 14 | System.out.println(FormatUtils.emailFormat("1@3.com")); 15 | System.out.println(FormatUtils.emailFormat("a@sd.m")); 16 | } 17 | 18 | } --------------------------------------------------------------------------------