Commit 8d3e4e7c authored by Quxl's avatar Quxl

x

parent 561a66c1
......@@ -17,6 +17,6 @@ public interface NewsService {
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 {
@Override
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
......@@ -42,9 +43,9 @@ public class NewsServiceImpl implements NewsService {
}
@Override
public List<Map<String, Object>> queryListForUser(Integer uid, Page page) {
// TODO Auto-generated method stub
return null;
public List<Map<String, Object>> queryListForUser(Integer uid, Integer gid, Page page) {
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 jdbcTemplate.limit(sql, page, uid, uid, gid);
}
}
......@@ -15,7 +15,7 @@ import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService;
import com.egolm.film.api.service.UserTokenService;
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.ApiImplicitParam;
......@@ -40,9 +40,10 @@ public class UserNewsController {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
LoginToken token = tokenService.getToken();
Integer uid = ((Number)token.getId()).intValue();
List<Map<String, Object>> list = service.queryListForUser(uid, page);
Fc_user user = (Fc_user)tokenService.getTokenObj();
Integer uid = user.getUid();
Integer gid = user.getGroup_id();
List<Map<String, Object>> list = service.queryListForUser(uid, gid, 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