You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
Java
62 lines
1.8 KiB
Java
package com.gszc.service.impl;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.gszc.entity.Banner;
|
|
import com.gszc.entity.Banner;
|
|
import com.gszc.mapper.BannerMapper;
|
|
import com.gszc.service.IBannerService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import com.gszc.util.Uuid8Utils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* <p>
|
|
* 服务实现类
|
|
* </p>
|
|
*
|
|
* @author ky
|
|
* @since 2020-05-25
|
|
*/
|
|
@Service
|
|
@Transactional
|
|
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements IBannerService {
|
|
|
|
@Autowired
|
|
BannerMapper bannerMapper;
|
|
|
|
public void addBanner(Banner banner){
|
|
String id = UUID.randomUUID().toString();
|
|
banner.setId(id);
|
|
banner.setCreateDate(new Date());
|
|
banner.setModifyDate(new Date());
|
|
bannerMapper.insert(banner);
|
|
}
|
|
|
|
public void deleteBanner(Banner banner){
|
|
bannerMapper.deleteById(banner);
|
|
}
|
|
|
|
public void updateBanner(Banner banner){
|
|
bannerMapper.updateById(banner);
|
|
}
|
|
|
|
public JSONObject queryBanner(Integer pageNum, Integer pageSize){
|
|
|
|
Integer count = bannerMapper.selectCount(new EntityWrapper<Banner>());
|
|
List<Banner> result = bannerMapper.selectPage(new Page<>((pageNum - 1) * pageSize, pageSize), new EntityWrapper<Banner>().eq("1", "1").orderBy("ix", true));
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count",count);
|
|
jsonObject.put("data",result);
|
|
return jsonObject;
|
|
}
|
|
|
|
}
|