|  | @ -1,8 +1,12 @@
 | 
	
		
			
				|  |  | package com.yihu.jk.api;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.sql.SQLException;
 | 
	
		
			
				|  |  | import java.sql.Timestamp;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.coreframework.remoting.standard.DateOper;
 | 
	
		
			
				|  |  | import com.yihu.jk.vo.Article;
 | 
	
		
			
				|  |  | import com.yihu.jk.vo.OrgArticleVo;
 | 
	
		
			
				|  |  | import net.sf.json.JSONArray;
 | 
	
		
			
				|  |  | import net.sf.json.JSONObject;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -472,4 +476,137 @@ public class ArticleApi {
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/************************************************* new ************************************************************/
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 添加文章
 | 
	
		
			
				|  |  | 	 * @param im
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 * @throws JSONException
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public String saveArticle(InterfaceMessage im) throws JSONException {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		JSONObject json = JSONObject.fromObject(im.getParam());
 | 
	
		
			
				|  |  | 		String userCode = StringUtil.isEmpty(json.get("userCode")) ? null : json.getString("userCode");
 | 
	
		
			
				|  |  | 		if (StringUtil.isEmpty(userCode)) {
 | 
	
		
			
				|  |  | 			return ApiUtil.getRespJSON(-10000, "userCode 必传").toString();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		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	articleTitle = StringUtil.isEmpty(json.get("articleTitle")) ? null : json.getString("articleTitle");//标题
 | 
	
		
			
				|  |  | 		String	articleType = StringUtil.isEmpty(json.get("articleType")) ? null : json.getString("articleType");//类型
 | 
	
		
			
				|  |  | 		Integer	articlelevel = StringUtil.isEmpty(json.get("articlelevel")) ? null : json.getInt("articlelevel");//文章级别
 | 
	
		
			
				|  |  | 		String	secondLevelCategoryId = StringUtil.isEmpty(json.get("secondLevelCategoryId")) ? null : json.getString("secondLevelCategoryId");//二级分类id
 | 
	
		
			
				|  |  | 		String	secondLevelCategoryName = StringUtil.isEmpty(json.get("secondLevelCategoryName")) ? null : json.getString("secondLevelCategoryName");// 二级分类名称
 | 
	
		
			
				|  |  | 		String	firstLevelCategoryId = StringUtil.isEmpty(json.get("firstLevelCategoryId")) ? null : json.getString("firstLevelCategoryId");//一级分类id
 | 
	
		
			
				|  |  | 		String	firstLevelCategoryName = StringUtil.isEmpty(json.get("firstLevelCategoryName")) ? null : json.getString("firstLevelCategoryName");// 一级分类名称
 | 
	
		
			
				|  |  | 		String	content = StringUtil.isEmpty(json.get("content")) ? null : json.getString("content");//内容
 | 
	
		
			
				|  |  | 		String	newUrl = StringUtil.isEmpty(json.get("newUrl")) ? null : json.getString("newUrl");//封面图片地址
 | 
	
		
			
				|  |  | 		String	operatorRoleCode = StringUtil.isEmpty(json.get("operatorRoleCode")) ? null : json.getString("operatorRoleCode");//操作人角色code
 | 
	
		
			
				|  |  | 		String	opertorRoleLevel = StringUtil.isEmpty(json.get("opertorRoleLevel")) ? null : json.getString("opertorRoleLevel");//操作人角色级别
 | 
	
		
			
				|  |  | 		Integer	userScope = StringUtil.isEmpty(json.get("userScope")) ? null : json.getInt("userScope");//使用范围(1、全市使用,2、全区使用,3、全社区使用)
 | 
	
		
			
				|  |  | 		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
 | 
	
		
			
				|  |  | 		Timestamp nowTime = DateOper.getNowDateTime();//插入和更新时间一样
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		OrgArticleVo orgArticleVo = new OrgArticleVo();
 | 
	
		
			
				|  |  | 		String articleId=StringUtil.createUUID();
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleId(articleId);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleOrder(99);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleType(articleType);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleTitle(articleTitle);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleContent(content);
 | 
	
		
			
				|  |  | 		orgArticleVo.setInsertTime(nowTime);
 | 
	
		
			
				|  |  | 		orgArticleVo.setUpdateTime(nowTime);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleState(1);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticlelevel(articlelevel);
 | 
	
		
			
				|  |  | 		orgArticleVo.setSecondLevelCategoryId(secondLevelCategoryId);
 | 
	
		
			
				|  |  | 		orgArticleVo.setFirstLevelCategoryId(firstLevelCategoryId);
 | 
	
		
			
				|  |  | 		orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleCover(newUrl);
 | 
	
		
			
				|  |  | 		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.setUserScope(userScope);
 | 
	
		
			
				|  |  | 		orgArticleVo.setIsAuthentication(isAuthentication);
 | 
	
		
			
				|  |  | 		orgArticleVo.setAuthentication(authentication);
 | 
	
		
			
				|  |  | 		orgArticleVo.setAuthenticationId(authenticationId);
 | 
	
		
			
				|  |  | 		if ("".equals(orgName)&&orgName==null){
 | 
	
		
			
				|  |  | 			orgName = "无";
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		orgArticleVo.setOrgName(orgName);
 | 
	
		
			
				|  |  | 		orgArticleVo.setArticleSource(orgName);
 | 
	
		
			
				|  |  | 		orgArticleVo.setFirstLevelCategoryName(firstLevelCategoryName);
 | 
	
		
			
				|  |  | 		orgArticleVo.setSecondLevelCategoryName(secondLevelCategoryName);
 | 
	
		
			
				|  |  | 		return dao.saveArticle(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
 | 
	
		
			
				|  |  | 		boolean  isManage = StringUtil.isEmpty(json.get("isManage")) ? false : json.getBoolean("isManage");//是否为管理员
 | 
	
		
			
				|  |  | 		String  currentUserRole = StringUtil.isEmpty(json.get("currentUserRole")) ? null : json.getString("currentUserRole");//当前登录的角色
 | 
	
		
			
				|  |  | 		String  currentUserRoleLevel = StringUtil.isEmpty(json.get("currentUserRoleLevel")) ? null : json.getString("currentUserRoleLevel");//当前登录的角色级别
 | 
	
		
			
				|  |  | 		Integer	page = 0;
 | 
	
		
			
				|  |  | 		Integer	pageSize = 0;
 | 
	
		
			
				|  |  | 		if(!StringUtil.isEmpty(json.get("page"))){
 | 
	
		
			
				|  |  | 			page = json.getInt("page");
 | 
	
		
			
				|  |  | 		}else{
 | 
	
		
			
				|  |  | 			return ApiUtil.getRespJSON(-10000, "page 必传").toString();
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		if(!StringUtil.isEmpty(json.get("pageSize"))){
 | 
	
		
			
				|  |  | 			pageSize = json.getInt("pageSize");
 | 
	
		
			
				|  |  | 		}else{
 | 
	
		
			
				|  |  | 			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);
 | 
	
		
			
				|  |  | 		vo.setOperatorId(userCode);
 | 
	
		
			
				|  |  | 		vo.setOperatorRoleCode(currentUserRole);
 | 
	
		
			
				|  |  | 		vo.setArticleTitle(articleTitle);
 | 
	
		
			
				|  |  | 		vo.setOperatorRoleLevel(currentUserRoleLevel);
 | 
	
		
			
				|  |  | 		if(!isManage){
 | 
	
		
			
				|  |  | 			vo.setIsAuthentication(1);
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  | 		try {
 | 
	
		
			
				|  |  | 			JSONObject rv = ApiUtil.getRespJSON(10000, "成功");
 | 
	
		
			
				|  |  | 			List<Article> list = dao.queryArticlePcList(vo, page, pageSize);
 | 
	
		
			
				|  |  | 			array.addAll(list);
 | 
	
		
			
				|  |  | 			Integer count = dao.queryArticlePcListCount(vo);
 | 
	
		
			
				|  |  | 			rv.put("Result", array);
 | 
	
		
			
				|  |  | 			rv.put("Count", count);
 | 
	
		
			
				|  |  | 		}catch (SQLException e) {
 | 
	
		
			
				|  |  | 			e.printStackTrace();
 | 
	
		
			
				|  |  | 			return ApiUtil.getRespJSON(-14444, "获取数据异常:" + e.getMessage()).toString();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		return array.toString();
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | }
 |