package com.atguigu.crud.service;
import com.atguigu.crud.bean.Club;
import com.atguigu.crud.bean.Empty;
import com.atguigu.crud.dao.ClubMapper;
import com.atguigu.crud.dao.EmptyMapper;
import com.atguigu.crud.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class ClubServiceImpl implements ClubService {
@Autowired
ClubMapper clubDao;
@Autowired
EmptyMapper emptydao;
@Override
public void createNewClub(Club club) throws Exception {
club.setCreate_time(new Date());
clubDao.insert(club);
}
public void addempty(Empty empty) {
emptydao.insert(empty);
}
public List<Club> list(Long long1) {
return clubDao.select(long1);
}
public PageData<Club> listClubs(Club condition, String sortName, String sortOrder, Integer pagenum,
Integer pagesize) {
List<Club> list = clubDao.listClubs(condition, sortName, sortOrder, pagenum, pagesize);
int count = clubDao.count(condition, sortName, sortOrder);
PageData<Club> page = new PageData<>();
page.setRows(list);
page.setTotal(count);
return page;
}
public Club get(String name) {
return clubDao.selectbyname(name);
}
}