Browse Source

APP发现政策、专家相关接口开发

anderx 7 years ago
parent
commit
9a0c343e07

+ 37 - 2
src/main/java/com/goafanti/app/controller/AppDiscoveryController.java

@@ -9,9 +9,11 @@ import org.springframework.web.bind.annotation.RestController;
 import com.goafanti.achievement.service.AchievementInterestService;
 import com.goafanti.achievement.service.AchievementService;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.demand.service.DemandService;
+import com.goafanti.news.service.NewsService;
 import com.goafanti.user.service.UserIdentityService;
 
 @RestController
@@ -25,6 +27,8 @@ public class AppDiscoveryController extends BaseApiController {
 	private UserIdentityService	userIdentityService;
 	@Resource
 	private AchievementInterestService	achievementInterestService;
+	@Resource
+	private NewsService newsService;
 	
 	/**
 	 * 成果列表
@@ -88,9 +92,9 @@ public class AppDiscoveryController extends BaseApiController {
 	 * 专家列表
 	 */
 	@RequestMapping(value = "/expertsList", method = RequestMethod.GET)
-	public Result expertsList(String industry, Integer pNo, Integer pSize) {
+	public Result expertsList(String name,String industry, Integer pNo, Integer pSize) {
 		Result res = new Result();
-		res.setData(userIdentityService.expertsList(industry,  pNo,  pSize));
+		res.setData(userIdentityService.expertsList(name,industry,  pNo,  pSize));
 		return res;
 	}
 	
@@ -104,4 +108,35 @@ public class AppDiscoveryController extends BaseApiController {
 		return res;
 	}
 	
+
+	
+	/**
+	 * 政策列表
+	 */
+	@RequestMapping(value = "/listNews", method = RequestMethod.GET)
+	public Result appListNews(String param,Integer pNo,Integer pSize) {
+		Result res = new Result();
+		if (null==pNo) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"页码","页码"));
+			return res;
+		}
+		if (null==pSize) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"页显示数","页显示数"));
+			return res;
+		}
+		res.setData(newsService.appListNews( param ,pNo, pSize));
+		return res;
+	}
+	
+	/**
+	 * 政策详情
+	 */
+	@RequestMapping(value = "/newsDetail", method = RequestMethod.GET)
+	public Result expertsDetail(long id) {
+		System.out.println("111111111111");
+		Result res = new Result();
+		res.setData(newsService.findNewsDetail( id));
+		return res;
+	}
+	
 }

+ 25 - 2
src/main/java/com/goafanti/app/controller/OpenAppDiscoveryController.java

@@ -9,9 +9,11 @@ import org.springframework.web.bind.annotation.RestController;
 import com.goafanti.achievement.service.AchievementInterestService;
 import com.goafanti.achievement.service.AchievementService;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.demand.service.DemandService;
+import com.goafanti.news.service.NewsService;
 import com.goafanti.user.service.UserIdentityService;
 
 @RestController
