Commit 9dcf3ca6 authored by Quxl's avatar Quxl
parents 01386529 2f3796f3
......@@ -8,7 +8,7 @@ import com.egolm.film.bean.Fc_admin;
public interface NewsService {
List<Map<String, Object>> queryList(Page page);
List<Map<String, Object>> queryList(Page page, String key);
void merge(Object obj);
......
......@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService;
......@@ -25,9 +26,19 @@ public class NewsServiceImpl implements NewsService {
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryList(Page 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);
public List<Map<String, Object>> queryList(Page page, String key) {
String beforeSql = "select ns.*, a.realname creator_name from fc_news ns left join fc_admin a on a.adminid = ns.creator ";
String centerSql = "";
if(StringUtil.isNotBlank(key)) {
centerSql = " where ns.title like ? ";
}
String endSql = "order by ns.create_time desc";
String sql = beforeSql + centerSql + endSql;
if(!"".equals(centerSql)) {
return jdbcTemplate.limit(sql, page, "%"+key+"%");
}else {
return jdbcTemplate.limit(sql, page);
}
}
@Override
......@@ -42,7 +53,22 @@ public class NewsServiceImpl implements NewsService {
@Override
public Map<String, Object> queryById(Integer id) {
return jdbcTemplate.queryForMap("select * from fc_news where id = ?", id);
Map<String, Object> map = jdbcTemplate.queryForMap("select * from fc_news where id = ?", id);
String sql2 = "select user_group_id, user_id from fc_news_sender where news_id = ?";
List<Map<String, Object>> send = jdbcTemplate.queryForList(sql2, id);
List<Object> sendUserList = new ArrayList<>();
List<Object> sendGroupList = new ArrayList<>();
for (Map<String, Object> map2 : send) {
if(map2.get("user_id")!=null) {
sendUserList.add(map2.get("user_id"));
}
if(map2.get("user_group_id")!=null) {
sendGroupList.add(map2.get("user_group_id"));
}
}
map.put("userList", sendUserList);
map.put("groupList", sendGroupList);
return map;
}
@Override
......
......@@ -38,11 +38,11 @@ public class AdminNewsController {
@ResponseBody
@PostMapping("list")
@ApiOperation("公告列表查询")
public Object list(Long index, Long limit) {
public Object list(Long index, Long limit, String key) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
List<Map<String, Object>> list = service.queryList(page);
List<Map<String, Object>> list = service.queryList(page, key);
return Rjx.jsonOk().setData(list).setPage(page);
}
......@@ -76,7 +76,7 @@ public class AdminNewsController {
news.setLast_update_time(now);
}
service.merge(news);
return Rjx.jsonOk();
return Rjx.jsonOk().setData(news);
}
@ResponseBody
......@@ -92,21 +92,25 @@ public class AdminNewsController {
LoginToken token = tokenService.getToken();
Integer adminid = ((Number)token.getId()).intValue();
List<Fc_news_sender> senders = new ArrayList<Fc_news_sender>();
for(Integer uid : user_id) {
Fc_news_sender sender = new Fc_news_sender();
sender.setNews_id(id);
sender.setUser_id(uid);
sender.setSender(adminid);
sender.setSend_time(now);
senders.add(sender);
if(user_id!=null&&user_id.length>0) {
for(Integer uid : user_id) {
Fc_news_sender sender = new Fc_news_sender();
sender.setNews_id(id);
sender.setUser_id(uid);
sender.setSender(adminid);
sender.setSend_time(now);
senders.add(sender);
}
}
for(Integer gid : user_group_id) {
Fc_news_sender sender = new Fc_news_sender();
sender.setNews_id(id);
sender.setUser_group_id(gid);
sender.setSender(adminid);
sender.setSend_time(now);
senders.add(sender);
if(user_group_id!=null&&user_group_id.length>0) {
for(Integer gid : user_group_id) {
Fc_news_sender sender = new Fc_news_sender();
sender.setNews_id(id);
sender.setUser_group_id(gid);
sender.setSender(adminid);
sender.setSend_time(now);
senders.add(sender);
}
}
service.batchSave(senders);
return Rjx.jsonOk();
......
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