ArticleApi.java 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. package com.yihu.jk.api;
  2. import com.common.json.JSONException;
  3. import com.coreframework.db.DB;
  4. import com.coreframework.remoting.standard.DateOper;
  5. import com.coreframework.util.AppConfig;
  6. import com.yihu.jk.dao.ArticleDao;
  7. import com.yihu.jk.dao.ArticlePcDao;
  8. import com.yihu.jk.utils.ApiUtil;
  9. import com.yihu.jk.utils.StringUtil;
  10. import com.yihu.jk.vo.Article;
  11. import com.yihu.jk.vo.ArticleStatistic;
  12. import com.yihu.jk.vo.OrgArticleVo;
  13. import com.yihu.wsgw.api.InterfaceMessage;
  14. import net.sf.json.JSONArray;
  15. import net.sf.json.JSONObject;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.apache.log4j.Logger;
  18. import java.sql.SQLException;
  19. import java.sql.Timestamp;
  20. import java.util.List;
  21. public class ArticleApi {
  22. private static ArticleDao dao = new ArticleDao();
  23. private static ArticlePcDao articlePcDao = new ArticlePcDao();
  24. static Logger log = Logger.getLogger(ArticleApi.class.getName());
  25. /**
  26. * 查询文章列表 返回(文章统计,文章相关字段
  27. *
  28. * @param im
  29. * @return
  30. * @throws JSONException
  31. */
  32. public String getArticalList(InterfaceMessage im) throws JSONException {
  33. JSONObject json = JSONObject.fromObject(im.getParam());
  34. String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
  35. Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
  36. String orgId = StringUtil.isEmpty(json.get("orgId")) ? null : json.getString("orgId");
  37. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
  38. String startTime = StringUtil.isEmpty(json.get("startTime")) ? null : json.getString("startTime");
  39. String endTime = StringUtil.isEmpty(json.get("endTime")) ? null : json.getString("endTime");
  40. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
  41. .getString("firstLevelCategoryId");
  42. Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
  43. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
  44. ArticleStatistic vo = new ArticleStatistic();
  45. vo.setArticleId(articleId);
  46. vo.setArticleState(articleState);
  47. vo.setArticleTitle(articleTitle);
  48. vo.setStartTime(startTime);
  49. vo.setEndTime(endTime);
  50. vo.setOrgId(orgId);
  51. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  52. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  53. JSONArray array = new JSONArray();
  54. try {
  55. List<ArticleStatistic> result = dao.getArticleList(vo, pageIndex, pageSize);
  56. JSONObject jsonObj = new JSONObject();
  57. if (result.size() > 0) {
  58. for (ArticleStatistic vbo : result) {
  59. jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
  60. jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
  61. jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
  62. jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
  63. jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
  64. jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
  65. jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
  66. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  67. jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
  68. jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
  69. jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
  70. jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
  71. jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
  72. jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
  73. jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
  74. jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
  75. jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
  76. jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
  77. jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
  78. jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
  79. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  80. jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
  81. jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
  82. jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
  83. jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
  84. jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
  85. array.add(jsonObj);
  86. }
  87. }
  88. int count = dao.getArticleListCount(vo);
  89. rv.put("Result", array);
  90. rv.put("Count", count);
  91. return rv.toString();
  92. } catch (SQLException e) {
  93. e.printStackTrace();
  94. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  95. }
  96. }
  97. /**
  98. * // 获取文章收藏列表
  99. *
  100. * @param im
  101. * @return
  102. * @throws JSONException
  103. */
  104. public String getCollectionArticalList(InterfaceMessage im) throws JSONException {
  105. JSONObject json = JSONObject.fromObject(im.getParam());
  106. Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
  107. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
  108. .getString("firstLevelCategoryId");
  109. Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
  110. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
  111. String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
  112. int userType = StringUtil.isEmpty(json.get("userType")) ? 2 : json.getInt("userType");// 1医生
  113. boolean myArticle = StringUtil.isEmpty(json.get("myArticle")) ? false : json.getBoolean("myArticle");
  114. if (StringUtil.isEmpty(userId)) {
  115. return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
  116. }
  117. ArticleStatistic vo = new ArticleStatistic();
  118. vo.setArticleState(articleState);
  119. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  120. vo.setUserId(userId);
  121. vo.setUserType(userType);
  122. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  123. JSONArray array = new JSONArray();
  124. try {
  125. List<ArticleStatistic> result = dao.getArticleCollectionArticleList(vo, pageIndex, pageSize,myArticle);
  126. JSONObject jsonObj = new JSONObject();
  127. if (result.size() > 0) {
  128. for (ArticleStatistic vbo : result) {
  129. jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
  130. jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
  131. jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
  132. jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
  133. jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
  134. jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
  135. jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
  136. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  137. jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
  138. jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
  139. jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
  140. jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
  141. jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
  142. jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
  143. jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
  144. jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
  145. jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
  146. jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
  147. jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
  148. jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
  149. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  150. jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
  151. jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
  152. jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
  153. jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
  154. jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
  155. jsonObj.put("articleContent",StringUtil.getJSONValue(vbo.getArticleContent()));
  156. array.add(jsonObj);
  157. }
  158. }
  159. int count = dao.getArticleCollectionArticleListCount(vo);
  160. rv.put("Result", array);
  161. rv.put("Count", count);
  162. return rv.toString();
  163. } catch (SQLException e) {
  164. e.printStackTrace();
  165. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  166. }
  167. }
  168. /**
  169. * 根据文章ID 获取文章详情
  170. *
  171. * @param im
  172. * @return
  173. * @throws JSONException
  174. */
  175. public String getArticalById(InterfaceMessage im) throws JSONException {
  176. JSONObject json = JSONObject.fromObject(im.getParam());
  177. String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
  178. String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
  179. Integer userType = StringUtil.isEmpty(json.get("userType")) ? 0 : json.getInt("userType");
  180. if (StringUtil.isEmpty(articleId)) {
  181. return ApiUtil.getRespJSON(-10000, "articleId 必传").toString();
  182. }
  183. ArticleStatistic vo = new ArticleStatistic();
  184. vo.setArticleId(articleId);
  185. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  186. JSONArray array = new JSONArray();
  187. try {
  188. List<ArticleStatistic> result = dao.getArticleById(vo);
  189. JSONObject jsonObj = new JSONObject();
  190. if (result.size() > 0) {
  191. for (ArticleStatistic vbo : result) {
  192. jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
  193. jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
  194. jsonObj.put("articleContent", StringUtil.getJSONValue(vbo.getArticleContent()));
  195. jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
  196. jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
  197. jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
  198. jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
  199. jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
  200. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  201. jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
  202. jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
  203. jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
  204. jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
  205. jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
  206. jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
  207. jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
  208. jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
  209. jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
  210. jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
  211. jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
  212. jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
  213. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  214. jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
  215. jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
  216. jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
  217. jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
  218. jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
  219. jsonObj.put("deptName", StringUtil.getJSONValue(vbo.getDeptName()));
  220. jsonObj.put("titleLevel", StringUtil.getJSONValue(vbo.getTitleLevel()));
  221. jsonObj.put("operatorImg", StringUtil.getJSONValue(vbo.getOperatorImg()));
  222. jsonObj.put("userScope", StringUtil.getJSONValue(vbo.getUserScope()));
  223. jsonObj.put("articleCategoryId", StringUtil.getJSONValue(vbo.getArticleCategoryId()));
  224. jsonObj.put("articleCategoryName", StringUtil.getJSONValue(vbo.getArticleCategoryName()));
  225. jsonObj.put("pushNumber", StringUtil.getJSONValue(vbo.getPushNumber()));
  226. if (StringUtil.isNotEmpty(userId)) {
  227. vo.setUserId(userId);
  228. vo.setUserType(userType);
  229. int pointNumberCount = dao.pointNumberCount(vo);
  230. int collectionNumberCount = dao.collectionNumberCount(vo);
  231. jsonObj.put("pointNumberCount", pointNumberCount);
  232. jsonObj.put("collectionNumberCount", collectionNumberCount);
  233. }
  234. array.add(jsonObj);
  235. }
  236. }
  237. rv.put("Result", array);
  238. return rv.toString();
  239. } catch (SQLException e) {
  240. e.printStackTrace();
  241. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  242. }
  243. }
  244. /**
  245. * // 更新统计表数据
  246. *
  247. * @param articleId
  248. * @param behaviorAction
  249. * @param number
  250. */
  251. public static void updateArticleStatistic(String articleId, int behaviorAction, int number) {
  252. try {
  253. dao.insertArticleStatistic(articleId);
  254. // 浏览数 点赞数 评论数 分享数 收藏数
  255. if (behaviorAction == 1) {// 点赞
  256. dao.updateArticleStatistic(articleId, "PointNumber", behaviorAction, number);
  257. } else if (behaviorAction == 2) {// 转发
  258. } else if (behaviorAction == 3) {// 分享
  259. dao.updateArticleStatistic(articleId, "ShareNumber", behaviorAction, number);
  260. } else if (behaviorAction == 4) {// 浏览
  261. dao.updateArticleStatistic(articleId, "BrowseNumber", behaviorAction, number);
  262. } else if (behaviorAction == 5) {// 评论
  263. dao.updateArticleStatistic(articleId, "CommentNumber", behaviorAction, number);
  264. } else if (behaviorAction == 6) {// 收藏
  265. dao.updateArticleStatistic(articleId, "CollectionNumber", behaviorAction, number);
  266. }else if (behaviorAction == 7) {// 发送
  267. dao.updateArticleStatistic(articleId, "PushNumber", behaviorAction, number);
  268. }
  269. } catch (SQLException e) {
  270. // TODO Auto-generated catch block
  271. log.error(e.getMessage() + "参数:" + articleId + behaviorAction);
  272. }
  273. }
  274. public static void main(String[] args) throws SQLException {
  275. initDB();
  276. // initArticleStatistic();
  277. String articleId = "10C2222122";
  278. int behaviorAction = 1;
  279. int number = 1;
  280. updateArticleStatistic(articleId, behaviorAction, number);
  281. }
  282. public static void initDB() {
  283. String DB_Alias = AppConfig.getValue("DB.Alias");
  284. String DB_DatabaseName = AppConfig.getValue("DB.DatabaseName");
  285. String DB_IP = AppConfig.getValue("DB.IP");
  286. String DB_UserName = AppConfig.getValue("DB.UserName");
  287. String DB_Password = AppConfig.getValue("DB.Password");
  288. String DB_Port = AppConfig.getValue("DB.Port");
  289. DB.me().addDataSourceMySQL(DB_Alias, DB_DatabaseName, DB_IP, Integer.parseInt(DB_Port), DB_UserName,
  290. DB_Password);
  291. }
  292. /**
  293. * // 初始化统计数据
  294. *
  295. * @throws SQLException
  296. */
  297. public static void initArticleStatistic() throws SQLException {
  298. dao.deleteArticleStatistic();// 删除所有统计数据
  299. ArticleStatistic vo = new ArticleStatistic();
  300. List<ArticleStatistic> result1 = dao.getArticleList(vo, 0, 100000000);// 获取全部文章ID
  301. if (result1.size() > 0) {
  302. for (ArticleStatistic vbo : result1) {
  303. List<ArticleStatistic> result = dao.queryArticleStatistic(vbo.getArticleId());
  304. ArticleStatistic vo1 = result.get(0);
  305. vo1.setArticleId(vbo.getArticleId());
  306. dao.insertArticleInitStatistic(vo1);// 插入统计数据
  307. }
  308. }
  309. }
  310. /**
  311. * // 初始化统计数据
  312. *
  313. * @throws SQLException
  314. */
  315. public String insertArticleStatistic(InterfaceMessage im) throws Exception {
  316. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  317. List<Article> result1 = dao.getAllArticle();
  318. if (result1.size() > 0) {
  319. for (Article vbo : result1) {
  320. dao.insertArticleStatistic(vbo.getArticleId());
  321. }
  322. }
  323. return rv.toString();
  324. }
  325. /**
  326. * 医生端查询文章列表
  327. *
  328. * @param im
  329. * @return
  330. * @throws JSONException
  331. */
  332. public String getDoctorArticalList(InterfaceMessage im) throws JSONException {
  333. JSONObject json = JSONObject.fromObject(im.getParam());
  334. Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
  335. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
  336. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
  337. .getString("firstLevelCategoryId");
  338. Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
  339. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
  340. String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
  341. ArticleStatistic vo = new ArticleStatistic();
  342. vo.setArticleState(articleState);
  343. vo.setArticleTitle(articleTitle);
  344. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  345. if (StringUtil.isEmpty(userId)) {
  346. return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
  347. }
  348. if (StringUtil.isEmpty(articleState)) {
  349. return ApiUtil.getRespJSON(-10000, "articleState 必传").toString();
  350. }
  351. vo.setUserId(userId);
  352. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  353. JSONArray array = new JSONArray();
  354. try {
  355. List<ArticleStatistic> result = dao.getDoctorArticleList(vo, pageIndex, pageSize);
  356. JSONObject jsonObj = new JSONObject();
  357. if (result.size() > 0) {
  358. for (ArticleStatistic vbo : result) {
  359. jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
  360. jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
  361. jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
  362. jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
  363. jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
  364. jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
  365. jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
  366. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  367. jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
  368. jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
  369. jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
  370. jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
  371. jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
  372. jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
  373. jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
  374. jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
  375. jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
  376. jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
  377. jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
  378. jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
  379. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  380. jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
  381. jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
  382. jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
  383. jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
  384. array.add(jsonObj);
  385. }
  386. }
  387. int count = dao.getDoctorArticleListCount(vo);
  388. rv.put("Result", array);
  389. rv.put("Count", count);
  390. return rv.toString();
  391. } catch (SQLException e) {
  392. e.printStackTrace();
  393. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  394. }
  395. }
  396. /**
  397. * 医生 端根据用户ID 查询发表文章
  398. *
  399. * @param im
  400. * @return
  401. * @throws JSONException
  402. */
  403. public String getDoctorArticalByUserId(InterfaceMessage im) throws JSONException {
  404. JSONObject json = JSONObject.fromObject(im.getParam());
  405. Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
  406. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
  407. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
  408. .getString("firstLevelCategoryId");
  409. Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
  410. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
  411. String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
  412. ArticleStatistic vo = new ArticleStatistic();
  413. vo.setArticleState(articleState);
  414. vo.setArticleTitle(articleTitle);
  415. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  416. if (StringUtil.isEmpty(userId)) {
  417. return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
  418. }
  419. if (StringUtil.isEmpty(articleState)) {
  420. return ApiUtil.getRespJSON(-10000, "articleState 必传").toString();
  421. }
  422. vo.setUserId(userId);
  423. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  424. JSONArray array = new JSONArray();
  425. try {
  426. List<ArticleStatistic> result = dao.getDoctorArticalByUserId(vo, pageIndex, pageSize);
  427. JSONObject jsonObj = new JSONObject();
  428. if (result.size() > 0) {
  429. for (ArticleStatistic vbo : result) {
  430. jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
  431. jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
  432. jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
  433. jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
  434. jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
  435. jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
  436. jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
  437. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  438. jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
  439. jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
  440. jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
  441. jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
  442. jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
  443. jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
  444. jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
  445. jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
  446. jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
  447. jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
  448. jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
  449. jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
  450. jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
  451. jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
  452. jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
  453. jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
  454. jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
  455. array.add(jsonObj);
  456. }
  457. }
  458. int count = dao.getDoctorArticalByUserIdCount(vo);
  459. rv.put("Result", array);
  460. rv.put("Count", count);
  461. return rv.toString();
  462. } catch (SQLException e) {
  463. e.printStackTrace();
  464. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  465. }
  466. }
  467. /************************************************* new ************************************************************/
  468. /**
  469. * 添加、编辑文章
  470. * @param im
  471. * @return
  472. * @throws JSONException
  473. */
  474. public String saveArticle(InterfaceMessage im) throws Exception {
  475. JSONObject json = JSONObject.fromObject(im.getParam());
  476. String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
  477. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
  478. String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");// 一级分类名称
  479. String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
  480. String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");// 二级分类名称
  481. String content = StringUtil.isEmpty(json.get("content")) ? null : json.getString("content");//内容
  482. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//标题
  483. Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
  484. Integer userScope = StringUtil.isEmpty(json.get("userScope")) ? null : json.getInt("userScope");//使用范围(1、全市使用,2、全区使用,3、全社区使用)
  485. String newUrl = StringUtil.isEmpty(json.get("newUrl")) ? null : json.getString("newUrl");//封面图片地址
  486. Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
  487. OrgArticleVo orgArticleVo = new OrgArticleVo();
  488. orgArticleVo.setArticleTitle(articleTitle);
  489. orgArticleVo.setArticleContent(content);
  490. orgArticleVo.setArticlelevel(articlelevel);
  491. orgArticleVo.setUserScope(userScope);
  492. orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
  493. orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
  494. orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
  495. orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
  496. orgArticleVo.setArticleCover(newUrl);
  497. Timestamp nowTime = DateOper.getNowDateTime();//插入和更新时间一样
  498. orgArticleVo.setUpdateTime(nowTime);
  499. if(StringUtil.isEmpty(articleId)) {
  500. String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");
  501. String orgName = StringUtil.isEmpty(json.get("orgName")) ? null : json.getString("orgName");//组织名称
  502. String deptName = StringUtil.isEmpty(json.get("deptName")) ? null : json.getString("deptName");//科室名称
  503. String levelName = StringUtil.isEmpty(json.get("levelName")) ? null : json.getString("levelName");//职称
  504. String photo = StringUtil.isEmpty(json.get("photo")) ? null : json.getString("photo");//头像
  505. String orgId = StringUtil.isEmpty(json.get("orgId")) ? null : json.getString("orgId");//组织
  506. String userName = StringUtil.isEmpty(json.get("userName")) ? null : json.getString("userName");//登录名称
  507. String articleType = StringUtil.isEmpty(json.get("articleType")) ? null : json.getString("articleType");//类型
  508. String operatorRoleCode = StringUtil.isEmpty(json.get("operatorRoleCode")) ? null : json.getString("operatorRoleCode");//操作人角色code
  509. String opertorRoleLevel = StringUtil.isEmpty(json.get("opertorRoleLevel")) ? null : json.getString("opertorRoleLevel");//操作人角色级别
  510. Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否认证
  511. String authentication = StringUtil.isEmpty(json.get("authentication")) ? null : json.getString("authentication");//认证单位
  512. String authenticationId = StringUtil.isEmpty(json.get("authenticationId")) ? null : json.getString("authenticationId");//认证单位ID
  513. articleId = StringUtil.createUUID();
  514. orgArticleVo.setArticleId(articleId);
  515. orgArticleVo.setArticleOrder(99);
  516. orgArticleVo.setArticleType(articleType);
  517. orgArticleVo.setInsertTime(nowTime);
  518. orgArticleVo.setArticleState(1);
  519. orgArticleVo.setDeptName(deptName);
  520. orgArticleVo.setTitleLevel(levelName);
  521. orgArticleVo.setOperatorImg(photo);
  522. orgArticleVo.setOrgId(orgId);
  523. orgArticleVo.setOperatorName(userName);
  524. orgArticleVo.setOperatorId(userCode);
  525. orgArticleVo.setLastOperatorId(userCode);
  526. orgArticleVo.setLastOperatorName(userName);
  527. orgArticleVo.setOperatorRoleCode(operatorRoleCode);
  528. orgArticleVo.setOperatorRoleLevel(opertorRoleLevel);
  529. orgArticleVo.setIsAuthentication(isAuthentication);
  530. orgArticleVo.setAuthentication(authentication);
  531. orgArticleVo.setAuthenticationId(authenticationId);
  532. orgArticleVo.setRoleType(roleType);
  533. if ("".equals(orgName) || orgName == null) {
  534. orgName = "无";
  535. }
  536. orgArticleVo.setOrgName(orgName);
  537. orgArticleVo.setArticleSource(orgName);
  538. //新增文章时 保存分享数,阅读数等数据
  539. // ArticleStatistic statistic = new ArticleStatistic();
  540. // statistic.setBrowseNumber(0);
  541. // statistic.setPointNumber(0);
  542. // statistic.setCommentNumber(0);
  543. // statistic.setShareNumber(0);
  544. // statistic.setCollectionNumber(0);
  545. // statistic.setArticleId(articleId);
  546. // dao.insertArticleInitStatistic(statistic);
  547. dao.insertArticleStatistic(articleId);
  548. return dao.saveArticle(orgArticleVo).toString();
  549. }else{
  550. orgArticleVo.setArticleId(articleId);
  551. return dao.updateArticle(orgArticleVo).toString();
  552. }
  553. }
  554. /************************************************ PC *************************************************************/
  555. public String queryArticlePcList(InterfaceMessage im) throws Exception {
  556. JSONObject json = JSONObject.fromObject(im.getParam());
  557. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
  558. String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
  559. String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
  560. String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
  561. Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
  562. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
  563. String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");//操作人id
  564. Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
  565. String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
  566. String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
  567. Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
  568. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
  569. Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
  570. Boolean isMyArticle = StringUtil.isEmpty(json.get("isMyArticle")) ? false : json.getBoolean("isMyArticle");
  571. Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
  572. if(page==null){
  573. return ApiUtil.getRespJSON(-10000, "page 必传").toString();
  574. }
  575. if(pageSize==null){
  576. return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
  577. }
  578. OrgArticleVo vo = new OrgArticleVo();
  579. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  580. vo.setSecondLevelCategoryId(secondLevelCategoryId);
  581. vo.setStartTime(insertTimeStart);
  582. vo.setEndTime(insertTimeEnd);
  583. vo.setArticlelevel(articlelevel);
  584. if(isMyArticle){
  585. vo.setOperatorId(userCode);
  586. }
  587. vo.setOperatorRoleCode(currentUserRole);
  588. vo.setArticleTitle(articleTitle);
  589. vo.setOperatorRoleLevel(currentUserRoleLevel);
  590. vo.setIsAuthentication(isAuthentication);
  591. vo.setRoleType(roleType);
  592. // JSONArray array = new JSONArray();
  593. System.out.printf("OrgArticleVo参数:"+vo.toString());
  594. try {
  595. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  596. com.common.json.JSONObject result = dao.queryArticlePcList(vo, page, pageSize,userCode,isMyArticle);
  597. // array.addAll(list);
  598. // int count = dao.queryArticlePcListCount(vo);
  599. // rv.put("Result", array);
  600. // rv.put("Count", count);
  601. rv.put("aaData", result.get("result").toString());
  602. rv.put("iTotalDisplayRecords", result.get("totalProperty"));
  603. rv.put("iTotalRecords", result.get("totalProperty"));
  604. rv.put("sEcho", sEcho);
  605. // System.out.printf("article:"+rv.toString());
  606. return rv.toString();
  607. }catch (SQLException e) {
  608. e.printStackTrace();
  609. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  610. }
  611. }
  612. public String queryArticleAPPList(InterfaceMessage im) throws Exception {
  613. JSONObject json = JSONObject.fromObject(im.getParam());
  614. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
  615. String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
  616. String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
  617. String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
  618. Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
  619. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
  620. String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");//操作人id
  621. Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
  622. String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
  623. String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
  624. Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
  625. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
  626. Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
  627. Boolean isMyArticle = StringUtil.isEmpty(json.get("isMyArticle")) ? false : json.getBoolean("isMyArticle");
  628. Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
  629. if(page==null){
  630. return ApiUtil.getRespJSON(-10000, "page 必传").toString();
  631. }
  632. if(pageSize==null){
  633. return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
  634. }
  635. OrgArticleVo vo = new OrgArticleVo();
  636. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  637. vo.setSecondLevelCategoryId(secondLevelCategoryId);
  638. vo.setStartTime(insertTimeStart);
  639. vo.setEndTime(insertTimeEnd);
  640. vo.setArticlelevel(articlelevel);
  641. if(isMyArticle){
  642. vo.setOperatorId(userCode);
  643. }
  644. vo.setOperatorRoleCode(currentUserRole);
  645. vo.setArticleTitle(articleTitle);
  646. vo.setOperatorRoleLevel(currentUserRoleLevel);
  647. vo.setIsAuthentication(isAuthentication);
  648. vo.setRoleType(roleType);
  649. JSONArray array = new JSONArray();
  650. try {
  651. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  652. List<Article> result = dao.queryArticleAPPList(vo, page, pageSize,userCode,isMyArticle);
  653. array.addAll(result);
  654. // int count = dao.queryArticlePcListCount(vo);
  655. // rv.put("Result", array);
  656. // rv.put("Count", count);
  657. rv.put("aaData", array);
  658. // rv.put("iTotalDisplayRecords", result.get("totalProperty"));
  659. // rv.put("iTotalRecords", result.get("totalProperty"));
  660. // rv.put("sEcho", sEcho);
  661. // System.out.printf("article:"+rv.toString());
  662. return rv.toString();
  663. }catch (SQLException e) {
  664. e.printStackTrace();
  665. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  666. }
  667. }
  668. /**
  669. * 文章认证列表
  670. * @param im
  671. * @return
  672. * @throws Exception
  673. */
  674. public String authenArticlePCList(InterfaceMessage im) throws Exception {
  675. JSONObject json = JSONObject.fromObject(im.getParam());
  676. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
  677. String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
  678. String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
  679. String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
  680. String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
  681. Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
  682. String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
  683. String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
  684. Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
  685. Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
  686. Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
  687. if(page==null){
  688. return ApiUtil.getRespJSON(-10000, "page 必传").toString();
  689. }
  690. if(pageSize==null){
  691. return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
  692. }
  693. OrgArticleVo vo = new OrgArticleVo();
  694. vo.setFirstLevelCategoryId(firstLevelCategoryId);
  695. vo.setSecondLevelCategoryId(secondLevelCategoryId);
  696. vo.setStartTime(insertTimeStart);
  697. vo.setEndTime(insertTimeEnd);
  698. vo.setOperatorRoleCode(currentUserRole);
  699. vo.setArticleTitle(articleTitle);
  700. vo.setOperatorRoleLevel(currentUserRoleLevel);
  701. vo.setIsAuthentication(isAuthentication);
  702. JSONArray array = new JSONArray();
  703. try {
  704. JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
  705. com.common.json.JSONObject result = dao.authenArticlePCList(vo, page, pageSize);
  706. // array.addAll(list);
  707. // int count = dao.queryArticlePcListCount(vo);
  708. // rv.put("Result", array);
  709. // rv.put("Count", count);
  710. rv.put("aaData", result.get("result").toString());
  711. rv.put("iTotalDisplayRecords", result.get("totalProperty"));
  712. rv.put("iTotalRecords", result.get("totalProperty"));
  713. rv.put("sEcho", sEcho);
  714. // System.out.printf("article:"+rv.toString());
  715. return rv.toString();
  716. }catch (SQLException e) {
  717. e.printStackTrace();
  718. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  719. }
  720. }
  721. /**
  722. * 修改文章
  723. * @param im
  724. * @return
  725. * @throws Exception
  726. */
  727. // public String editArticle(InterfaceMessage im) throws Exception {
  728. //
  729. // JSONObject json = JSONObject.fromObject(im.getParam());
  730. // String articleid = StringUtil.isEmpty(json.get("articleid")) ? null : json.getString("articleid");//文章id
  731. // String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章id
  732. //
  733. // String articleType = StringUtil.isEmpty(json.get("articleType")) ? null : json.getString("articleType");//文章id
  734. // String remark = StringUtil.isEmpty(json.get("remark")) ? null : json.getString("remark");//文章id
  735. // Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");//文章id
  736. // Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章id
  737. // String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//文章id
  738. // String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//文章id
  739. // String newUrl = StringUtil.isEmpty(json.get("newUrl")) ? null : json.getString("newUrl");//文章id
  740. // String userName = StringUtil.isEmpty(json.get("userName")) ? null : json.getString("userName");//文章id
  741. // String userid = StringUtil.isEmpty(json.get("userid")) ? null : json.getString("userid");//文章id
  742. // String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");//文章id
  743. // String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");//文章id
  744. //
  745. // Timestamp nowTime = DateOper.getNowDateTime();
  746. // OrgArticleVo orgArticleVo = new OrgArticleVo();
  747. // orgArticleVo.setArticleId(articleid);
  748. // orgArticleVo.setArticleType(articleType);
  749. // orgArticleVo.setArticleTitle(articleTitle);
  750. // orgArticleVo.setArticleContent(remark);
  751. // orgArticleVo.setUpdateTime(nowTime);
  752. // orgArticleVo.setArticleState(articleState);
  753. // orgArticleVo.setArticlelevel(articlelevel);
  754. // orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
  755. // orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
  756. // orgArticleVo.setArticleCover(newUrl);
  757. // orgArticleVo.setOperatorName(userName);
  758. // orgArticleVo.setOperatorId(userid);
  759. // orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
  760. // orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
  761. // orgArticleVo.setLastOperatorId(userid);
  762. // orgArticleVo.setLastOperatorName(userName);
  763. // return null;
  764. // }
  765. /**
  766. * 认证管理
  767. * @param im
  768. * @return
  769. * @throws Exception
  770. */
  771. public String authenticationArticle(InterfaceMessage im) throws Exception {
  772. JSONObject json = JSONObject.fromObject(im.getParam());
  773. String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");//文章id
  774. Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否认证过
  775. String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//文章一级分类
  776. String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");//文章一级分类名称
  777. String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//文章二级分类
  778. String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");//文章二级分类名称
  779. OrgArticleVo orgArticleVo = new OrgArticleVo();
  780. orgArticleVo.setArticleId(articleId);
  781. orgArticleVo.setIsAuthentication(isAuthentication);
  782. if(!StringUtil.isEmpty(firstLevelCategoryId)){
  783. orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
  784. }
  785. if(!StringUtil.isEmpty(firstLevelCategoryName)){
  786. orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
  787. }
  788. if(!StringUtil.isEmpty(secondLevelCategoryId)){
  789. orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
  790. }
  791. if(!StringUtil.isEmpty(secondLevelCategoryName)){
  792. orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
  793. }
  794. net.sf.json.JSONObject jsonObject = articlePcDao.editArticle(orgArticleVo);
  795. return jsonObject.toString();
  796. }
  797. /**
  798. * 删除文章
  799. * @param im
  800. * @return
  801. * @throws Exception
  802. */
  803. public String removeArticle(InterfaceMessage im) throws Exception {
  804. JSONObject json = JSONObject.fromObject(im.getParam());
  805. String ids = StringUtil.isEmpty(json.get("ids")) ? null : json.getString("ids");//文章id
  806. if(!StringUtils.isNotEmpty(ids)){
  807. return ApiUtil.getRespJSON(-14444, "ids必传").toString();
  808. }
  809. Timestamp nowTime = DateOper.getNowDateTime();
  810. String[] idsArr = ids.split(",");
  811. Integer code = null;
  812. for (int i = 0; i < idsArr.length; i++) {
  813. try {
  814. // 参数赋值
  815. OrgArticleVo orgArticleVo = new OrgArticleVo();
  816. orgArticleVo.setArticleId(idsArr[i]);
  817. orgArticleVo.setArticleState(0);
  818. orgArticleVo.setUpdateTime(nowTime);
  819. // 修改
  820. articlePcDao.removeArticle(orgArticleVo);
  821. } catch (Exception e) {
  822. e.printStackTrace();
  823. return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
  824. }
  825. }
  826. return ApiUtil.getRespJSON(10000, "删除成功").toString();
  827. }
  828. }