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; /** *

* 服务实现类 *

* * @author ky * @since 2020-05-25 */ @Service @Transactional public class BannerServiceImpl extends ServiceImpl 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()); List result = bannerMapper.selectPage(new Page<>((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("1", "1").orderBy("ix", true)); JSONObject jsonObject = new JSONObject(); jsonObject.put("count",count); jsonObject.put("data",result); return jsonObject; } }