Commit 561a66c1 authored by Quxl's avatar Quxl

x

parent b309f0a1
......@@ -11,8 +11,12 @@ public interface NewsService {
void merge(Object obj);
void save(Object obj);
void batchSave(List<?> objs);
Map<String, Object> queryById(Integer id);
List<Map<String, Object>> queryListForUser(Integer uid, Page page);
}
......@@ -36,4 +36,15 @@ public class NewsServiceImpl implements NewsService {
return jdbcTemplate.queryForMap("select * from fc_news where id = ?", id);
}
@Override
public void save(Object obj) {
jdbcTemplate.save(obj);
}
@Override
public List<Map<String, Object>> queryListForUser(Integer uid, Page page) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -58,8 +58,8 @@ public class AdminNewsController {
})
public Object save(Integer id, String type, String title, String content, Integer level) {
Date now = new Date();
LoginToken loginToken = tokenService.getToken();
Integer adminid = (Integer)loginToken.getId();
LoginToken token = tokenService.getToken();
Integer adminid = ((Number)token.getId()).intValue();
Fc_news news = new Fc_news();
news.setId(id);
news.setType(type);
......@@ -89,8 +89,8 @@ public class AdminNewsController {
})
public Object send(Integer id, Integer[] user_id, Integer[] user_group_id) {
Date now = new Date();
LoginToken loginToken = tokenService.getToken();
Integer adminid = (Integer)loginToken.getId();
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();
......
package com.egolm.film.api.web.user;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api
@Controller
@RequestMapping("user/news")
public class UserNewsController {
@Autowired
UserTokenService tokenService;
@Autowired
NewsService service;
@ResponseBody
@PostMapping("list")
@ApiOperation("公告列表查询")
public Object list(Long index, Long limit) {
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);
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
@PostMapping("saveReadLog")
@ApiOperation("保存阅读记录")
public Object saveReadLog(Integer news_id, Integer user_id) {
Fc_news_read read = new Fc_news_read();
read.setNews_id(news_id);
read.setUser_id(user_id);
read.setRead_time(new Date());
service.save(read);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("getById")
@ApiOperation("消息详情查询")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", name="id", value="消息ID"),
})
public Object getById(Integer id) {
Map<String, Object> map = service.queryById(id);
return Rjx.jsonOk().setData(map);
}
}
......@@ -6,6 +6,8 @@ import javax.persistence.Column;
import javax.persistence.Id;
import java.util.Date;
@Entity(name="fc_news_read")
public class Fc_news_read implements java.io.Serializable {
......@@ -19,6 +21,9 @@ public class Fc_news_read implements java.io.Serializable {
@Column(columnDefinition="int(11)")
private Integer user_id;
@Column(columnDefinition="datetime")
private Date read_time;
public void setNews_id(Integer news_id) {
this.news_id = news_id;
......@@ -36,5 +41,13 @@ public class Fc_news_read implements java.io.Serializable {
return user_id;
}
public void setRead_time(Date read_time) {
this.read_time = read_time;
}
public Date getRead_time() {
return read_time;
}
}
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