@@ -25,6 +27,8 @@ public class OpenAppDiscoveryController extends BaseApiController {
 	private UserIdentityService	userIdentityService;
 	@Resource
 	private AchievementInterestService	achievementInterestService;
+	@Resource
+	private NewsService newsService;
 	
 	/**
 	 * 成果列表
@@ -88,9 +92,9 @@ public class OpenAppDiscoveryController extends BaseApiController {
 	 * 专家列表
 	 */
 	@RequestMapping(value = "/expertsList", method = RequestMethod.GET)
-	public Result expertsList(String industry, Integer pNo, Integer pSize) {
+	public Result expertsList(String name,String industry, Integer pNo, Integer pSize) {
 		Result res = new Result();
-		res.setData(userIdentityService.expertsList(industry,pNo,pSize));
+		res.setData(userIdentityService.expertsList(name,industry,pNo,pSize));
 		return res;
 	}
 	
@@ -103,4 +107,23 @@ public class OpenAppDiscoveryController extends BaseApiController {
 		res.setData(userIdentityService.advertising());
 		return res;
 	}
+	/**
+	 * 政策列表
+	 */
+	@RequestMapping(value = "/listNews", method = RequestMethod.GET)
+	public Result appListNews(String param,Integer pNo,Integer pSize) {
+		Result res = new Result();
+		res.setData(newsService.appListNews( param ,pNo, pSize));
+		return res;
+	}
+	
+	/**
+	 * 政策详情
+	 */
+	@RequestMapping(value = "/newsDetail", method = RequestMethod.GET)
+	public Result expertsDetail(long id) {
+		Result res = new Result();
+		res.setData(newsService.findNewsDetail( id));
+		return res;
+	}
 }

+ 1 - 1
src/main/java/com/goafanti/app/controller/OpenAppHomeController.java

@@ -12,7 +12,7 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.controller.BaseApiController;
 
 @RestController
-@RequestMapping(path = "open/app/home")
+@RequestMapping(path = "/open/app/home")
 public class OpenAppHomeController extends BaseApiController{
 	@Resource
 	private AppHomePageService	appHomePageService;

+ 1 - 1
src/main/java/com/goafanti/app/controller/OpenAppServiceController.java

@@ -20,7 +20,7 @@ import com.goafanti.user.service.UserIdentityService;
 
 
 @RestController
-@RequestMapping(path = "open/app/service", method = RequestMethod.GET)
+@RequestMapping(path = "/open/app/service", method = RequestMethod.GET)
 public class OpenAppServiceController extends BaseApiController {
 	@Resource
 	private BusinessVarietiesService	adminVarietiesService;

+ 1 - 1
src/main/java/com/goafanti/app/controller/OpenAppUserController.java

@@ -23,7 +23,7 @@ import com.goafanti.user.service.UserInterestService;
 import com.goafanti.user.service.UserService;
 
 @RestController
-@RequestMapping(path = "open/app/user", method = RequestMethod.GET)
+@RequestMapping(path = "/open/app/user", method = RequestMethod.GET)
 public class OpenAppUserController extends BaseApiController {
 	@Resource
 	private UserService userServiceImpl;

+ 41 - 0
src/main/java/com/goafanti/common/mapper/NewsMapper.xml

@@ -329,5 +329,46 @@
 	</select>
 	
 	
+	<select id="appNewsList" resultType="com.goafanti.news.bo.NewsPortalList">
+		select
+			a.id,
+			DATE_FORMAT(a.create_time,'%Y-%m-%d') as createTime,
+			a.title,
+			a.title_img as titleImg,
+			a.type,
+			a.hot,
+			a.summary,
+			a.source,
+			a.content
+		from news a
+		left join district_glossory d on a.province_id=d.id
+		where
+		a.type != 1 and a.type != 2
+		<if test="param != null">
+			and a.title like concat('%',#{param},'%')
+			or a.source like concat('%',#{param},'%')
+			or d.name like concat('%',#{param},'%')
+		</if>	
+		order by create_time desc
+		<if test="page_sql != null">
+			${page_sql}
+		</if>
+	</select>
+	
+	<select id="appNewsCount" resultType="java.lang.Integer">
+		select 
+			count(0)
+		from news a
+		left join district_glossory d on a.province_id=d.id
+		where 
+		a.type != 1 and a.type != 2
+		<if test="param != null">
+			and a.title like concat('%',#{param},'%')
+			or a.source like concat('%',#{param},'%')
+			or d.name like concat('%',#{param},'%')
+		</if>	
+	</select>
+	
+	
 	
 </mapper>

+ 6 - 0
src/main/java/com/goafanti/common/mapper/UserIdentityMapper.xml

@@ -1045,6 +1045,9 @@
 	<if test="industry != null">
         and t.industry = #{industry,jdbcType=VARCHAR}
     </if>
+    <if test="name != null">
+        and u.nickname like concat('%',#{name},'%')
+    </if>
     <if test="page_sql!=null">
         ${page_sql}
     </if>
@@ -1061,6 +1064,9 @@
     <if test="industry != null">
         and t.industry = #{industry,jdbcType=VARCHAR}
     </if>
+    <if test="name != null">
+        and u.nickname like concat('%',#{name},'%')
+    </if>
   </select>
   
   <select id="countInterest" resultType="java.lang.Integer">

+ 14 - 0
src/main/java/com/goafanti/news/service/NewsService.java

@@ -203,5 +203,19 @@ public class NewsService extends BaseMybatisDao<NewsMapper> {
 		
 		return newsMapper.portalNewsQuestion();
 	}
+	@SuppressWarnings("unchecked")
+	public Pagination<NewsPortalList> appListNews(String param,Integer pNo,Integer pSize){
+		Map<String, Object> params=new HashMap<>();
+		if (StringUtils.isNotBlank(param)) {
+			params.put("param", param);
+		}
+		if (pNo == null || pNo < 0) {
+			pNo = 1;
+		}
+		if (pSize == null || pSize < 0 || pSize > 10) {
+			pSize = 10;
+		}
+		return (Pagination<NewsPortalList>) findPage("appNewsList", "appNewsCount", params, pNo, pSize);
+	}
 	
 }

+ 1 - 1
src/main/java/com/goafanti/user/service/UserIdentityService.java

@@ -42,7 +42,7 @@ public interface UserIdentityService {
 	
 	UserIdentityBo expertsDetail(String uid);
 
-	Pagination<UserIdentityBo> expertsList(String industry, Integer pNo, Integer pSize);
+	Pagination<UserIdentityBo> expertsList(String name,String industry, Integer pNo, Integer pSize);
 
 	List<fieldGlossoryBo> industryList();
 

+ 4 - 1
src/main/java/com/goafanti/user/service/impl/UserIdentityServiceImpl.java

@@ -335,11 +335,14 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<UserIdentityBo> expertsList(String industry, Integer pNo, Integer pSize) {
+	public Pagination<UserIdentityBo> expertsList(String name,String industry, Integer pNo, Integer pSize) {
 		Map<String, Object> params = new HashMap<>();
 		if (StringUtils.isNotBlank(industry)) {
 			params.put("industry", industry);
 		}
+		if (StringUtils.isNotBlank(name)) {
+			params.put("name", name);
+		}
 		if (pNo == null || pNo < 0) {
 			pNo = 1;
 		}