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

com.quhaodian.notice.data.service.impl.UserNotificationCatalogServiceImpl Maven / Gradle / Ivy

There is a newer version: 3.3.18-20230117
Show newest version
package com.quhaodian.notice.data.service.impl;

import com.quhaodian.data.core.Updater;
import com.quhaodian.data.page.Filter;
import com.quhaodian.data.page.Order;
import com.quhaodian.data.page.Page;
import com.quhaodian.data.page.Pageable;
import com.quhaodian.data.utils.FilterUtils;
import com.quhaodian.notice.data.dao.UserNotificationCatalogDao;
import com.quhaodian.notice.data.entity.UserNotificationCatalog;
import com.quhaodian.notice.data.service.UserNotificationCatalogService;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


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


@Scope("prototype")
@Service
@Transactional
public class UserNotificationCatalogServiceImpl implements UserNotificationCatalogService {
  
  private UserNotificationCatalogDao dao;
  
  
  @Override
  @Transactional(readOnly = true)
  public UserNotificationCatalog findById(Integer id) {
    return dao.findById(id);
  }
  
  @Override
  public List findByTops(Integer pid) {
    LinkedList result = new LinkedList();
    UserNotificationCatalog catalog = dao.findById(pid);
    if (catalog != null) {
      while (catalog != null && catalog.getParent() != null) {
        result.addFirst(catalog);
        catalog = dao.findById(catalog.getParentId());
      }
      result.addFirst(catalog);
    }
    return result;
  }
  
  
  @Override
  public List child(Integer id, Integer max) {
    List orders = new ArrayList();
    orders.add(Order.asc("code"));
    List list = new ArrayList();
    list.add(Filter.eq("parent.id", id));
    return dao.list(0, max, list, orders);
  }
  
  @Override
  @Transactional
  public UserNotificationCatalog save(UserNotificationCatalog bean) {
    dao.save(bean);
    return bean;
  }
  
  @Override
  @Transactional
  public UserNotificationCatalog update(UserNotificationCatalog bean) {
    Updater updater = new Updater(bean);
    return dao.updateByUpdater(updater);
  }
  
  @Override
  @Transactional
  public UserNotificationCatalog deleteById(Integer id) {
    UserNotificationCatalog bean = dao.findById(id);
    dao.deleteById(id);
    return bean;
  }
  
  @Override
  @Transactional
  public UserNotificationCatalog[] deleteByIds(Integer[] ids) {
    UserNotificationCatalog[] beans = new UserNotificationCatalog[ids.length];
    for (int i = 0, len = ids.length; i < len; i++) {
      beans[i] = deleteById(ids[i]);
    }
    return beans;
  }
  
  
  @Autowired
  public void setDao(UserNotificationCatalogDao dao) {
    this.dao = dao;
  }
  
  @Override
  public Page page(Pageable pageable) {
    return dao.page(pageable);
  }
  
  
  @Override
  public Page page(Pageable pageable, Object search) {
    List filters = FilterUtils.getFilters(search);
    if (filters != null) {
      pageable.getFilters().addAll(filters);
    }
    return dao.page(pageable);
  }
  
  @Override
  public List list(int first, Integer size, List filters, List orders) {
    return dao.list(first, size, filters, orders);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy