All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quhaodian.notice.data.dao.impl.UserNotificationNumDaoImpl Maven / Gradle / Ivy

There is a newer version: 1.8.4
Show newest version
package com.quhaodian.notice.data.dao.impl;

import com.quhaodian.data.core.CriteriaDaoImpl;
import com.quhaodian.data.core.Finder;
import com.quhaodian.notice.data.dao.UserNotificationNumDao;
import com.quhaodian.notice.data.entity.UserNotificationNum;
import com.quhaodian.user.data.entity.UserInfo;
import java.util.Date;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * Created by imake on 2018年01月02日11:12:13.
 */
@Repository

public class UserNotificationNumDaoImpl extends CriteriaDaoImpl implements UserNotificationNumDao {

  @Override
  public UserNotificationNum findById(Long id) {
    if (id == null) {
      return null;
    }
    return get(id);
  }

  @Override
  public UserNotificationNum save(UserNotificationNum bean) {

    getSession().save(bean);


    return bean;
  }

  @Override
  public UserNotificationNum deleteById(Long id) {
    UserNotificationNum entity = super.get(id);
    if (entity != null) {
      getSession().delete(entity);
    }
    return entity;
  }

  @Override
  public UserNotificationNum findByUser(Long user) {
    UserNotificationNum result = null;
    Finder finder = Finder.create();
    finder.append("from UserNotificationNum t where t.user.id =:uid");
    finder.setParam("uid", user);
    result = this.findOne(finder);
    if (result == null) {
      result = new UserNotificationNum();
      result.setUser(UserInfo.fromId(user));
      result.setMid(0L);
      this.add(result);
    }
    result.setLastDate(new Date());
    return result;
  }

  @Override
  protected Class getEntityClass() {
    return UserNotificationNum.class;
  }

  @Autowired
  public void setSuperSessionFactory(SessionFactory sessionFactory) {
    super.setSessionFactory(sessionFactory);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy