123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- package com.ruoyi.system.service.impl;
- import java.sql.Time;
- import java.text.SimpleDateFormat;
- import java.time.LocalDateTime;
- import java.util.Date;
- import java.util.List;
- import java.util.stream.Collectors;
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.system.domain.vo.CollectionsVo;
- import com.ruoyi.system.mapper.PostCollectionsMapper;
- import com.ruoyi.system.service.IPostCollectionsService;
- import org.apache.commons.lang3.builder.ToStringExclude;
- import org.apache.ibatis.type.LocalDateTimeTypeHandler;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.format.annotation.DateTimeFormat;
- import org.springframework.stereotype.Service;
- import com.ruoyi.system.mapper.PostCollectionsSystemMapper;
- import com.ruoyi.system.domain.PostCollectionsSystem;
- import com.ruoyi.system.service.IPostCollectionsSystemService;
- import static com.ruoyi.common.utils.SecurityUtils.getUsername;
- @Service
- public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemService
- {
- @Autowired
- private PostCollectionsSystemMapper postCollectionsSystemMapper;
- @Autowired
- private IPostCollectionsService postCollectionsService;
-
- @Override
- public PostCollectionsSystem selectPostCollectionsSystemById(Long id)
- {
- return postCollectionsSystemMapper.selectPostCollectionsSystemById(id);
- }
-
- @Override
- public List<PostCollectionsSystem> selectPostCollectionsSystemList(PostCollectionsSystem postCollectionsSystem)
- {
- return postCollectionsSystemMapper.selectPostCollectionsSystemList(postCollectionsSystem);
- }
-
- @Override
- public int insertPostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
- {
-
- Date nowDate = DateUtils.getNowDate();
- Date startTime = postCollectionsSystem.getStartTime();
- Date endTime = postCollectionsSystem.getEndTime();
-
- if (null!=startTime && null!=endTime){
- if (nowDate.before(startTime)){
- postCollectionsSystem.setType((long) 1);
- }
- else if (nowDate.after(endTime)){
- postCollectionsSystem.setType((long) 2);
- }
- else {
- postCollectionsSystem.setType((long) 0);
- }
- }
-
- postCollectionsSystem.setCreateBy(getUsername());
- postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
- postCollectionsSystem.setUpdateBy(getUsername());
- postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
- return postCollectionsSystemMapper.insertPostCollectionsSystem(postCollectionsSystem);
- }
-
- @Override
- public int updatePostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
- {
-
- postCollectionsSystem.setUpdateBy(getUsername());
- postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
-
-
- Date nowDate = DateUtils.getNowDate();
- Date startTime = postCollectionsSystem.getStartTime();
- Date endTime = postCollectionsSystem.getEndTime();
-
- if (null!=startTime && null!=endTime){
- if (nowDate.before(startTime)){
- postCollectionsSystem.setType((long) 1);
- }
- else if (nowDate.after(endTime)){
- postCollectionsSystem.setType((long) 2);
- }
- else {
- postCollectionsSystem.setType((long) 0);
- }
- }
- return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
- }
-
- @Override
- public int deletePostCollectionsSystemByIds(Long[] ids)
- {
- return postCollectionsSystemMapper.deletePostCollectionsSystemByIds(ids);
- }
-
- @Override
- public int deletePostCollectionsSystemById(Long id)
- {
- return postCollectionsSystemMapper.deletePostCollectionsSystemById(id);
- }
-
- @Override
- public List<PostCollectionsSystem> selectByTitleAndTime(String title, Date TimeLeft, Date TimeRight) {
- if (title != null) {
-
- if (TimeLeft != null && TimeRight != null) {
- if( TimeLeft.before(TimeRight)) {
- return postCollectionsSystemMapper.selectPostListByTitleOrTime(title, TimeLeft, TimeRight);
- }else {
- return null;
- }
- }else {
-
- return postCollectionsSystemMapper.selectPostListByTitleOrTime(title, TimeLeft, TimeRight);
- }
- } else {
-
-
- if (TimeLeft != null && TimeRight != null) {
-
- if( TimeLeft.before(TimeRight)) {
- return postCollectionsSystemMapper.selectPostListByTitleOrTime(title, TimeLeft, TimeRight);
- }else {
- return null;
- }
- }
- }
- PostCollectionsSystem post = new PostCollectionsSystem();
- return postCollectionsSystemMapper.selectPostCollectionsSystemList(post);
- }
-
- @Override
- public int getCopies(Long id) {
- return postCollectionsSystemMapper.getCopiesById(id);
- }
- @Override
- public List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem) {
- List<PostCollectionsSystem> list = postCollectionsSystemMapper.selectPostCollectionsSystemList(postCollectionsSystem);
- List<CollectionsVo> collectionsVos=list.stream().map((item)->{
-
- CollectionsVo collectionsVo=new CollectionsVo();
- BeanUtils.copyProperties(item,collectionsVo);
-
- Long id = item.getId();
-
- Integer copiesById = postCollectionsSystemMapper.getCopiesById(id);
- collectionsVo.setCopies(copiesById);
- return collectionsVo;
- }).collect(Collectors.toList());
- return collectionsVos;
- }
- @Override
- public int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem) {
- return postCollectionsSystemMapper.selectPostCollectionsSystemByName(postCollectionsSystem);
- }
- @Override
- public List<PostCollectionsSystem> listByIds(List<Long> ids) {
- return postCollectionsSystemMapper.selectPostCollectionsSystemByIds(ids);
- }
- @Override
- public int updateBatchById(List<PostCollectionsSystem> postCollectionsSystemList) {
- for (int i = 0; i < postCollectionsSystemList.size(); i++) {
-
- postCollectionsService.selectPostCollectionsList(postCollectionsSystemList.get(i).getId());
- postCollectionsSystemList.get(i). setUpdateBy(getUsername());
- postCollectionsSystemList.get(i).setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
- }
- return postCollectionsSystemMapper.updateBatchById(postCollectionsSystemList);
- }
- }
|