// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private int id;
// 
//     private int yibanid;
// 
//     private String title;
//     private String message;
//     private String tag;
// 
//     private LocalDateTime publishtime;
// 
//     public Notification() {
//     }
// 
//     public Notification(int yibanid, String title, String message) {
//         this.yibanid = yibanid;
//         this.title = title;
//         this.message = message;
//         this.tag = "default";
//         this.publishtime = LocalDateTime.now();
//     }
// 
//     public Notification(int yibanid, String title, String message, String tag) {
//         this.yibanid = yibanid;
//         this.title = title;
//         this.message = message;
//         this.tag = tag;
//         this.publishtime = LocalDateTime.now();
//     }
// 
//     public int getYibanid() {
//         return yibanid;
//     }
// 
//     public void setYibanid(int yibanid) {
//         this.yibanid = yibanid;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     public String getTag() {
//         return tag;
//     }
// 
//     public void setTag(String tag) {
//         this.tag = tag;
//     }
// 
//     public LocalDateTime getPublishtime() {
//         return publishtime;
//     }
// 
//     public void setPublishtime(LocalDateTime publishtime) {
//         this.publishtime = publishtime;
//     }
// }
// 
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
// 
//     @Autowired
//     private HttpSession httpSession;
// 
//     @Autowired
//     private CommonAdminService commonAdminService;
// 
//     @Autowired
//     private NotificationDao notificationDao;
// 
//     public Object postNew(String title, String message, String tag){
//         YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
//         if (!commonAdminService.isCommonAdmin()){
//             return new ErrorReporter(-1,"no-access");
//         }
//         Notification notification = new Notification(user.visit_user.userid, title, message, tag);
//         notificationDao.save(notification);
//         return new ErrorReporter(0, "success");
//     }
// 
//     public Object deleteOne(int Nid){
//         if (!commonAdminService.isCommonAdmin()){
//             return new ErrorReporter(-1,"no-access");
//         }
//         notificationDao.delete(Nid);
//         return new ErrorReporter(0, "success");
//     }
// }
// 
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
//     public int visit_time;
//     public VisitUser visit_user;
//     public VisitOauth visit_oauth;
// 
//     public class VisitUser{
//         public int userid;
//         public String username;
//         public String usernick;
//         public char usersex;
//         public String userhead;
//     }
// 
//     public class VisitOauth{
//         public String access_token;
//         public int token_expires;
//     }
// }


import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
package cn.edu.upc.yb.integrate.bulletinboard;



/**
 * Created by skyADMIN on 16/7/8.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {

    @Autowired
    private NotificationDao notificationDao;

    @Autowired
    private NotificationService notificationService;

    @Autowired
    private HttpSession httpSession;

    @Test
    @Transactional
    public void testDB(){
        Notification notification = new Notification(119, "测试233", "222222", "w");
        notificationDao.save(notification);
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private int id;
// 
//     private int yibanid;
// 
//     private String title;
//     private String message;
//     private String tag;
// 
//     private LocalDateTime publishtime;
// 
//     public Notification() {
//     }
// 
//     public Notification(int yibanid, String title, String message) {
//         this.yibanid = yibanid;
//         this.title = title;
//         this.message = message;
//         this.tag = "default";
//         this.publishtime = LocalDateTime.now();
//     }
// 
//     public Notification(int yibanid, String title, String message, String tag) {
//         this.yibanid = yibanid;
//         this.title = title;
//         this.message = message;
//         this.tag = tag;
//         this.publishtime = LocalDateTime.now();
//     }
// 
//     public int getYibanid() {
//         return yibanid;
//     }
// 
//     public void setYibanid(int yibanid) {
//         this.yibanid = yibanid;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     public String getTag() {
//         return tag;
//     }
// 
//     public void setTag(String tag) {
//         this.tag = tag;
//     }
// 
//     public LocalDateTime getPublishtime() {
//         return publishtime;
//     }
// 
//     public void setPublishtime(LocalDateTime publishtime) {
//         this.publishtime = publishtime;
//     }
// }
// 
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
// 
//     @Autowired
//     private HttpSession httpSession;
// 
//     @Autowired
//     private CommonAdminService commonAdminService;
// 
//     @Autowired
//     private NotificationDao notificationDao;
// 
//     public Object postNew(String title, String message, String tag){
//         YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
//         if (!commonAdminService.isCommonAdmin()){
//             return new ErrorReporter(-1,"no-access");
//         }
//         Notification notification = new Notification(user.visit_user.userid, title, message, tag);
//         notificationDao.save(notification);
//         return new ErrorReporter(0, "success");
//     }
// 
//     public Object deleteOne(int Nid){
//         if (!commonAdminService.isCommonAdmin()){
//             return new ErrorReporter(-1,"no-access");
//         }
//         notificationDao.delete(Nid);
//         return new ErrorReporter(0, "success");
//     }
// }
// 
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
//     public int visit_time;
//     public VisitUser visit_user;
//     public VisitOauth visit_oauth;
// 
//     public class VisitUser{
//         public int userid;
//         public String username;
//         public String usernick;
//         public char usersex;
//         public String userhead;
//     }
// 
//     public class VisitOauth{
//         public String access_token;
//         public int token_expires;
//     }
// }


// Path: src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;

package cn.edu.upc.yb.integrate.bulletinboard;



/**
 * Created by skyADMIN on 16/7/8.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {

    @Autowired
    private NotificationDao notificationDao;

    @Autowired
    private NotificationService notificationService;

    @Autowired
    private HttpSession httpSession;

    @Test
    @Transactional
    public void testDB(){
        Notification notification = new Notification(119, "测试233", "222222", "w");
        notificationDao.save(notification);
        Notification notification1 = notificationDao.findFirstByOrderByIdDesc();