Commit 8d3e4e7c authored by Quxl's avatar Quxl

x

parent 561a66c1
...@@ -17,6 +17,6 @@ public interface NewsService { ...@@ -17,6 +17,6 @@ public interface NewsService {
Map<String, Object> queryById(Integer id); Map<String, Object> queryById(Integer id);
List<Map<String, Object>> queryListForUser(Integer uid, Page page); List<Map<String, Object>> queryListForUser(Integer uid, Integer gid, Page page);
} }
...@@ -18,7 +18,8 @@ public class NewsServiceImpl implements NewsService { ...@@ -18,7 +18,8 @@ public class NewsServiceImpl implements NewsService {
@Override @Override
public List<Map<String, Object>> queryList(Page page) { public List<Map<String, Object>> queryList(Page page) {
return jdbcTemplate.limit("select ns.*, a.realname creator_name from fc_news ns left join fc_admin a on a.adminid = ns.creator", page); String sql = "select ns.*, a.realname creator_name from fc_news ns left join fc_admin a on a.adminid = ns.creator order by ns.create_time desc";
return jdbcTemplate.limit(sql, page);
} }
@Override @Override
...@@ -42,9 +43,9 @@ public class NewsServiceImpl implements NewsService { ...@@ -42,9 +43,9 @@ public class NewsServiceImpl implements NewsService {
} }
@Override @Override
public List<Map<String, Object>> queryListForUser(Integer uid, Page page) { public List<Map<String, Object>> queryListForUser(Integer uid, Integer gid, Page page) {
// TODO Auto-generated method stub String sql = "select n.*, ns.sender, ns.send_time, nr.user_id, nr.read_time from fc_news n left join (select user_id, news_id, max(read_time) read_time from fc_news_read where user_id = ? group by user_id, news_id) nr on nr.news_id = n.id, fc_news_sender ns where n.id = ns.news_id and (ns.user_id = ? or ns.user_group_id = ?)";
return null; return jdbcTemplate.limit(sql, page, uid, uid, gid);
} }
} }
...@@ -15,7 +15,7 @@ import com.egolm.common.jdbc.Page; ...@@ -15,7 +15,7 @@ import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService; import com.egolm.film.api.service.NewsService;
import com.egolm.film.api.service.UserTokenService; import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.bean.Fc_news_read; import com.egolm.film.bean.Fc_news_read;
import com.egolm.film.model.LoginToken; import com.egolm.film.bean.Fc_user;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -40,9 +40,10 @@ public class UserNewsController { ...@@ -40,9 +40,10 @@ public class UserNewsController {
index = index == null ? 1 : index; index = index == null ? 1 : index;
limit = limit == null ? 20 : limit; limit = limit == null ? 20 : limit;
Page page = new Page(index, limit); Page page = new Page(index, limit);
LoginToken token = tokenService.getToken(); Fc_user user = (Fc_user)tokenService.getTokenObj();
Integer uid = ((Number)token.getId()).intValue(); Integer uid = user.getUid();
List<Map<String, Object>> list = service.queryListForUser(uid, page); Integer gid = user.getGroup_id();
List<Map<String, Object>> list = service.queryListForUser(uid, gid, page);
return Rjx.jsonOk().setData(list).setPage(page); return Rjx.jsonOk().setData(list).setPage(page);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment