├── .classpath ├── .project ├── .settings ├── .jsdtscope ├── org.eclipse.jdt.core.prefs ├── org.eclipse.m2e.core.prefs ├── org.eclipse.wst.common.component ├── org.eclipse.wst.common.project.facet.core.xml ├── org.eclipse.wst.jsdt.ui.superType.container ├── org.eclipse.wst.jsdt.ui.superType.name └── org.eclipse.wst.validation.prefs ├── README.md ├── pom.xml ├── src └── main │ ├── java │ └── cn │ │ └── com │ │ └── itjh │ │ └── mitjh │ │ ├── dao │ │ ├── ArticleDao.java │ │ ├── PeopleDao.java │ │ └── PeopleOperationArticleDao.java │ │ ├── domain │ │ ├── Article.java │ │ ├── ArticleCategory.java │ │ └── People.java │ │ ├── mapping │ │ ├── ArticlesMapper.xml │ │ ├── PeopleMapper.xml │ │ └── PeopleOperationArticleMapper.xml │ │ ├── server │ │ ├── ArticleServer.java │ │ ├── PeopleOperationArticleServer.java │ │ └── PeopleServer.java │ │ └── service │ │ ├── ArticleService.java │ │ ├── PeopleOperationArticleService.java │ │ ├── PeopleService.java │ │ └── impl │ │ ├── ArticleServiceImpl.java │ │ ├── PeopleOperationArticleServiceImpl.java │ │ └── PeopleServiceImpl.java │ ├── resources │ ├── applicationContext.xml │ ├── jdbc.properties │ ├── log4j.properties │ ├── memcached.properties │ ├── redis.properties │ └── spring-mybatis.xml │ └── webapp │ └── WEB-INF │ └── web.xml └── target ├── .gitignore └── m2e-wtp └── web-resources └── .gitignore /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mitjh 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | org.eclipse.wst.validation.validationbuilder 30 | 31 | 32 | 33 | 34 | 35 | org.eclipse.jem.workbench.JavaEMFNature 36 | org.eclipse.wst.common.modulecore.ModuleCoreNature 37 | org.eclipse.jdt.core.javanature 38 | org.eclipse.m2e.core.maven2Nature 39 | org.eclipse.wst.common.project.facet.core.nature 40 | org.eclipse.wst.jsdt.core.jsNature 41 | 42 | 43 | -------------------------------------------------------------------------------- /.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mitjh 2 | 3 | IT江湖接口服务 4 | 5 | // 获取文章列表 6 | http://api.itjh.net/v1/ArticleServer/queryArticleListByNew/0/11 7 | 8 | // 根据文章ID获取文章详情 9 | http://api.itjh.net/v1/ArticleServer/queryArticleById/33 10 | 11 | // 根据分类获取文章列表 12 | http://api.itjh.net/v1/ArticleServer/queryArticleListByCategory/3/0/11 13 | 14 | 15 | //第三方用户登录接口 16 | http://api.itjh.net/v1/PeopleServer/saveUser 17 | 18 | POST方式 19 | 传入参数 20 | nickname 用户名(昵称) 21 | face 用户第三方头像 22 | user_client_id 第三方平台用户id 23 | platform_id 第三方平台 0:微博 1:微信 24 | ``` json 25 | 返回参数: 26 | { 27 | "result": 1, 28 | "description": "用户信息注册成功", 29 | "people": { 30 | "user_client_id": "186256489", 31 | "nickname": "IT江湖网", 32 | "face": "http://55465.pnh", 33 | "platform_id": 0 34 | } 35 | } 36 | ``` 37 | 38 | #用户收藏文章 39 | http://api.itjh.net/v1/poas/userCollectionArticle 40 | 41 | POST方式 42 | 传入参数 43 | user_client_id 第三方平台用户id 44 | article_id 文章id 45 | 46 | ``` json 47 | 返回参数: 48 | --成功 49 | { 50 | "result": 1, 51 | "description": "收藏成功" 52 | } 53 | --收藏过 54 | { 55 | "result": 2, 56 | "description": "用户已经收藏" 57 | } 58 | ``` 59 | //获取用户收藏文章列表 60 | http://api.itjh.net/v1/poas/queryArticleListByUserCollection/186256489/0/11 61 | 62 | GET方式 63 | 64 | 186256489 // 用户id 65 | ```json 66 | { 67 | "result": 1, 68 | "description": "文章列表获取成功", 69 | "content": [ 70 | { 71 | "aid": 312, 72 | "date": "2015-01-23 15:33:08.0", 73 | "title": "重磅推荐丨移动互联网的本质", 74 | "img": "http://www.itjh.net/wp-content/uploads/2015/01/45548asdqwe22.png", 75 | "author_id": 1, 76 | "author": "IT江湖" 77 | }, 78 | { 79 | "aid": 368, 80 | "date": "2015-03-15 09:29:19.0", 81 | "title": "程序猿的经典语录(一)", 82 | "img": "http://www.itjh.net/wp-content/uploads/2014/12/1401074960812.jpg", 83 | "author_id": 1, 84 | "author": "IT江湖" 85 | }, 86 | { 87 | "aid": 369, 88 | "date": "2015-03-16 14:37:03.0", 89 | "title": "移动互联网结束后,我们会不会失业?", 90 | "img": "http://www.itjh.net/wp-content/uploads/2015/03/f21789406342c4b302ef43d8c4a83d18.jpg", 91 | "author_id": 1, 92 | "author": "IT江湖" 93 | } 94 | ] 95 | } 96 | ``` 97 | #修改根据文章id获取文章详情接口 98 | http://api.itjh.net/v1/ArticleServer/queryArticleById/403?userId=1862462231 99 | 100 | 101 | content 字段中新增isUserCollect 判断用户是否收藏过 102 | 103 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | cn.com.itjh 5 | mitjh 6 | war 7 | 0.0.1-SNAPSHOT 8 | mitjh Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | 1.7.2 13 | 14 | 4.1.1.RELEASE 15 | 16 | 17 | 18 | 19 | 20 | com.sun.jersey 21 | jersey-server 22 | 1.9 23 | 24 | 25 | com.sun.jersey 26 | jersey-client 27 | 1.9 28 | 29 | 30 | 31 | 32 | com.sun.jersey.contribs 33 | jersey-spring 34 | 1.9 35 | 36 | 37 | org.springframework 38 | spring 39 | 40 | 41 | org.springframework 42 | spring-core 43 | 44 | 45 | org.springframework 46 | spring-web 47 | 48 | 49 | org.springframework 50 | spring-beans 51 | 52 | 53 | org.springframework 54 | spring-context 55 | 56 | 57 | org.springframework 58 | spring-aop 59 | 60 | 61 | org.springframework 62 | spring-asm 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.springframework 71 | spring-core 72 | ${spring.version} 73 | 74 | 75 | 76 | org.springframework 77 | spring-context 78 | ${spring.version} 79 | 80 | 81 | 82 | org.springframework 83 | spring-context-support 84 | ${spring.version} 85 | 86 | 87 | 88 | org.springframework 89 | spring-web 90 | ${spring.version} 91 | 92 | 93 | 94 | org.springframework 95 | spring-oxm 96 | ${spring.version} 97 | 98 | 99 | 100 | org.springframework 101 | spring-tx 102 | ${spring.version} 103 | 104 | 105 | 106 | org.springframework 107 | spring-jdbc 108 | ${spring.version} 109 | 110 | 111 | 112 | org.springframework 113 | spring-webmvc 114 | ${spring.version} 115 | 116 | 117 | 118 | org.springframework 119 | spring-aspects 120 | ${spring.version} 121 | 122 | 123 | 124 | org.springframework 125 | spring-aop 126 | ${spring.version} 127 | 128 | 129 | 130 | org.springframework 131 | spring-test 132 | ${spring.version} 133 | 134 | 135 | 136 | 137 | 138 | org.slf4j 139 | slf4j-api 140 | ${org.slf4j-version} 141 | 142 | 143 | org.slf4j 144 | jcl-over-slf4j 145 | ${org.slf4j-version} 146 | runtime 147 | 148 | 149 | org.slf4j 150 | slf4j-log4j12 151 | ${org.slf4j-version} 152 | 153 | 154 | log4j 155 | log4j 156 | 1.2.15 157 | 158 | 159 | javax.mail 160 | mail 161 | 162 | 163 | javax.jms 164 | jms 165 | 166 | 167 | com.sun.jdmk 168 | jmxtools 169 | 170 | 171 | com.sun.jmx 172 | jmxri 173 | 174 | 175 | 176 | 177 | 178 | 179 | org.mybatis 180 | mybatis 181 | 3.2.1 182 | 183 | 184 | 185 | org.mybatis 186 | mybatis-spring 187 | 1.2.0 188 | 189 | 190 | 191 | mysql 192 | mysql-connector-java 193 | 5.1.26 194 | 195 | 196 | 197 | com.alibaba 198 | druid 199 | 0.2.20 200 | 201 | 202 | 203 | com.googlecode.xmemcached 204 | xmemcached 205 | 2.0.0 206 | 207 | 208 | 209 | com.google.code.gson 210 | gson 211 | 2.2.4 212 | 213 | 214 | 215 | javax.servlet 216 | servlet-api 217 | provided 218 | 3.0-alpha-1 219 | 220 | 221 | 222 | junit 223 | junit 224 | 4.11 225 | test 226 | 227 | 228 | 229 | org.apache.commons 230 | commons-pool2 231 | 2.3 232 | 233 | 234 | 235 | redis.clients 236 | jedis 237 | 2.6.2 238 | jar 239 | compile 240 | 241 | 242 | 243 | org.springframework.integration 244 | spring-integration-redis 245 | ${spring.version} 246 | jar 247 | compile 248 | 249 | 250 | 251 | org.springframework.data 252 | spring-data-redis 253 | 1.5.0.RELEASE 254 | 255 | 256 | 257 | mitjh 258 | 259 | 260 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/dao/ArticleDao.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import cn.com.itjh.mitjh.domain.Article; 7 | import cn.com.itjh.mitjh.domain.ArticleCategory; 8 | 9 | /** 10 | * 11 | * 处理文章的dao.
12 | * 处理文章的dao 13 | * 14 | * @Copyright itjh 15 | * @Project 16 | * @author 宋立君 17 | * @date 2014年10月30日 下午3:40:22 18 | * @Version 19 | * @JDK version used 8.0 20 | * @Modification history none 21 | * @Modified by none 22 | */ 23 | public interface ArticleDao { 24 | 25 | /** 26 | * 27 | * 获取文章列表.
28 | * 根据分类ID获取文章列表 29 | * 30 | * @Copyright itjh 31 | * @Project 32 | * @param params 33 | * @return 34 | * @return List
35 | * @throws 36 | * @author 宋立君 37 | * @date 2014年10月30日 下午3:43:22 38 | * @Version 39 | * @JDK version used 8.0 40 | * @Modification history none 41 | * @Modified by none 42 | */ 43 | List
queryArticleListByCat(Map params); 44 | 45 | /** 46 | * 47 | * 获取文章列表.
48 | * 获取各分类最新的文章列表 49 | * 50 | * @Copyright itjh 51 | * @Project 52 | * @param params 53 | * @return 54 | * @return List
55 | * @throws 56 | * @author 宋立君 57 | * @date 2014年10月30日 下午3:43:22 58 | * @Version 59 | * @JDK version used 8.0 60 | * @Modification history none 61 | * @Modified by none 62 | */ 63 | List
queryArticleListByNew(Map params); 64 | 65 | /** 66 | * 67 | * 获取文章详情.
68 | * 根据文章ID获取文章详情 69 | * 70 | * @Copyright vcinema 71 | * @Project 72 | * @param aid 73 | * @return 74 | * @return Article 75 | * @throws 76 | * @author 宋立君 77 | * @date 2014年11月3日 上午11:54:47 78 | * @Version 79 | * @JDK version used 8.0 80 | * @Modification history none 81 | * @Modified by none 82 | */ 83 | Article queryArticleById(Map params); 84 | 85 | /** 86 | * 87 | * 根据分类获取文章列表.
88 | * 根据不同的分类ID获取文章列表 89 | * 90 | * @Copyright vcinema 91 | * @Project 92 | * @param params 93 | * @return 94 | * @return List
95 | * @throws 96 | * @author 宋立君 97 | * @date 2014年12月2日 下午6:49:48 98 | * @Version 99 | * @JDK version used 8.0 100 | * @Modification history none 101 | * @Modified by none 102 | */ 103 | List
queryArticleListByCategory(Map params); 104 | 105 | /** 106 | * 107 | * 获取分类.
108 | * 获取文章所有分类 109 | * 110 | * @Copyright itjh 111 | * @Project 112 | * @return 113 | * @return ArticleCategory 114 | * @throws 115 | * @author 宋立君 116 | * @date 2014年12月2日 下午7:10:26 117 | * @Version 118 | * @JDK version used 8.0 119 | * @Modification history none 120 | * @Modified by none 121 | */ 122 | List queryArticleCategory(); 123 | 124 | /** 125 | * 126 | * 查询文章总数.
127 | * 查询文章总数 128 | * 129 | * @Copyright vcinema 130 | * @Project 131 | * @return 132 | * @return Long 133 | * @throws 134 | * @author 宋立君 135 | * @date 2015年3月31日 下午5:29:59 136 | * @Version 137 | * @JDK version used 8.0 138 | * @Modification history none 139 | * @Modified by none 140 | */ 141 | Long selectCountByNew(); 142 | 143 | /** 144 | * 145 | * 根据分类查询文章总数.
146 | * 根据分类查询文章总数 147 | * 148 | * @Copyright vcinema 149 | * @Project 150 | * @return 151 | * @return Long 152 | * @throws 153 | * @author 宋立君 154 | * @date 2015年3月31日 下午5:29:59 155 | * @Version 156 | * @JDK version used 8.0 157 | * @Modification history none 158 | * @Modified by none 159 | */ 160 | Long selectCountByByCategory(Map params); 161 | 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/dao/PeopleDao.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.dao; 2 | 3 | import java.util.Map; 4 | 5 | import cn.com.itjh.mitjh.domain.People; 6 | 7 | /** 8 | * 9 | * 使用人操作. 10 | *
使用人操 11 | * @Copyright itjh 12 | * @Project 13 | * @author 宋立君 14 | * @date 2014年12月17日 下午3:12:10 15 | * @Version 16 | * @JDK version used 8.0 17 | * @Modification history none 18 | * @Modified by none 19 | */ 20 | public interface PeopleDao { 21 | 22 | /** 23 | * 24 | * 保存人. 25 | *
保存人 26 | * @Copyright itjh 27 | * @Project 28 | * @param people 29 | * @return 30 | * @return int 31 | * @throws 32 | * @author 宋立君 33 | * @date 2014年12月17日 下午3:12:44 34 | * @Version 35 | * @JDK version used 8.0 36 | * @Modification history none 37 | * @Modified by none 38 | */ 39 | int save(People people); 40 | 41 | /** 42 | * 43 | * 判断用户是否注册. 44 | *
//通过user_client_id判断用户是否注册过 45 | * @Copyright itjh 46 | * @Project 47 | * @param user_client_id 48 | * @param platform_id 49 | * @return 50 | * @return People 51 | * @throws 52 | * @author 宋立君 53 | * @date 2015年3月17日 下午2:12:08 54 | * @Version 55 | * @JDK version used 8.0 56 | * @Modification history none 57 | * @Modified by none 58 | */ 59 | People selectUserByUserClientId(Map peopleumap); 60 | 61 | /** 62 | * 63 | * 修改用户信息. 64 | *
修改用户信息 65 | * @Copyright vcinema 66 | * @Project 67 | * @param peopleumap 68 | * @return 69 | * @return int 70 | * @throws 71 | * @author 宋立君 72 | * @date 2015年3月17日 下午2:30:33 73 | * @Version 74 | * @JDK version used 8.0 75 | * @Modification history none 76 | * @Modified by none 77 | */ 78 | int updateUser(Map peopleumap); 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/dao/PeopleOperationArticleDao.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import cn.com.itjh.mitjh.domain.Article; 7 | 8 | /** 9 | * 10 | * 用户操作文章的行为. 11 | *
用户操作文章 12 | * @Copyright itjh 13 | * @Project 14 | * @author 宋立君 15 | * @date 2015年3月17日 下午5:04:22 16 | * @Version 17 | * @JDK version used 8.0 18 | * @Modification history none 19 | * @Modified by none 20 | */ 21 | public interface PeopleOperationArticleDao { 22 | 23 | /** 24 | * 25 | * 检测用户是否收藏过. 26 | *
检测用户是否收藏过 27 | * @Copyright vcinema 28 | * @Project 29 | * @param params 30 | * @return 31 | * @return int 32 | * @throws 33 | * @author 宋立君 34 | * @date 2015年3月17日 下午5:05:00 35 | * @Version 36 | * @JDK version used 8.0 37 | * @Modification history none 38 | * @Modified by none 39 | */ 40 | int checkUserCollection(Map params); 41 | 42 | /** 43 | * 44 | * 保存用户收藏文章. 45 | *
保存用户收藏文章 46 | * @Copyright itjh 47 | * @Project 48 | * @param params 49 | * @return 50 | * @return int 51 | * @throws 52 | * @author 宋立君 53 | * @date 2015年3月17日 下午5:20:42 54 | * @Version 55 | * @JDK version used 8.0 56 | * @Modification history none 57 | * @Modified by none 58 | */ 59 | int saveUserCollection(Map params); 60 | /** 61 | * 62 | * 获取用户收藏文章列表. 63 | *
根据用户id获取收藏列表 64 | * @Copyright itjh 65 | * @Project 66 | * @param user_client_id 67 | * @param pageNum 68 | * @param showNum 69 | * @param servletResponse 70 | * @return 71 | * @return String 72 | * @throws 73 | * @author 宋立君 74 | * @date 2015年3月17日 下午5:56:46 75 | * @Version 76 | * @JDK version used 8.0 77 | * @Modification history none 78 | * @Modified by none 79 | */ 80 | List
queryArticleListByUserCollection(Map params); 81 | /** 82 | * 83 | * 用户取消收藏文章. 84 | *
用户取消收藏文章 85 | * @Copyright vcinema 86 | * @Project 87 | * @param params 88 | * @return 89 | * @return int 90 | * @throws 91 | * @author 宋立君 92 | * @date 2015年4月2日 下午3:41:22 93 | * @Version 94 | * @JDK version used 8.0 95 | * @Modification history none 96 | * @Modified by none 97 | */ 98 | int deleteUserCollection(Map params); 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/domain/Article.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 7 | * 文章实体类.
8 | * 文章实体类 9 | * @Copyright itjh 10 | * @Project 11 | * @author 宋立君 12 | * @date 2014年10月30日 下午3:37:28 13 | * @Version 14 | * @JDK version used 8.0 15 | * @Modification history none 16 | * @Modified by none 17 | */ 18 | public class Article implements Serializable { 19 | 20 | /** 21 | 22 | * 23 | 24 | */ 25 | 26 | private static final long serialVersionUID = -786696046736928251L; 27 | private Integer aid; //文章ID 28 | private String date; //文章发布时间 29 | private String title;//文章标题 30 | private String summary;//文章摘要 31 | private String content;//文章摘要 32 | private String img; //文章缩略图 33 | private Integer author_id; //作者ID 34 | private String author; //作者名称 35 | 36 | private Integer isUserCollect; // 用户是否收藏此文章 37 | 38 | public Integer getAid() { 39 | return aid; 40 | } 41 | 42 | public void setAid(Integer aid) { 43 | this.aid = aid; 44 | } 45 | 46 | public String getDate() { 47 | return date; 48 | } 49 | 50 | public void setDate(String date) { 51 | this.date = date; 52 | } 53 | 54 | public String getTitle() { 55 | return title; 56 | } 57 | 58 | public void setTitle(String title) { 59 | this.title = title; 60 | } 61 | 62 | public String getImg() { 63 | return img; 64 | } 65 | 66 | public void setImg(String img) { 67 | this.img = img; 68 | } 69 | 70 | public Integer getAuthor_id() { 71 | return author_id; 72 | } 73 | 74 | public void setAuthor_id(Integer author_id) { 75 | this.author_id = author_id; 76 | } 77 | 78 | public String getAuthor() { 79 | return author; 80 | } 81 | 82 | public void setAuthor(String author) { 83 | this.author = author; 84 | } 85 | 86 | 87 | 88 | public String getSummary() { 89 | return summary; 90 | } 91 | 92 | public void setSummary(String summary) { 93 | this.summary = summary; 94 | } 95 | 96 | public Article() { 97 | super(); 98 | // TODO Auto-generated constructor stub 99 | } 100 | 101 | 102 | 103 | public String getContent() { 104 | return content; 105 | } 106 | 107 | public void setContent(String content) { 108 | this.content = content; 109 | } 110 | 111 | 112 | 113 | public Integer getIsUserCollect() { 114 | return isUserCollect; 115 | } 116 | 117 | public void setIsUserCollect(Integer isUserCollect) { 118 | this.isUserCollect = isUserCollect; 119 | } 120 | 121 | public Article(Integer aid, String date, String title, String summary, String content, String img, 122 | Integer author_id, String author, Integer isUserCollect) { 123 | super(); 124 | this.aid = aid; 125 | this.date = date; 126 | this.title = title; 127 | this.summary = summary; 128 | this.content = content; 129 | this.img = img; 130 | this.author_id = author_id; 131 | this.author = author; 132 | this.isUserCollect = isUserCollect; 133 | } 134 | 135 | @Override 136 | public String toString() { 137 | return "Article [aid=" + aid + ", date=" + date + ", title=" + title + ", summary=" + summary + ", content=" 138 | + content + ", img=" + img + ", author_id=" + author_id + ", author=" + author + ", isUserCollect=" 139 | + isUserCollect + "]"; 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/domain/ArticleCategory.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.domain; 2 | 3 | /** 4 | * 5 | * 文章分类.
6 | * 文章分类 7 | * 8 | * @Copyright itjh 9 | * @Project 10 | * @author 宋立君 11 | * @date 2014年12月2日 下午7:08:25 12 | * @Version 13 | * @JDK version used 8.0 14 | * @Modification history none 15 | * @Modified by none 16 | */ 17 | public class ArticleCategory { 18 | 19 | private String id; 20 | private String name; 21 | private String slug; 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getSlug() { 40 | return slug; 41 | } 42 | 43 | public void setSlug(String slug) { 44 | this.slug = slug; 45 | } 46 | 47 | public ArticleCategory(String id, String name, String slug) { 48 | super(); 49 | this.id = id; 50 | this.name = name; 51 | this.slug = slug; 52 | } 53 | 54 | public ArticleCategory() { 55 | super(); 56 | // TODO Auto-generated constructor stub 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/domain/People.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.domain; 2 | 3 | /** 4 | * 5 | * 人.
6 | * 人 7 | * 8 | * @Copyright itjh 9 | * @Project 10 | * @author 宋立君 11 | * @date 2014年12月17日 下午3:08:01 12 | * @Version 13 | * @JDK version used 8.0 14 | * @Modification history none 15 | * @Modified by none 16 | */ 17 | public class People { 18 | private Integer id; 19 | private String user_client_id; 20 | private String nickname; 21 | private String face; 22 | private Integer platform_id; 23 | 24 | public Integer getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Integer id) { 29 | this.id = id; 30 | } 31 | 32 | public String getUser_client_id() { 33 | return user_client_id; 34 | } 35 | 36 | public void setUser_client_id(String user_client_id) { 37 | this.user_client_id = user_client_id; 38 | } 39 | 40 | public String getNickname() { 41 | return nickname; 42 | } 43 | 44 | public void setNickname(String nickname) { 45 | this.nickname = nickname; 46 | } 47 | 48 | public String getFace() { 49 | return face; 50 | } 51 | 52 | public void setFace(String face) { 53 | this.face = face; 54 | } 55 | 56 | public Integer getPlatform_id() { 57 | return platform_id; 58 | } 59 | 60 | public void setPlatform_id(Integer platform_id) { 61 | this.platform_id = platform_id; 62 | } 63 | 64 | public People(Integer id, String user_client_id, String nickname, String face, Integer platform_id) { 65 | super(); 66 | this.id = id; 67 | this.user_client_id = user_client_id; 68 | this.nickname = nickname; 69 | this.face = face; 70 | this.platform_id = platform_id; 71 | } 72 | public People(String user_client_id, String nickname, String face, Integer platform_id) { 73 | super(); 74 | this.user_client_id = user_client_id; 75 | this.nickname = nickname; 76 | this.face = face; 77 | this.platform_id = platform_id; 78 | } 79 | 80 | public People() { 81 | super(); 82 | // TODO Auto-generated constructor stub 83 | } 84 | @Override 85 | public String toString() { 86 | return "People [id=" + id + ", user_client_id=" + user_client_id + ", nickname=" + nickname + ", face=" + face 87 | + ", platform_id=" + platform_id + "]"; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/mapping/ArticlesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 31 | 81 | 106 | 110 | 111 | 112 | 113 | 123 | 124 | 125 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/mapping/PeopleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | INSERT INTO 9 | `third_users` (`user_client_id`, `nickname`, `face`, 10 | `platform_id`) VALUES (#{user_client_id}, #{nickname}, #{face}, 11 | #{platform_id}); 12 | 13 | 14 | 15 | 22 | 23 | 24 | 25 | UPDATE third_users SET ${resql}; 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/mapping/PeopleOperationArticleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | INSERT INTO 14 | `user_collection` (`user_id`, `article_id`, `time`) VALUES 15 | (#{user_client_id}, #{article_id}, #{time}); 16 | 17 | 18 | 19 | 20 | update 21 | user_collection set state = 0 ,`time` = #{time} where article_id = 22 | #{article_id} and user_id= #{user_client_id} 23 | 24 | 25 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/server/ArticleServer.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.server; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | import javax.annotation.Resource; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import javax.ws.rs.GET; 16 | import javax.ws.rs.POST; 17 | import javax.ws.rs.Path; 18 | import javax.ws.rs.PathParam; 19 | import javax.ws.rs.Produces; 20 | import javax.ws.rs.core.Context; 21 | import javax.ws.rs.core.MediaType; 22 | 23 | import net.rubyeye.xmemcached.MemcachedClient; 24 | 25 | import org.apache.commons.codec.binary.Base64; 26 | import org.apache.log4j.Logger; 27 | import org.springframework.data.redis.core.RedisTemplate; 28 | import org.springframework.stereotype.Repository; 29 | 30 | import cn.com.itjh.mitjh.domain.Article; 31 | import cn.com.itjh.mitjh.domain.ArticleCategory; 32 | import cn.com.itjh.mitjh.service.ArticleService; 33 | import cn.com.itjh.util.HttpUtil; 34 | 35 | import com.google.gson.Gson; 36 | 37 | /** 38 | * 39 | * 文章server.
40 | * 文章server 41 | * 42 | * @Copyright vcinema 43 | * @Project 44 | * @author 宋立君 45 | * @date 2014年10月30日 下午4:08:39 46 | * @Version 47 | * @JDK version used 8.0 48 | * @Modification history none 49 | * @Modified by none 50 | */ 51 | @Repository 52 | @Path("ArticleServer") 53 | public class ArticleServer { 54 | 55 | @Resource 56 | private ArticleService articleService; 57 | 58 | private static final Logger logger = Logger.getLogger(ArticleServer.class.getName()); 59 | 60 | @Resource 61 | private MemcachedClient memcachedClient; 62 | @Resource 63 | private RedisTemplate redisTemplate; 64 | 65 | Gson gson = new Gson(); 66 | 67 | /** 68 | * 69 | * 获取最新发布的文章.
70 | * 获取最新发布的文章 71 | * 72 | * @Copyright vcinema 73 | * @Project 74 | * @param pageNum 75 | * @param showNum 76 | * @param servletResponse 77 | * @return 78 | * @return String 79 | * @throws 80 | * @author 宋立君 81 | * @date 2014年11月3日 上午11:42:13 82 | * @Version 83 | * @JDK version used 8.0 84 | * @Modification history none 85 | * @Modified by none 86 | */ 87 | @GET 88 | @Produces(MediaType.APPLICATION_JSON) 89 | @Path("queryArticleListByNew/{pageNum}/{showNum}") 90 | public String queryArticleListByNew(@PathParam(value = "pageNum") int pageNum, 91 | @PathParam(value = "showNum") int showNum, @Context HttpServletRequest servletRequest, 92 | @Context HttpServletResponse servletResponse) { 93 | servletResponse.setContentType("application/json;charset=UTF-8"); 94 | // 返回参数的map 95 | Map result = new HashMap(); 96 | String resultJson = ""; 97 | try { 98 | Map params = new HashMap(); 99 | // pageNum = pageNum * showNum; 100 | 101 | int start = showNum * (pageNum);// 因为redis中list元素位置基数是0 102 | if (start > 0) { 103 | start += pageNum; 104 | } 105 | int end = start + showNum; 106 | 107 | System.out.println("start: " + start + " end: " + end); 108 | 109 | // params.put("pageNum", pageNum); 110 | // params.put("showNum", showNum); 111 | logger.info("查询条件:" + params); 112 | 113 | // redisTemplate.delete("artices_new"); 114 | List
articles = new ArrayList
(); 115 | 116 | // 查询文章总数 117 | Long acount = articleService.selectCountByNew(); 118 | 119 | Long anewl = redisTemplate.opsForList().size("artices_new"); 120 | 121 | if (acount > anewl) {// 数据库文章总数比缓存多 122 | Long ad = (acount - anewl); 123 | params.put("limit", "limit " + ad); 124 | // 查询新增的数据,存放到缓存中 125 | articles = articleService.queryArticleListByNew(params); 126 | if (anewl == 0) { 127 | anewl = redisTemplate.opsForList().rightPushAll("artices_new", articles); 128 | } else { 129 | anewl = redisTemplate.opsForList().leftPushAll("artices_new", articles); 130 | } 131 | } 132 | 133 | if (anewl > 0) {// redis中有数据 134 | articles = redisTemplate.opsForList().range("artices_new", start, end); 135 | } else { 136 | articles = articleService.queryArticleListByNew(params); 137 | anewl = redisTemplate.opsForList().rightPushAll("artices_new", articles); 138 | } 139 | 140 | if (null != articles) { 141 | System.out.println("文章列表长度:" + anewl); 142 | // logger.info("获取最新文章成功"); 143 | result.put("result", 1); 144 | result.put("content", articles); 145 | result.put("description", "文章列表获取成功");// 描述信息 146 | 147 | // 148 | 149 | } else { 150 | result.put("result", -1); 151 | result.put("content", articles); 152 | result.put("description", "文章列表获取失败");// 描述信息 153 | } 154 | } catch (Exception e) { 155 | logger.info("系统异常\n"); 156 | logger.info(e.getMessage()); 157 | result.put("result", 0); 158 | result.put("description", "系统异常");// 描述信息 159 | e.printStackTrace(); 160 | } 161 | resultJson = gson.toJson(result); 162 | return resultJson; 163 | } 164 | 165 | @POST 166 | @Produces(MediaType.APPLICATION_JSON) 167 | @Path("redisTest") 168 | public String redisTest(@Context HttpServletRequest servletRequest, @Context HttpServletResponse servletResponse) 169 | throws IOException { 170 | Map result = new HashMap(); 171 | String resultJson = ""; 172 | 173 | System.out.println(servletRequest); 174 | System.out.println("==========================="); 175 | System.out.println(servletResponse); 176 | System.out.println(servletRequest.getPathTranslated()); 177 | System.out.println(servletRequest.getContentLength()); 178 | System.out.println(servletRequest.getContentType()); 179 | 180 | 181 | System.out.println(HttpUtil.getBody(servletRequest)); 182 | // 183 | // // int pageNo = 6; 184 | // // int pageSize = 6; 185 | // // redisTemplate.delete("artices_new"); 186 | // // redisTemplate.delete("artices_2"); 187 | // // redisTemplate.delete("artices_3"); 188 | // // redisTemplate.delete("artices_4"); 189 | // // 返回参数的map 190 | // Map result = new HashMap(); 191 | // String resultJson = ""; 192 | // //获取到的内容是结果base64编码后的字符串,所以这样的认证方式安全性不高 193 | // try { 194 | // String authValue = servletRequest.getHeader("Authorization"), username = null, 195 | // pwd = null; //获取到的请求头格式类似于 Basic MTIzOjEyMw== 196 | // 197 | // if(authValue != null){ 198 | // byte [] values = decode(authValue); 199 | // String valuestr = new String(values); 200 | // String [] aa = valuestr.split(":"); 201 | // 202 | // if(aa.length == 2){ 203 | // username = aa[0]; 204 | // pwd = aa[1]; 205 | // } 206 | // } 207 | // 208 | // //用户名和密码都不为空时验证成功 209 | // if(username != null && username.length() >0 210 | // && username.equals(pwd)){ 211 | // // servletResponse.setContentType("text/html; charset=UTF-8"); 212 | // // servletResponse.getWriter().print("你已经通过验证!"); 213 | // result.put("res", "已经通过验证"); 214 | // 215 | // }else{ //未通过验证 216 | // servletResponse.setStatus(401); //设置好相应的状态 217 | // // servletResponse.setHeader("WWW-Authenticate", "Basic realm=\"My Application\""); 218 | // // 219 | // // //设置用户取消验证后的消息提示 220 | // // servletResponse.setContentType("text/html; charset=UTF-8"); 221 | // // servletResponse.getWriter().print("HTTP STATUS -- 401!"); 222 | // result.put("res", "没有通过验证"); 223 | // 224 | // } 225 | // resultJson = gson.toJson(result); 226 | // System.out.println(resultJson); 227 | // 228 | // } catch (Exception e) { 229 | // // TODO Auto-generated catch block 230 | // e.printStackTrace(); 231 | // } 232 | // 233 | return resultJson; 234 | } 235 | 236 | /** 237 | * @param bytes 238 | * @return 239 | */ 240 | public static byte[] decode(String base64String) { 241 | return Base64.decodeBase64(base64String); 242 | } 243 | 244 | /** 245 | * 二进制数据编码为BASE64字符串 246 | * 247 | * @param bytes 248 | * @return 249 | * @throws Exception 250 | */ 251 | public static String encode(final byte[] bytes) { 252 | return new String(Base64.encodeBase64(bytes)); 253 | } 254 | 255 | @GET 256 | @Produces(MediaType.APPLICATION_JSON) 257 | @Path("queryArticleListByCategory/{categoryId}/{pageNum}/{showNum}") 258 | public String queryArticleListByCategory(@PathParam(value = "categoryId") int categoryId, 259 | @PathParam(value = "pageNum") int pageNum, @PathParam(value = "showNum") int showNum, 260 | @Context HttpServletRequest servletRequest, @Context HttpServletResponse servletResponse) { 261 | servletResponse.setContentType("application/json;charset=UTF-8"); 262 | // 返回参数的map 263 | Map result = new HashMap(); 264 | String resultJson = ""; 265 | try { 266 | Map params = new HashMap(); 267 | int start = showNum * (pageNum);// 因为redis中list元素位置基数是0 268 | if (start > 0) { 269 | start += pageNum; 270 | } 271 | int end = start + showNum; 272 | System.out.println("start: " + start + " end: " + end); 273 | params.put("categoryId", categoryId); 274 | logger.info("查询条件:" + params); 275 | List
articles = new ArrayList
(); 276 | // 查询分类下文章总数 277 | Long acount = articleService.selectCountByByCategory(params); 278 | Long anewl = redisTemplate.opsForList().size("artices_" + categoryId); 279 | if (acount > anewl) {// 数据库文章总数比缓存多 280 | Long ad = (acount - anewl); 281 | params.put("limit", "limit " + ad); 282 | // 查询新增的数据,存放到缓存中 283 | articles = articleService.queryArticleListByCategory(params); 284 | if (anewl == 0) { 285 | anewl = redisTemplate.opsForList().rightPushAll("artices_" + categoryId, articles); 286 | } else { 287 | anewl = redisTemplate.opsForList().leftPushAll("artices_" + categoryId, articles); 288 | } 289 | } 290 | if (anewl > 0) {// redis中有数据 291 | articles = redisTemplate.opsForList().range("artices_" + categoryId, start, end); 292 | logger.info("缓存中的分类:" + categoryId + " 总数:" + articles); 293 | } else { 294 | articles = articleService.queryArticleListByCategory(params); 295 | anewl = redisTemplate.opsForList().rightPushAll("artices_" + categoryId, articles); 296 | } 297 | 298 | if (null != articles) { 299 | logger.info("获取分类:" + categoryId + "文章成功"); 300 | result.put("result", 1); 301 | result.put("content", articles); 302 | result.put("description", "获取分类:" + categoryId + "文章成功");// 描述信息 303 | } else { 304 | result.put("result", -1); 305 | result.put("content", articles); 306 | result.put("description", "文章列表获取失败");// 描述信息 307 | } 308 | } catch (Exception e) { 309 | logger.info("系统异常\n"); 310 | logger.info(e.getMessage()); 311 | result.put("result", 0); 312 | result.put("description", "系统异常");// 描述信息 313 | e.printStackTrace(); 314 | } 315 | resultJson = gson.toJson(result); 316 | return resultJson; 317 | } 318 | 319 | /** 320 | * 321 | * 获取单个文章.
322 | * 根据文章id获取文章详情 323 | * 324 | * @Copyright vcinema 325 | * @Project 326 | * @param aid 327 | * 文章id 328 | * @param servletResponse 329 | * @return 330 | * @return String 331 | * @throws 332 | * @author 宋立君 333 | * @date 2014年11月3日 上午11:42:31 334 | * @Version 335 | * @JDK version used 8.0 336 | * @Modification history none 337 | * @Modified by none 338 | */ 339 | @GET 340 | @Produces(MediaType.APPLICATION_JSON) 341 | @Path("queryArticleById/{aid}") 342 | public String queryArticleById(@PathParam(value = "aid") int aid, @Context HttpServletRequest servletRequest, 343 | @Context HttpServletResponse servletResponse) { 344 | servletResponse.setContentType("application/json;charset=UTF-8"); 345 | // 返回参数的map 346 | Map result = new HashMap(); 347 | String resultJson = ""; 348 | try { 349 | String userId = servletRequest.getParameter("userId"); 350 | Map params = new HashMap(); 351 | params.put("id", aid); 352 | params.put("userId", null != userId ? userId : "0"); 353 | Article article = articleService.queryArticleById(params); 354 | if (null != article) { 355 | logger.info("获取文章成功"); 356 | result.put("aid", aid); 357 | result.put("result", 1); 358 | result.put("content", article); 359 | result.put("description", "文章获取成功");// 描述信息 360 | } else { 361 | result.put("aid", aid); 362 | result.put("result", -1); 363 | result.put("content", article); 364 | result.put("description", "没有此文章信息");// 描述信息 365 | } 366 | } catch (Exception e) { 367 | result.put("result", -1); 368 | result.put("description", "系统异常");// 描述信息 369 | e.printStackTrace(); 370 | } 371 | resultJson = gson.toJson(result); 372 | return resultJson; 373 | } 374 | 375 | @GET 376 | @Produces(MediaType.APPLICATION_JSON) 377 | @Path("queryArticleCategory") 378 | public String queryArticleCategory(@Context HttpServletResponse servletResponse) { 379 | servletResponse.setContentType("application/json;charset=UTF-8"); 380 | // 返回参数的map 381 | Map result = new HashMap(); 382 | String resultJson = ""; 383 | try { 384 | List articleCategorys = articleService.queryArticleCategory(); 385 | if (null != articleCategorys) { 386 | logger.info("获取全部分类成功"); 387 | result.put("result", 1); 388 | result.put("content", articleCategorys); 389 | result.put("description", "获取全部分类");// 描述信息 390 | } else { 391 | result.put("result", -1); 392 | result.put("content", articleCategorys); 393 | result.put("description", "文章列表获取失败");// 描述信息 394 | } 395 | } catch (Exception e) { 396 | result.put("result", -1); 397 | result.put("description", "系统异常");// 描述信息 398 | e.printStackTrace(); 399 | } 400 | resultJson = gson.toJson(result); 401 | return resultJson; 402 | } 403 | 404 | } 405 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/server/PeopleOperationArticleServer.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.server; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.annotation.Resource; 8 | import javax.servlet.http.HttpServletResponse; 9 | import javax.ws.rs.DELETE; 10 | import javax.ws.rs.FormParam; 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.POST; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.core.Context; 17 | import javax.ws.rs.core.MediaType; 18 | 19 | import net.rubyeye.xmemcached.MemcachedClient; 20 | 21 | import org.apache.log4j.Logger; 22 | import org.glassfish.jersey.client.oauth2.OAuth2ClientSupport; 23 | import org.glassfish.jersey.client.oauth2.OAuth2CodeGrantFlow; 24 | import org.springframework.stereotype.Repository; 25 | 26 | import cn.com.itjh.mitjh.domain.Article; 27 | import cn.com.itjh.mitjh.service.ArticleService; 28 | import cn.com.itjh.mitjh.service.PeopleOperationArticleService; 29 | 30 | import com.google.gson.Gson; 31 | 32 | /** 33 | * 34 | * 用户操作文章Server.
35 | * 用户收藏,喜欢,顶等操作 36 | * 37 | * @Copyright itjh 38 | * @Project 39 | * @author 宋立君 40 | * @date 2015年3月17日 下午4:32:23 41 | * @Version 42 | * @JDK version used 8.0 43 | * @Modification history none 44 | * @Modified by none 45 | */ 46 | @Repository 47 | @Path("poas") 48 | public class PeopleOperationArticleServer { 49 | 50 | private static final Logger logger = Logger.getLogger(PeopleOperationArticleServer.class.getName()); 51 | 52 | @Resource 53 | private MemcachedClient memcachedClient; 54 | 55 | @Resource 56 | private ArticleService articleService; 57 | 58 | @Resource 59 | private PeopleOperationArticleService peopleOperationArticleService; 60 | 61 | Gson gson = new Gson(); 62 | 63 | /** 64 | * 65 | * 用户收藏文章.
66 | * 用户收藏文章 67 | * @Copyright itjh 68 | * @Project 69 | * @param user_client_id 70 | * 用户客户端id 71 | * @param article_id 72 | * 文章id 73 | * @return 74 | * @return String 75 | * @throws 76 | * @author 宋立君 77 | * @date 2015年3月17日 下午4:43:37 78 | * @Version 79 | * @JDK version used 8.0 80 | * @Modification history none 81 | * @Modified by none 82 | */ 83 | @Path("/userCollectionArticle") 84 | @POST 85 | public String userCollectionArticle(@FormParam(value = "user_client_id") String user_client_id, 86 | @FormParam(value = "article_id") String article_id, @Context HttpServletResponse servletResponse) { 87 | servletResponse.setContentType("application/json;charset=UTF-8"); 88 | logger.info("用户:" + user_client_id + "收藏文章:" + article_id); 89 | // 返回参数的map 90 | Map result = new HashMap(); 91 | String resultJson = ""; 92 | 93 | // 查询参数 94 | Map params = new HashMap(); 95 | // 保存收藏信息 96 | if (!"".equals(user_client_id) && null != user_client_id && !"".equals(article_id) && null != article_id) { 97 | 98 | // 判断用户是否收藏过,保存 99 | params.put("user_client_id", user_client_id); 100 | params.put("article_id", article_id); 101 | 102 | int cuc = peopleOperationArticleService.checkUserCollectionOrSaveUserCollection(params); 103 | switch (cuc) { 104 | case 2: 105 | logger.info("用户已经收藏此文章"); 106 | result.put("result", 2); 107 | result.put("description", "用户已经收藏");// 描述信息 108 | break; 109 | case -1: 110 | logger.info("系统异常"); 111 | result.put("result", -1); 112 | result.put("description", "系统异常");// 描述信息 113 | break; 114 | case 0: 115 | logger.info("收藏失败"); 116 | result.put("result", 0); 117 | result.put("description", "收藏失败");// 描述信息 118 | break; 119 | default: 120 | logger.info("收藏成功"); 121 | result.put("result", 1); 122 | result.put("description", "收藏成功");// 描述信息 123 | break; 124 | } 125 | } else { 126 | result.put("result", 0); 127 | result.put("description", "信息传入有误");// 描述信息 128 | } 129 | 130 | // 返回收藏信息 131 | resultJson = gson.toJson(result); 132 | return resultJson; 133 | } 134 | 135 | 136 | @Path("/userCanceledArticle") 137 | @DELETE 138 | public String userCanceledArticle(@FormParam(value = "user_client_id") String user_client_id, 139 | @FormParam(value = "article_id") String article_id, @Context HttpServletResponse servletResponse) { 140 | 141 | servletResponse.setContentType("application/json;charset=UTF-8"); 142 | logger.info("用户:" + user_client_id + "取消收藏文章:" + article_id); 143 | // 返回参数的map 144 | Map result = new HashMap(); 145 | String resultJson = ""; 146 | // 查询参数 147 | Map params = new HashMap(); 148 | // 删除收藏信息 149 | if (!"".equals(user_client_id) && null != user_client_id && !"".equals(article_id) && null != article_id) { 150 | // 判断用户是否收藏过,删除 151 | params.put("user_client_id", user_client_id); 152 | params.put("article_id", article_id); 153 | 154 | int cuc = peopleOperationArticleService.checkUserCollectionOrDeleteUserCollection(params); 155 | switch (cuc) { 156 | case 2: 157 | logger.info("用户没有收藏此文章"); 158 | result.put("result", 2); 159 | result.put("description", "用户没有收藏此文章,不可以取消");// 描述信息 160 | break; 161 | case -1: 162 | logger.info("系统异常"); 163 | result.put("result", -1); 164 | result.put("description", "系统异常");// 描述信息 165 | break; 166 | case 0: 167 | logger.info("取消收藏失败"); 168 | result.put("result", 0); 169 | result.put("description", "取消收藏失败");// 描述信息 170 | break; 171 | default: 172 | logger.info("取消成功"); 173 | result.put("result", 1); 174 | result.put("description", "取消成功");// 描述信息 175 | break; 176 | } 177 | } else { 178 | result.put("result", 0); 179 | result.put("description", "信息传入有误");// 描述信息 180 | } 181 | 182 | // 返回收藏信息 183 | resultJson = gson.toJson(result); 184 | return resultJson; 185 | } 186 | 187 | 188 | /** 189 | * 190 | * 获取用户收藏文章列表. 191 | *
根据用户id获取收藏列表 192 | * @Copyright itjh 193 | * @Project 194 | * @param user_client_id 195 | * @param pageNum 196 | * @param showNum 197 | * @param servletResponse 198 | * @return 199 | * @return String 200 | * @throws 201 | * @author 宋立君 202 | * @date 2015年3月17日 下午5:56:46 203 | * @Version 204 | * @JDK version used 8.0 205 | * @Modification history none 206 | * @Modified by none 207 | */ 208 | @GET 209 | @Produces(MediaType.APPLICATION_JSON) 210 | @Path("queryArticleListByUserCollection/{user_client_id}/{pageNum}/{showNum}") 211 | public String queryArticleListByUserCollection(@PathParam(value = "user_client_id") String user_client_id,@PathParam(value = "pageNum") int pageNum, 212 | @PathParam(value = "showNum") int showNum, @Context HttpServletResponse servletResponse) { 213 | servletResponse.setContentType("application/json;charset=UTF-8"); 214 | // 返回参数的map 215 | Map result = new HashMap(); 216 | String resultJson = ""; 217 | try { 218 | Map params = new HashMap(); 219 | pageNum = pageNum*showNum; 220 | params.put("pageNum", pageNum); 221 | params.put("showNum", showNum); 222 | params.put("user_client_id", user_client_id); 223 | List
articles = peopleOperationArticleService.queryArticleListByUserCollection(params); 224 | if (null != articles) { 225 | logger.info("获取用户收藏文章列表"); 226 | result.put("result", 1); 227 | result.put("content", articles); 228 | result.put("description", "文章列表获取成功");// 描述信息 229 | }else{ 230 | result.put("result", -1); 231 | result.put("content", articles); 232 | result.put("description", "文章列表获取失败");// 描述信息 233 | } 234 | } catch (Exception e) { 235 | logger.info("系统异常\n"); 236 | logger.info(e.getMessage()); 237 | result.put("result", 0); 238 | result.put("description", "系统异常");// 描述信息 239 | e.printStackTrace(); 240 | } 241 | resultJson = gson.toJson(result); 242 | return resultJson; 243 | } 244 | 245 | 246 | 247 | 248 | } 249 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/server/PeopleServer.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.server; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.annotation.Resource; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import javax.ws.rs.FormParam; 10 | import javax.ws.rs.POST; 11 | import javax.ws.rs.Path; 12 | import javax.ws.rs.Produces; 13 | import javax.ws.rs.core.Context; 14 | import javax.ws.rs.core.MediaType; 15 | 16 | import net.rubyeye.xmemcached.MemcachedClient; 17 | 18 | import org.apache.log4j.Logger; 19 | import org.springframework.stereotype.Repository; 20 | 21 | import com.google.gson.Gson; 22 | 23 | import cn.com.itjh.mitjh.domain.People; 24 | import cn.com.itjh.mitjh.service.PeopleService; 25 | 26 | /** 27 | * 28 | * 处理人(用户)接口.
29 | * 处理人(用户)接口 30 | * 31 | * @Copyright itjh 32 | * @Project 33 | * @author 宋立君 34 | * @date 2014年12月17日 下午3:16:38 35 | * @Version 36 | * @JDK version used 8.0 37 | * @Modification history none 38 | * @Modified by none 39 | */ 40 | @Repository 41 | @Path("PeopleServer") 42 | public class PeopleServer { 43 | 44 | @Resource 45 | private PeopleService peopleService; 46 | 47 | private static final Logger logger = Logger.getLogger(PeopleServer.class.getName()); 48 | 49 | @Resource 50 | private MemcachedClient memcachedClient; 51 | 52 | Gson gson = new Gson(); 53 | 54 | @Path("/saveUser") 55 | @POST 56 | @Produces(MediaType.APPLICATION_JSON) 57 | public String saveUser(@FormParam(value = "user_client_id") String user_client_id, 58 | @FormParam(value = "face") String face, @FormParam(value = "platform_id") int platform_id, 59 | @FormParam(value = "nickname") String nickname, @Context HttpServletRequest servletRequest, 60 | @Context HttpServletResponse servletResponse) { 61 | servletResponse.setContentType("application/json;charset=UTF-8"); 62 | // 返回参数的map 63 | Map result = new HashMap(); 64 | String resultJson = ""; 65 | try { 66 | if (null != user_client_id && "" != user_client_id && null != face && "" != face && null != nickname 67 | && "" != nickname) { 68 | 69 | People people = new People(user_client_id,nickname,face,platform_id); 70 | 71 | int count = peopleService.save(people); 72 | if (count == 1) { 73 | logger.info("保存用户成功"); 74 | result.put("result", 1); 75 | result.put("people", people); 76 | result.put("description", "用户信息注册成功");// 描述信息 77 | } 78 | if (count == 2) { 79 | logger.info("用户登录成功"); 80 | result.put("result", 1); 81 | result.put("people", people); 82 | result.put("description", "用户信息获取成功");// 描述信息 83 | } 84 | } else { 85 | result.put("result", 0); 86 | result.put("description", "信息传入有误");// 描述信息 87 | } 88 | } catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | resultJson = gson.toJson(result); 92 | return resultJson; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/ArticleService.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import cn.com.itjh.mitjh.domain.Article; 7 | import cn.com.itjh.mitjh.domain.ArticleCategory; 8 | 9 | /** 10 | * 11 | * 处理文章的Service. 12 | *
详细说明 13 | * @Copyright vcinema 14 | * @Project 15 | * @author 宋立君 16 | * @date 2014年10月30日 下午4:05:31 17 | * @Version 18 | * @JDK version used 8.0 19 | * @Modification history none 20 | * @Modified by none 21 | */ 22 | public interface ArticleService { 23 | /** 24 | * 25 | * 获取文章列表. 26 | *
根据分类ID获取文章列表 27 | * @Copyright itjh 28 | * @Project 29 | * @param params 30 | * @return 31 | * @return List
32 | * @throws 33 | * @author 宋立君 34 | * @date 2014年10月30日 下午3:43:22 35 | * @Version 36 | * @JDK version used 8.0 37 | * @Modification history none 38 | * @Modified by none 39 | */ 40 | List
queryArticleListByCat(Map params); 41 | /** 42 | * 43 | * 获取文章列表. 44 | *
获取各分类最新的文章列表 45 | * @Copyright itjh 46 | * @Project 47 | * @param params 48 | * @return 49 | * @return List
50 | * @throws 51 | * @author 宋立君 52 | * @date 2014年10月30日 下午3:43:22 53 | * @Version 54 | * @JDK version used 8.0 55 | * @Modification history none 56 | * @Modified by none 57 | */ 58 | List
queryArticleListByNew(Map params); 59 | /** 60 | * 61 | * 获取文章详情. 62 | *
根据文章ID获取文章详情 63 | * @Copyright vcinema 64 | * @Project 65 | * @param aid 66 | * @return 67 | * @return Article 68 | * @throws 69 | * @author 宋立君 70 | * @date 2014年11月3日 上午11:54:47 71 | * @Version 72 | * @JDK version used 8.0 73 | * @Modification history none 74 | * @Modified by none 75 | */ 76 | Article queryArticleById(Map params); 77 | /** 78 | * 79 | * 根据分类获取文章列表. 80 | *
根据不同的分类ID获取文章列表 81 | * @Copyright vcinema 82 | * @Project 83 | * @param params 84 | * @return 85 | * @return List
86 | * @throws 87 | * @author 宋立君 88 | * @date 2014年12月2日 下午6:49:48 89 | * @Version 90 | * @JDK version used 8.0 91 | * @Modification history none 92 | * @Modified by none 93 | */ 94 | List
queryArticleListByCategory(Map params); 95 | 96 | /** 97 | * 98 | * 获取分类. 99 | *
获取文章所有分类 100 | * @Copyright vcinema 101 | * @Project 102 | * @return 103 | * @return ArticleCategory 104 | * @throws 105 | * @author 宋立君 106 | * @date 2014年12月2日 下午7:10:26 107 | * @Version 108 | * @JDK version used 8.0 109 | * @Modification history none 110 | * @Modified by none 111 | */ 112 | List queryArticleCategory(); 113 | 114 | 115 | 116 | /** 117 | * 118 | * 查询文章总数. 119 | *
查询文章总数 120 | * @Copyright vcinema 121 | * @Project 122 | * @return 123 | * @return Long 124 | * @throws 125 | * @author 宋立君 126 | * @date 2015年3月31日 下午5:29:59 127 | * @Version 128 | * @JDK version used 8.0 129 | * @Modification history none 130 | * @Modified by none 131 | */ 132 | Long selectCountByNew(); 133 | 134 | 135 | /** 136 | * 137 | * 根据分类查询文章总数.
138 | * 根据分类查询文章总数 139 | * 140 | * @Copyright vcinema 141 | * @Project 142 | * @return 143 | * @return Long 144 | * @throws 145 | * @author 宋立君 146 | * @date 2015年3月31日 下午5:29:59 147 | * @Version 148 | * @JDK version used 8.0 149 | * @Modification history none 150 | * @Modified by none 151 | */ 152 | Long selectCountByByCategory(Map params); 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/PeopleOperationArticleService.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import cn.com.itjh.mitjh.domain.Article; 7 | 8 | /** 9 | * 10 | * 用户操作文章Server. 11 | *
用户收藏,喜欢,顶等操作 12 | * @Copyright itjh 13 | * @Project 14 | * @author 宋立君 15 | * @date 2015年3月17日 下午4:33:48 16 | * @Version 17 | * @JDK version used 8.0 18 | * @Modification history none 19 | * @Modified by none 20 | */ 21 | public interface PeopleOperationArticleService { 22 | 23 | /** 24 | * 25 | * 检测用户是否收藏过此文章. 26 | *
检测用户是否收藏过此文章 27 | * @Copyright vcinema 28 | * @Project 29 | * @param params 30 | * @return 31 | * @return int 32 | * @throws 33 | * @author 宋立君 34 | * @date 2015年3月17日 下午4:59:18 35 | * @Version 36 | * @JDK version used 8.0 37 | * @Modification history none 38 | * @Modified by none 39 | */ 40 | int checkUserCollectionOrSaveUserCollection(Map params); 41 | /** 42 | * 43 | * 获取用户收藏文章列表. 44 | *
根据用户id获取收藏列表 45 | * @Copyright itjh 46 | * @Project 47 | * @param user_client_id 48 | * @param pageNum 49 | * @param showNum 50 | * @param servletResponse 51 | * @return 52 | * @return String 53 | * @throws 54 | * @author 宋立君 55 | * @date 2015年3月17日 下午5:56:46 56 | * @Version 57 | * @JDK version used 8.0 58 | * @Modification history none 59 | * @Modified by none 60 | */ 61 | List
queryArticleListByUserCollection(Map params); 62 | /** 63 | * 64 | * 用户取消收藏文章. 65 | *
用户取消收藏文章 66 | * @Copyright vcinema 67 | * @Project 68 | * @param params 69 | * @return 70 | * @return int 71 | * @throws 72 | * @author 宋立君 73 | * @date 2015年4月2日 下午3:41:22 74 | * @Version 75 | * @JDK version used 8.0 76 | * @Modification history none 77 | * @Modified by none 78 | */ 79 | int checkUserCollectionOrDeleteUserCollection(Map params); 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/PeopleService.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service; 2 | 3 | import cn.com.itjh.mitjh.domain.People; 4 | 5 | /** 6 | * 7 | * 人Service. 8 | *
操作人Service 9 | * @Copyright itjh 10 | * @Project 11 | * @author 宋立君 12 | * @date 2014年12月17日 下午3:14:32 13 | * @Version 14 | * @JDK version used 8.0 15 | * @Modification history none 16 | * @Modified by none 17 | */ 18 | public interface PeopleService { 19 | 20 | /** 21 | * 22 | * 保存人. 23 | *
保存人 24 | * @Copyright itjh 25 | * @Project 26 | * @param people 27 | * @return 28 | * @return int 29 | * @throws 30 | * @author 宋立君 31 | * @date 2014年12月17日 下午3:12:44 32 | * @Version 33 | * @JDK version used 8.0 34 | * @Modification history none 35 | * @Modified by none 36 | */ 37 | int save(People people); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/impl/ArticleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service.impl; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import javax.annotation.Resource; 7 | 8 | import org.springframework.stereotype.Service; 9 | 10 | import cn.com.itjh.mitjh.dao.ArticleDao; 11 | import cn.com.itjh.mitjh.domain.Article; 12 | import cn.com.itjh.mitjh.domain.ArticleCategory; 13 | import cn.com.itjh.mitjh.service.ArticleService; 14 | 15 | /** 16 | * 17 | * 处理文章Service实现类. 18 | *
处理文章Service实现类 19 | * @Copyright itjh 20 | * @Project 21 | * @author 宋立君 22 | * @date 2014年10月30日 下午4:06:26 23 | * @Version 24 | * @JDK version used 8.0 25 | * @Modification history none 26 | * @Modified by none 27 | */ 28 | @Service 29 | public class ArticleServiceImpl implements ArticleService { 30 | 31 | @Resource 32 | private ArticleDao articleDao; 33 | 34 | @Override 35 | public List
queryArticleListByCat(Map params) { 36 | return null; 37 | } 38 | 39 | @Override 40 | public List
queryArticleListByNew(Map params) { 41 | return articleDao.queryArticleListByNew(params); 42 | } 43 | 44 | @Override 45 | public Article queryArticleById(Map params) { 46 | // TODO Auto-generated method stub 47 | return articleDao.queryArticleById(params); 48 | } 49 | 50 | @Override 51 | public List
queryArticleListByCategory(Map params) { 52 | return articleDao.queryArticleListByCategory(params); 53 | } 54 | 55 | @Override 56 | public List queryArticleCategory() { 57 | return articleDao.queryArticleCategory(); 58 | } 59 | @Override 60 | public Long selectCountByNew() { 61 | return articleDao.selectCountByNew(); 62 | } 63 | 64 | @Override 65 | public Long selectCountByByCategory(Map params) { 66 | return articleDao.selectCountByByCategory(params); 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/impl/PeopleOperationArticleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service.impl; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.annotation.Resource; 8 | 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import cn.com.itjh.mitjh.dao.PeopleDao; 13 | import cn.com.itjh.mitjh.dao.PeopleOperationArticleDao; 14 | import cn.com.itjh.mitjh.domain.Article; 15 | import cn.com.itjh.mitjh.service.PeopleOperationArticleService; 16 | 17 | /** 18 | * 19 | * 用户操作文章Server.
20 | * 用户收藏,喜欢,顶等操作 21 | * 22 | * @Copyright itjh 23 | * @Project 24 | * @author 宋立君 25 | * @date 2015年3月17日 下午4:34:33 26 | * @Version 27 | * @JDK version used 8.0 28 | * @Modification history none 29 | * @Modified by none 30 | */ 31 | @Service 32 | public class PeopleOperationArticleServiceImpl implements PeopleOperationArticleService { 33 | 34 | @Resource 35 | private PeopleDao peopleDao; 36 | @Resource 37 | private PeopleOperationArticleDao peopleOperationArticleDao; 38 | 39 | @Transactional 40 | @Override 41 | public int checkUserCollectionOrSaveUserCollection(Map params) { 42 | 43 | int result = 0; 44 | 45 | try { 46 | // 检测用户是否收藏过 47 | int count = peopleOperationArticleDao.checkUserCollection(params); 48 | if (count > 0) {//不进行收藏操作 49 | result = 2; 50 | }else{ 51 | //进行收藏操作 52 | params.put("time", new Date()); 53 | result = peopleOperationArticleDao.saveUserCollection(params); 54 | } 55 | } catch (Exception e) { 56 | result = -1; 57 | e.printStackTrace(); 58 | } 59 | 60 | return result; 61 | } 62 | 63 | @Override 64 | public List
queryArticleListByUserCollection(Map params) { 65 | return peopleOperationArticleDao.queryArticleListByUserCollection(params); 66 | } 67 | 68 | @Override 69 | public int checkUserCollectionOrDeleteUserCollection(Map params) { 70 | 71 | int result = 0; 72 | try { 73 | // 检测用户是否收藏过 74 | int count = peopleOperationArticleDao.checkUserCollection(params); 75 | if (count > 0) {//不进行取消收藏操作 76 | //进行取消收藏操作 77 | params.put("time", new Date()); 78 | result = peopleOperationArticleDao.deleteUserCollection(params); 79 | }else{ 80 | result = 2; 81 | } 82 | } catch (Exception e) { 83 | result = -1; 84 | e.printStackTrace(); 85 | } 86 | 87 | return result; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/cn/com/itjh/mitjh/service/impl/PeopleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.com.itjh.mitjh.service.impl; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.annotation.Resource; 7 | import javax.ws.rs.POST; 8 | import javax.ws.rs.Path; 9 | 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import cn.com.itjh.mitjh.dao.PeopleDao; 14 | import cn.com.itjh.mitjh.domain.People; 15 | import cn.com.itjh.mitjh.service.PeopleService; 16 | 17 | @Service 18 | public class PeopleServiceImpl implements PeopleService { 19 | 20 | @Resource 21 | private PeopleDao peopleDao; 22 | 23 | @Transactional 24 | @Override 25 | public int save(People people) { 26 | 27 | int count = 0; 28 | 29 | // 通过user_client_id,get,Platform_id判断用户是否注册过 30 | Map peopleumap = new HashMap(); 31 | peopleumap.put("userClientId", people.getUser_client_id()); 32 | peopleumap.put("platformId", people.getPlatform_id()); 33 | People peopleu = peopleDao.selectUserByUserClientId(peopleumap); 34 | 35 | if (null != peopleu) { 36 | // 用户通过第三方注册过,检测信息是否修改,从而修改客户端用户信息 37 | // 修改SQL 38 | StringBuffer usql = new StringBuffer(); 39 | 40 | if (!peopleu.getNickname().equals(people.getNickname())) {// 判断昵称 41 | usql.append("nickname='" + people.getNickname()+"'"); 42 | } 43 | if (!peopleu.getFace().equals(people.getFace())) {// 判断头像 44 | usql.append("face='" + people.getFace()+"'"); 45 | } 46 | 47 | if (usql.length() > 0) { 48 | usql.append("where user_client_id='" + people.getUser_client_id() +"' And platform_id=" + people.getPlatform_id()); 49 | //修改用户信息 50 | peopleumap = new HashMap(); 51 | String resql = usql.toString(); 52 | peopleumap.put("resql", resql); 53 | count = peopleDao.updateUser(peopleumap); 54 | }else{ 55 | count = 2; 56 | } 57 | } else {// 没有注册进行保存 58 | count = peopleDao.save(people); 59 | } 60 | return count; 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | classpath:jdbc.properties 22 | classpath:memcached.properties 23 | classpath:redis.properties 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | ${memcached.server1.host} 36 | 37 | 38 | ${memcached.server1.port} 39 | 40 | 41 | 42 | 43 | 44 | 45 | ${memcached.server1.weight} 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc_driverClassName=com.mysql.jdbc.Driver 2 | jdbc_url=jdbc:mysql://203.195.152.45:3306/mitjh?useUnicode=true&characterEncoding=utf-8 3 | jdbc_username=mitjh 4 | jdbc_password=song521530 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #@not support hotloading 2 | # For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml! 3 | # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J. 4 | # 5 | # Log4J Settings for log4j 1.2.x (via jakarta-commons-logging) 6 | # 7 | # The five logging levels used by Log are (in order): 8 | # 9 | # 1. DEBUG (the least serious) 10 | # 2. INFO 11 | # 3. WARN 12 | # 4. ERROR 13 | # 5. FATAL (the most serious) 14 | # Set root logger level to WARN and append to stdout 15 | 16 | # root stuff 17 | log4j.rootLogger=INFO,logfile,stdout,file,debug 18 | # Spring Stuff 19 | #log4j.logger.org.springframework=INFO,logfile,stdout 20 | 21 | ### \u540e\u53f0\u63a7\u5236\u53f0\u7684\u6253\u5370 ### 22 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender 23 | log4j.appender.stdout.Target = System.out 24 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout 25 | log4j.appender.stdout.layout.ConversionPattern =[mitjh]%d{yyyy-MM-dd HH:mm:ss} %p %F %m%n 26 | 27 | #\u8f93\u51fa\u5230\u65e5\u5fd7\u6587\u4ef6 28 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 29 | log4j.appender.file.File=../logs/mitjh.log 30 | log4j.appender.file.DatePattern='.'yyyy-MM-dd 31 | log4j.appender.file.Append=true 32 | log4j.appender.file.Threshold=DEBUG 33 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 34 | log4j.appender.file.layout.ConversionPattern=[mitjh]%d{yyyy-MM-dd HH:mm:ss} %p %F %m%n 35 | 36 | #\u4fdd\u5b58\u5f02\u5e38\u4fe1\u606f\u5230\u5355\u72ec\u6587\u4ef6 37 | log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender 38 | log4j.appender.logfile.File=../logs/mitjh_error.log 39 | log4j.appender.logfile.DatePattern='.'yyyy-MM-dd 40 | log4j.appender.logfile.Append=true 41 | log4j.appender.logfile.Threshold=ERROR 42 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 43 | log4j.appender.logfile.layout.ConversionPattern=[mitjh]%d{yyyy-MM-dd HH:mm:ss} %p %F %m%n 44 | #mybatis\u65e5\u5fd7\u8f93\u51fa 45 | log4j.logger.com.ibatis=debug 46 | log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug 47 | log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug 48 | log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug 49 | log4j.logger.java.sql.Connection=debug 50 | log4j.logger.java.sql.Statement=debug 51 | log4j.logger.java.sql.PreparedStatement=debug,stdout 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/memcached.properties: -------------------------------------------------------------------------------- 1 | memcached.connectionPoolSize=5 2 | memcached.failureMode=true 3 | #server1 4 | memcached.server1.host=203.195.152.45 5 | memcached.server1.port=11211 6 | memcached.server1.weight=1 -------------------------------------------------------------------------------- /src/main/resources/redis.properties: -------------------------------------------------------------------------------- 1 | #\u6700\u5927\u5206\u914d\u7684\u5bf9\u8c61\u6570 2 | redis.pool.maxActive=1024 3 | #\u6700\u5927\u80fd\u591f\u4fdd\u6301idel\u72b6\u6001\u7684\u5bf9\u8c61\u6570 4 | redis.pool.maxIdle=200 5 | #\u5f53\u6c60\u5185\u6ca1\u6709\u8fd4\u56de\u5bf9\u8c61\u65f6\uff0c\u6700\u5927\u7b49\u5f85\u65f6\u95f4 6 | redis.pool.maxWait=1000 7 | #\u5f53\u8c03\u7528borrow Object\u65b9\u6cd5\u65f6\uff0c\u662f\u5426\u8fdb\u884c\u6709\u6548\u6027\u68c0\u67e5 8 | redis.pool.testOnBorrow=true 9 | 10 | #IP 11 | redis.ip=203.195.152.45 12 | #Port 13 | redis.port=55555 14 | -------------------------------------------------------------------------------- /src/main/resources/spring-mybatis.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 21 | 22 | ${jdbc_driverClassName} 23 | 24 | 25 | ${jdbc_url} 26 | 27 | 28 | ${jdbc_username} 29 | 30 | 31 | ${jdbc_password} 32 | 33 | 34 | 35 | 20 36 | 37 | 38 | 39 | 1 40 | 41 | 42 | 43 | 60000 44 | 45 | 46 | 47 | 20 48 | 49 | 50 | 51 | 3 52 | 53 | 54 | 55 | true 56 | 57 | 58 | 59 | 180 60 | 61 | 62 | 63 | clientEncoding=UTF-8 64 | 65 | 66 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | log4jConfigLocation 11 | classpath:log4j.properties 12 | 13 | 14 | 15 | log4jRefreshInterval 16 | 6000 17 | 18 | 19 | org.springframework.web.util.Log4jConfigListener 20 | 21 | 22 | contextConfigLocation 23 | classpath:applicationContext.xml;classpath:spring-mybatis.xml 24 | 25 | 26 | 27 | org.springframework.web.context.ContextLoaderListener 28 | 29 | 30 | jersey-serlvet 31 | com.sun.jersey.spi.spring.container.servlet.SpringServlet 32 | 33 | com.sun.jersey.config.property.packages 34 | cn.com.itjh 35 | 36 | 37 | 38 | 39 | jersey-serlvet 40 | /* 41 | 42 | 43 | -------------------------------------------------------------------------------- /target/.gitignore: -------------------------------------------------------------------------------- 1 | /classes/ 2 | /test-classes/ 3 | -------------------------------------------------------------------------------- /target/m2e-wtp/web-resources/.gitignore: -------------------------------------------------------------------------------- 1 | /META-INF/ 2 | --------------------------------------------------------------------------------