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