123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891 |
- package com.yihu.jk.api;
- import com.common.json.JSONException;
- import com.coreframework.db.DB;
- import com.coreframework.remoting.standard.DateOper;
- import com.coreframework.util.AppConfig;
- import com.yihu.jk.dao.ArticleDao;
- import com.yihu.jk.dao.ArticlePcDao;
- import com.yihu.jk.utils.ApiUtil;
- import com.yihu.jk.utils.StringUtil;
- import com.yihu.jk.vo.Article;
- import com.yihu.jk.vo.ArticleStatistic;
- import com.yihu.jk.vo.OrgArticleVo;
- import com.yihu.wsgw.api.InterfaceMessage;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.log4j.Logger;
- import java.sql.SQLException;
- import java.sql.Timestamp;
- import java.util.List;
- public class ArticleApi {
- private static ArticleDao dao = new ArticleDao();
- private static ArticlePcDao articlePcDao = new ArticlePcDao();
- static Logger log = Logger.getLogger(ArticleApi.class.getName());
- /**
- * 查询文章列表 返回(文章统计,文章相关字段
- *
- * @param im
- * @return
- * @throws JSONException
- */
- public String getArticalList(InterfaceMessage im) throws JSONException {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
- Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
- String orgId = StringUtil.isEmpty(json.get("orgId")) ? null : json.getString("orgId");
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
- String startTime = StringUtil.isEmpty(json.get("startTime")) ? null : json.getString("startTime");
- String endTime = StringUtil.isEmpty(json.get("endTime")) ? null : json.getString("endTime");
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
- .getString("firstLevelCategoryId");
- Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
- ArticleStatistic vo = new ArticleStatistic();
- vo.setArticleId(articleId);
- vo.setArticleState(articleState);
- vo.setArticleTitle(articleTitle);
- vo.setStartTime(startTime);
- vo.setEndTime(endTime);
- vo.setOrgId(orgId);
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- JSONArray array = new JSONArray();
- try {
- List<ArticleStatistic> result = dao.getArticleList(vo, pageIndex, pageSize);
- JSONObject jsonObj = new JSONObject();
- if (result.size() > 0) {
- for (ArticleStatistic vbo : result) {
- jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
- jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
- jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
- jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
- jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
- jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
- jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
- jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
- jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
- jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
- jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
- jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
- jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
- jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
- jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
- jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
- jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
- jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
- jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
- jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
- jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
- jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
- array.add(jsonObj);
- }
- }
- int count = dao.getArticleListCount(vo);
- rv.put("Result", array);
- rv.put("Count", count);
- return rv.toString();
- } catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * // 获取文章收藏列表
- *
- * @param im
- * @return
- * @throws JSONException
- */
- public String getCollectionArticalList(InterfaceMessage im) throws JSONException {
- JSONObject json = JSONObject.fromObject(im.getParam());
- Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
- .getString("firstLevelCategoryId");
- Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
- String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
- int userType = StringUtil.isEmpty(json.get("userType")) ? 2 : json.getInt("userType");// 1医生
- boolean myArticle = StringUtil.isEmpty(json.get("myArticle")) ? false : json.getBoolean("myArticle");
- if (StringUtil.isEmpty(userId)) {
- return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
- }
- ArticleStatistic vo = new ArticleStatistic();
- vo.setArticleState(articleState);
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- vo.setUserId(userId);
- vo.setUserType(userType);
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- JSONArray array = new JSONArray();
- try {
- List<ArticleStatistic> result = dao.getArticleCollectionArticleList(vo, pageIndex, pageSize,myArticle);
- JSONObject jsonObj = new JSONObject();
- if (result.size() > 0) {
- for (ArticleStatistic vbo : result) {
- jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
- jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
- jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
- jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
- jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
- jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
- jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
- jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
- jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
- jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
- jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
- jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
- jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
- jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
- jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
- jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
- jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
- jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
- jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
- jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
- jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
- jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
- jsonObj.put("articleContent",StringUtil.getJSONValue(vbo.getArticleContent()));
- array.add(jsonObj);
- }
- }
- int count = dao.getArticleCollectionArticleListCount(vo);
- rv.put("Result", array);
- rv.put("Count", count);
- return rv.toString();
- } catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * 根据文章ID 获取文章详情
- *
- * @param im
- * @return
- * @throws JSONException
- */
- public String getArticalById(InterfaceMessage im) throws JSONException {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
- String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
- Integer userType = StringUtil.isEmpty(json.get("userType")) ? 0 : json.getInt("userType");
- if (StringUtil.isEmpty(articleId)) {
- return ApiUtil.getRespJSON(-10000, "articleId 必传").toString();
- }
- ArticleStatistic vo = new ArticleStatistic();
- vo.setArticleId(articleId);
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- JSONArray array = new JSONArray();
- try {
- List<ArticleStatistic> result = dao.getArticleById(vo);
- JSONObject jsonObj = new JSONObject();
- if (result.size() > 0) {
- for (ArticleStatistic vbo : result) {
- jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
- jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
- jsonObj.put("articleContent", StringUtil.getJSONValue(vbo.getArticleContent()));
- jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
- jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
- jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
- jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
- jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
- jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
- jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
- jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
- jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
- jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
- jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
- jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
- jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
- jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
- jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
- jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
- jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
- jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
- jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
- jsonObj.put("collectionNumber", StringUtil.getJSONValue(vbo.getCollectionNumber()));
- jsonObj.put("deptName", StringUtil.getJSONValue(vbo.getDeptName()));
- jsonObj.put("titleLevel", StringUtil.getJSONValue(vbo.getTitleLevel()));
- jsonObj.put("operatorImg", StringUtil.getJSONValue(vbo.getOperatorImg()));
- jsonObj.put("userScope", StringUtil.getJSONValue(vbo.getUserScope()));
- jsonObj.put("articleCategoryId", StringUtil.getJSONValue(vbo.getArticleCategoryId()));
- jsonObj.put("articleCategoryName", StringUtil.getJSONValue(vbo.getArticleCategoryName()));
- jsonObj.put("pushNumber", StringUtil.getJSONValue(vbo.getPushNumber()));
- if (StringUtil.isNotEmpty(userId)) {
- vo.setUserId(userId);
- vo.setUserType(userType);
- int pointNumberCount = dao.pointNumberCount(vo);
- int collectionNumberCount = dao.collectionNumberCount(vo);
- jsonObj.put("pointNumberCount", pointNumberCount);
- jsonObj.put("collectionNumberCount", collectionNumberCount);
- }
- array.add(jsonObj);
- }
- }
- rv.put("Result", array);
- return rv.toString();
- } catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * // 更新统计表数据
- *
- * @param articleId
- * @param behaviorAction
- * @param number
- */
- public static void updateArticleStatistic(String articleId, int behaviorAction, int number) {
- try {
- dao.insertArticleStatistic(articleId);
- // 浏览数 点赞数 评论数 分享数 收藏数
- if (behaviorAction == 1) {// 点赞
- dao.updateArticleStatistic(articleId, "PointNumber", behaviorAction, number);
- } else if (behaviorAction == 2) {// 转发
- } else if (behaviorAction == 3) {// 分享
- dao.updateArticleStatistic(articleId, "ShareNumber", behaviorAction, number);
- } else if (behaviorAction == 4) {// 浏览
- dao.updateArticleStatistic(articleId, "BrowseNumber", behaviorAction, number);
- } else if (behaviorAction == 5) {// 评论
- dao.updateArticleStatistic(articleId, "CommentNumber", behaviorAction, number);
- } else if (behaviorAction == 6) {// 收藏
- dao.updateArticleStatistic(articleId, "CollectionNumber", behaviorAction, number);
- }else if (behaviorAction == 7) {// 发送
- dao.updateArticleStatistic(articleId, "PushNumber", behaviorAction, number);
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- log.error(e.getMessage() + "参数:" + articleId + behaviorAction);
- }
- }
- public static void main(String[] args) throws SQLException {
- initDB();
- // initArticleStatistic();
- String articleId = "10C2222122";
- int behaviorAction = 1;
- int number = 1;
- updateArticleStatistic(articleId, behaviorAction, number);
- }
- public static void initDB() {
- String DB_Alias = AppConfig.getValue("DB.Alias");
- String DB_DatabaseName = AppConfig.getValue("DB.DatabaseName");
- String DB_IP = AppConfig.getValue("DB.IP");
- String DB_UserName = AppConfig.getValue("DB.UserName");
- String DB_Password = AppConfig.getValue("DB.Password");
- String DB_Port = AppConfig.getValue("DB.Port");
- DB.me().addDataSourceMySQL(DB_Alias, DB_DatabaseName, DB_IP, Integer.parseInt(DB_Port), DB_UserName,
- DB_Password);
- }
- /**
- * // 初始化统计数据
- *
- * @throws SQLException
- */
- public static void initArticleStatistic() throws SQLException {
- dao.deleteArticleStatistic();// 删除所有统计数据
- ArticleStatistic vo = new ArticleStatistic();
- List<ArticleStatistic> result1 = dao.getArticleList(vo, 0, 100000000);// 获取全部文章ID
- if (result1.size() > 0) {
- for (ArticleStatistic vbo : result1) {
- List<ArticleStatistic> result = dao.queryArticleStatistic(vbo.getArticleId());
- ArticleStatistic vo1 = result.get(0);
- vo1.setArticleId(vbo.getArticleId());
- dao.insertArticleInitStatistic(vo1);// 插入统计数据
- }
- }
- }
- /**
- * // 初始化统计数据
- *
- * @throws SQLException
- */
- public String insertArticleStatistic(InterfaceMessage im) throws Exception {
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- List<Article> result1 = dao.getAllArticle();
- if (result1.size() > 0) {
- for (Article vbo : result1) {
- dao.insertArticleStatistic(vbo.getArticleId());
- }
- }
- return rv.toString();
- }
- /**
- * 医生端查询文章列表
- *
- * @param im
- * @return
- * @throws JSONException
- */
- public String getDoctorArticalList(InterfaceMessage im) throws JSONException {
- JSONObject json = JSONObject.fromObject(im.getParam());
- Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
- .getString("firstLevelCategoryId");
- Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
- String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
- ArticleStatistic vo = new ArticleStatistic();
- vo.setArticleState(articleState);
- vo.setArticleTitle(articleTitle);
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- if (StringUtil.isEmpty(userId)) {
- return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
- }
- if (StringUtil.isEmpty(articleState)) {
- return ApiUtil.getRespJSON(-10000, "articleState 必传").toString();
- }
- vo.setUserId(userId);
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- JSONArray array = new JSONArray();
- try {
- List<ArticleStatistic> result = dao.getDoctorArticleList(vo, pageIndex, pageSize);
- JSONObject jsonObj = new JSONObject();
- if (result.size() > 0) {
- for (ArticleStatistic vbo : result) {
- jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
- jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
- jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
- jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
- jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
- jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
- jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
- jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
- jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
- jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
- jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
- jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
- jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
- jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
- jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
- jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
- jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
- jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
- jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
- jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
- jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
- array.add(jsonObj);
- }
- }
- int count = dao.getDoctorArticleListCount(vo);
- rv.put("Result", array);
- rv.put("Count", count);
- return rv.toString();
- } catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * 医生 端根据用户ID 查询发表文章
- *
- * @param im
- * @return
- * @throws JSONException
- */
- public String getDoctorArticalByUserId(InterfaceMessage im) throws JSONException {
- JSONObject json = JSONObject.fromObject(im.getParam());
- Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json
- .getString("firstLevelCategoryId");
- Integer pageIndex = StringUtil.isEmpty(json.get("pageIndex")) ? 0 : json.getInt("pageIndex");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? 5 : json.getInt("pageSize");
- String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
- ArticleStatistic vo = new ArticleStatistic();
- vo.setArticleState(articleState);
- vo.setArticleTitle(articleTitle);
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- if (StringUtil.isEmpty(userId)) {
- return ApiUtil.getRespJSON(-10000, "userId 必传").toString();
- }
- if (StringUtil.isEmpty(articleState)) {
- return ApiUtil.getRespJSON(-10000, "articleState 必传").toString();
- }
- vo.setUserId(userId);
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- JSONArray array = new JSONArray();
- try {
- List<ArticleStatistic> result = dao.getDoctorArticalByUserId(vo, pageIndex, pageSize);
- JSONObject jsonObj = new JSONObject();
- if (result.size() > 0) {
- for (ArticleStatistic vbo : result) {
- jsonObj.put("articleId", StringUtil.getJSONValue(vbo.getArticleId()));
- jsonObj.put("articleTitle", StringUtil.getJSONValue(vbo.getArticleTitle()));
- jsonObj.put("articleOrder", StringUtil.getJSONValue(vbo.getArticleOrder()));
- jsonObj.put("articleState", StringUtil.getJSONValue(vbo.getArticleState()));
- jsonObj.put("orgName", StringUtil.getJSONValue(vbo.getOrgName()));
- jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
- jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
- jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
- jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
- jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));
- jsonObj.put("firstLevelCategoryId", StringUtil.getJSONValue(vbo.getFirstLevelCategoryId()));
- jsonObj.put("firstLevelCategoryName", StringUtil.getJSONValue(vbo.getFirstLevelCategoryName()));
- jsonObj.put("secondLevelCategoryId", StringUtil.getJSONValue(vbo.getSecondLevelCategoryId()));
- jsonObj.put("secondLevelCategoryName", StringUtil.getJSONValue(vbo.getSecondLevelCategoryName()));
- jsonObj.put("authentication", StringUtil.getJSONValue(vbo.getAuthentication()));
- jsonObj.put("authenticationId", StringUtil.getJSONValue(vbo.getAuthenticationId()));
- jsonObj.put("articleType", StringUtil.getJSONValue(vbo.getArticleType()));
- jsonObj.put("isAuthentication", StringUtil.getJSONValue(vbo.getIsAuthentication()));
- jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
- jsonObj.put("browseNumber", StringUtil.getJSONValue(vbo.getBrowseNumber()));
- jsonObj.put("pointNumber", StringUtil.getJSONValue(vbo.getPointNumber()));
- jsonObj.put("commentNumber", StringUtil.getJSONValue(vbo.getCommentNumber()));
- jsonObj.put("shareNumber", StringUtil.getJSONValue(vbo.getShareNumber()));
- array.add(jsonObj);
- }
- }
- int count = dao.getDoctorArticalByUserIdCount(vo);
- rv.put("Result", array);
- rv.put("Count", count);
- return rv.toString();
- } catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /************************************************* new ************************************************************/
- /**
- * 添加、编辑文章
- * @param im
- * @return
- * @throws JSONException
- */
- public String saveArticle(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
- String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");// 一级分类名称
- String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
- String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");// 二级分类名称
- String content = StringUtil.isEmpty(json.get("content")) ? null : json.getString("content");//内容
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//标题
- Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
- Integer userScope = StringUtil.isEmpty(json.get("userScope")) ? null : json.getInt("userScope");//使用范围(1、全市使用,2、全区使用,3、全社区使用)
- String newUrl = StringUtil.isEmpty(json.get("newUrl")) ? null : json.getString("newUrl");//封面图片地址
- Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
- OrgArticleVo orgArticleVo = new OrgArticleVo();
- orgArticleVo.setArticleTitle(articleTitle);
- orgArticleVo.setArticleContent(content);
- orgArticleVo.setArticlelevel(articlelevel);
- orgArticleVo.setUserScope(userScope);
- orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
- orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
- orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
- orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
- orgArticleVo.setArticleCover(newUrl);
- Timestamp nowTime = DateOper.getNowDateTime();//插入和更新时间一样
- orgArticleVo.setUpdateTime(nowTime);
- if(StringUtil.isEmpty(articleId)) {
- String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");
- String orgName = StringUtil.isEmpty(json.get("orgName")) ? null : json.getString("orgName");//组织名称
- String deptName = StringUtil.isEmpty(json.get("deptName")) ? null : json.getString("deptName");//科室名称
- String levelName = StringUtil.isEmpty(json.get("levelName")) ? null : json.getString("levelName");//职称
- String photo = StringUtil.isEmpty(json.get("photo")) ? null : json.getString("photo");//头像
- String orgId = StringUtil.isEmpty(json.get("orgId")) ? null : json.getString("orgId");//组织
- String userName = StringUtil.isEmpty(json.get("userName")) ? null : json.getString("userName");//登录名称
- String articleType = StringUtil.isEmpty(json.get("articleType")) ? null : json.getString("articleType");//类型
- String operatorRoleCode = StringUtil.isEmpty(json.get("operatorRoleCode")) ? null : json.getString("operatorRoleCode");//操作人角色code
- String opertorRoleLevel = StringUtil.isEmpty(json.get("opertorRoleLevel")) ? null : json.getString("opertorRoleLevel");//操作人角色级别
- Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否认证
- String authentication = StringUtil.isEmpty(json.get("authentication")) ? null : json.getString("authentication");//认证单位
- String authenticationId = StringUtil.isEmpty(json.get("authenticationId")) ? null : json.getString("authenticationId");//认证单位ID
- articleId = StringUtil.createUUID();
- orgArticleVo.setArticleId(articleId);
- orgArticleVo.setArticleOrder(99);
- orgArticleVo.setArticleType(articleType);
- orgArticleVo.setInsertTime(nowTime);
- orgArticleVo.setArticleState(1);
- orgArticleVo.setDeptName(deptName);
- orgArticleVo.setTitleLevel(levelName);
- orgArticleVo.setOperatorImg(photo);
- orgArticleVo.setOrgId(orgId);
- orgArticleVo.setOperatorName(userName);
- orgArticleVo.setOperatorId(userCode);
- orgArticleVo.setLastOperatorId(userCode);
- orgArticleVo.setLastOperatorName(userName);
- orgArticleVo.setOperatorRoleCode(operatorRoleCode);
- orgArticleVo.setOperatorRoleLevel(opertorRoleLevel);
- orgArticleVo.setIsAuthentication(isAuthentication);
- orgArticleVo.setAuthentication(authentication);
- orgArticleVo.setAuthenticationId(authenticationId);
- orgArticleVo.setRoleType(roleType);
- if ("".equals(orgName) || orgName == null) {
- orgName = "无";
- }
- orgArticleVo.setOrgName(orgName);
- orgArticleVo.setArticleSource(orgName);
- //新增文章时 保存分享数,阅读数等数据
- // ArticleStatistic statistic = new ArticleStatistic();
- // statistic.setBrowseNumber(0);
- // statistic.setPointNumber(0);
- // statistic.setCommentNumber(0);
- // statistic.setShareNumber(0);
- // statistic.setCollectionNumber(0);
- // statistic.setArticleId(articleId);
- // dao.insertArticleInitStatistic(statistic);
- dao.insertArticleStatistic(articleId);
- return dao.saveArticle(orgArticleVo).toString();
- }else{
- orgArticleVo.setArticleId(articleId);
- return dao.updateArticle(orgArticleVo).toString();
- }
- }
- /************************************************ PC *************************************************************/
- public String queryArticlePcList(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
- String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
- String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
- String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
- Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
- String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");//操作人id
- Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
- String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
- String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
- Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
- Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
- Boolean isMyArticle = StringUtil.isEmpty(json.get("isMyArticle")) ? false : json.getBoolean("isMyArticle");
- Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
- if(page==null){
- return ApiUtil.getRespJSON(-10000, "page 必传").toString();
- }
- if(pageSize==null){
- return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
- }
- OrgArticleVo vo = new OrgArticleVo();
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- vo.setSecondLevelCategoryId(secondLevelCategoryId);
- vo.setStartTime(insertTimeStart);
- vo.setEndTime(insertTimeEnd);
- vo.setArticlelevel(articlelevel);
- if(isMyArticle){
- vo.setOperatorId(userCode);
- }
- vo.setOperatorRoleCode(currentUserRole);
- vo.setArticleTitle(articleTitle);
- vo.setOperatorRoleLevel(currentUserRoleLevel);
- vo.setIsAuthentication(isAuthentication);
- vo.setRoleType(roleType);
- // JSONArray array = new JSONArray();
- System.out.printf("OrgArticleVo参数:"+vo.toString());
- try {
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- com.common.json.JSONObject result = dao.queryArticlePcList(vo, page, pageSize,userCode,isMyArticle);
- // array.addAll(list);
- // int count = dao.queryArticlePcListCount(vo);
- // rv.put("Result", array);
- // rv.put("Count", count);
- rv.put("aaData", result.get("result").toString());
- rv.put("iTotalDisplayRecords", result.get("totalProperty"));
- rv.put("iTotalRecords", result.get("totalProperty"));
- rv.put("sEcho", sEcho);
- // System.out.printf("article:"+rv.toString());
- return rv.toString();
- }catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- public String queryArticleAPPList(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
- String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
- String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
- String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
- Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
- String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");//操作人id
- Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
- String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
- String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
- Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
- Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
- Boolean isMyArticle = StringUtil.isEmpty(json.get("isMyArticle")) ? false : json.getBoolean("isMyArticle");
- Integer roleType = StringUtil.isEmpty(json.get("roleType")) ? null : json.getInt("roleType");//1、健管师,2、管理员
- if(page==null){
- return ApiUtil.getRespJSON(-10000, "page 必传").toString();
- }
- if(pageSize==null){
- return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
- }
- OrgArticleVo vo = new OrgArticleVo();
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- vo.setSecondLevelCategoryId(secondLevelCategoryId);
- vo.setStartTime(insertTimeStart);
- vo.setEndTime(insertTimeEnd);
- vo.setArticlelevel(articlelevel);
- if(isMyArticle){
- vo.setOperatorId(userCode);
- }
- vo.setOperatorRoleCode(currentUserRole);
- vo.setArticleTitle(articleTitle);
- vo.setOperatorRoleLevel(currentUserRoleLevel);
- vo.setIsAuthentication(isAuthentication);
- vo.setRoleType(roleType);
- JSONArray array = new JSONArray();
- try {
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- List<Article> result = dao.queryArticleAPPList(vo, page, pageSize,userCode,isMyArticle);
- array.addAll(result);
- // int count = dao.queryArticlePcListCount(vo);
- // rv.put("Result", array);
- // rv.put("Count", count);
- rv.put("aaData", array);
- // rv.put("iTotalDisplayRecords", result.get("totalProperty"));
- // rv.put("iTotalRecords", result.get("totalProperty"));
- // rv.put("sEcho", sEcho);
- // System.out.printf("article:"+rv.toString());
- return rv.toString();
- }catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * 文章认证列表
- * @param im
- * @return
- * @throws Exception
- */
- public String authenArticlePCList(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
- String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
- String insertTimeStart = StringUtil.isEmpty(json.get("insertTimeStart")) ? null : json.getString("insertTimeStart");//添加时间开始
- String insertTimeEnd = StringUtil.isEmpty(json.get("insertTimeEnd")) ? null : json.getString("insertTimeEnd");//添加时间结束
- String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章标题
- Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否有权限
- String currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
- String currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
- Integer page = StringUtil.isEmpty(json.get("page")) ? null : json.getInt("page");
- Integer pageSize = StringUtil.isEmpty(json.get("pageSize")) ? null : json.getInt("pageSize");
- Integer sEcho = StringUtil.isEmpty(json.get("sEcho")) ? 0 : json.getInt("sEcho");
- if(page==null){
- return ApiUtil.getRespJSON(-10000, "page 必传").toString();
- }
- if(pageSize==null){
- return ApiUtil.getRespJSON(-10000, "pageSize 必传").toString();
- }
- OrgArticleVo vo = new OrgArticleVo();
- vo.setFirstLevelCategoryId(firstLevelCategoryId);
- vo.setSecondLevelCategoryId(secondLevelCategoryId);
- vo.setStartTime(insertTimeStart);
- vo.setEndTime(insertTimeEnd);
- vo.setOperatorRoleCode(currentUserRole);
- vo.setArticleTitle(articleTitle);
- vo.setOperatorRoleLevel(currentUserRoleLevel);
- vo.setIsAuthentication(isAuthentication);
- JSONArray array = new JSONArray();
- try {
- JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
- com.common.json.JSONObject result = dao.authenArticlePCList(vo, page, pageSize);
- // array.addAll(list);
- // int count = dao.queryArticlePcListCount(vo);
- // rv.put("Result", array);
- // rv.put("Count", count);
- rv.put("aaData", result.get("result").toString());
- rv.put("iTotalDisplayRecords", result.get("totalProperty"));
- rv.put("iTotalRecords", result.get("totalProperty"));
- rv.put("sEcho", sEcho);
- // System.out.printf("article:"+rv.toString());
- return rv.toString();
- }catch (SQLException e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- /**
- * 修改文章
- * @param im
- * @return
- * @throws Exception
- */
- // public String editArticle(InterfaceMessage im) throws Exception {
- //
- // JSONObject json = JSONObject.fromObject(im.getParam());
- // String articleid = StringUtil.isEmpty(json.get("articleid")) ? null : json.getString("articleid");//文章id
- // String articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//文章id
- //
- // String articleType = StringUtil.isEmpty(json.get("articleType")) ? null : json.getString("articleType");//文章id
- // String remark = StringUtil.isEmpty(json.get("remark")) ? null : json.getString("remark");//文章id
- // Integer articleState = StringUtil.isEmpty(json.get("articleState")) ? null : json.getInt("articleState");//文章id
- // Integer articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章id
- // String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//文章id
- // String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//文章id
- // String newUrl = StringUtil.isEmpty(json.get("newUrl")) ? null : json.getString("newUrl");//文章id
- // String userName = StringUtil.isEmpty(json.get("userName")) ? null : json.getString("userName");//文章id
- // String userid = StringUtil.isEmpty(json.get("userid")) ? null : json.getString("userid");//文章id
- // String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");//文章id
- // String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");//文章id
- //
- // Timestamp nowTime = DateOper.getNowDateTime();
- // OrgArticleVo orgArticleVo = new OrgArticleVo();
- // orgArticleVo.setArticleId(articleid);
- // orgArticleVo.setArticleType(articleType);
- // orgArticleVo.setArticleTitle(articleTitle);
- // orgArticleVo.setArticleContent(remark);
- // orgArticleVo.setUpdateTime(nowTime);
- // orgArticleVo.setArticleState(articleState);
- // orgArticleVo.setArticlelevel(articlelevel);
- // orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
- // orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
- // orgArticleVo.setArticleCover(newUrl);
- // orgArticleVo.setOperatorName(userName);
- // orgArticleVo.setOperatorId(userid);
- // orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
- // orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
- // orgArticleVo.setLastOperatorId(userid);
- // orgArticleVo.setLastOperatorName(userName);
- // return null;
- // }
- /**
- * 认证管理
- * @param im
- * @return
- * @throws Exception
- */
- public String authenticationArticle(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String articleId = StringUtil.isEmpty(json.get("articleId")) ? null : json.getString("articleId");//文章id
- Integer isAuthentication = StringUtil.isEmpty(json.get("isAuthentication")) ? null : json.getInt("isAuthentication");//是否认证过
- String firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//文章一级分类
- String firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");//文章一级分类名称
- String secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//文章二级分类
- String secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");//文章二级分类名称
- OrgArticleVo orgArticleVo = new OrgArticleVo();
- orgArticleVo.setArticleId(articleId);
- orgArticleVo.setIsAuthentication(isAuthentication);
- if(!StringUtil.isEmpty(firstLevelCategoryId)){
- orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
- }
- if(!StringUtil.isEmpty(firstLevelCategoryName)){
- orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
- }
- if(!StringUtil.isEmpty(secondLevelCategoryId)){
- orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
- }
- if(!StringUtil.isEmpty(secondLevelCategoryName)){
- orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
- }
- net.sf.json.JSONObject jsonObject = articlePcDao.editArticle(orgArticleVo);
- return jsonObject.toString();
- }
- /**
- * 删除文章
- * @param im
- * @return
- * @throws Exception
- */
- public String removeArticle(InterfaceMessage im) throws Exception {
- JSONObject json = JSONObject.fromObject(im.getParam());
- String ids = StringUtil.isEmpty(json.get("ids")) ? null : json.getString("ids");//文章id
- if(!StringUtils.isNotEmpty(ids)){
- return ApiUtil.getRespJSON(-14444, "ids必传").toString();
- }
- Timestamp nowTime = DateOper.getNowDateTime();
- String[] idsArr = ids.split(",");
- Integer code = null;
- for (int i = 0; i < idsArr.length; i++) {
- try {
- // 参数赋值
- OrgArticleVo orgArticleVo = new OrgArticleVo();
- orgArticleVo.setArticleId(idsArr[i]);
- orgArticleVo.setArticleState(0);
- orgArticleVo.setUpdateTime(nowTime);
- // 修改
- articlePcDao.removeArticle(orgArticleVo);
- } catch (Exception e) {
- e.printStackTrace();
- return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
- }
- }
- return ApiUtil.getRespJSON(10000, "删除成功").toString();
- }
- }
|