package com.panzhihua.service_grid.service.impl;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.panzhihua.common.model.dtos.grid.EventAddDTO;
|
import com.panzhihua.common.model.dtos.grid.EventDeleteDTO;
|
import com.panzhihua.common.model.dtos.grid.EventEditDTO;
|
import com.panzhihua.common.model.dtos.grid.PageEventDTO;
|
import com.panzhihua.common.model.vos.R;
|
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
|
import com.panzhihua.common.model.vos.grid.EventVO;
|
import com.panzhihua.service_grid.dao.*;
|
import com.panzhihua.service_grid.model.dos.*;
|
import com.panzhihua.service_grid.service.EventService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import org.springframework.beans.BeanUtils;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
/**
|
* @auther lyq
|
* @create 2021-04-14 15:03:01
|
* @describe 订单表服务实现类
|
*/
|
@Slf4j
|
@Service
|
public class EventServiceImpl extends ServiceImpl<EventMapper, EventDO> implements EventService {
|
|
@Resource
|
private EventMapper eventMapper;
|
/**
|
* 新增事件
|
* @param eventAddDTO
|
* @return 新增结果
|
*/
|
public R add(EventAddDTO eventAddDTO){
|
EventDO eventDO = new EventDO();
|
BeanUtils.copyProperties(eventAddDTO, eventDO);
|
eventDO.setCreateAt(new Date());
|
if(eventMapper.insert(eventDO)>0){
|
return R.ok();
|
}
|
return R.fail();
|
}
|
|
/**
|
* 修改事件
|
* @param eventEditDTO
|
* @return 维护结果
|
*/
|
public R edit(EventEditDTO eventEditDTO){
|
EventDO eventDO = new EventDO();
|
BeanUtils.copyProperties(eventEditDTO, eventDO);
|
//eventDO.setUpdateAt(new Date());
|
if(eventMapper.updateById(eventDO)>0){
|
return R.ok();
|
}
|
return R.fail();
|
}
|
|
/**
|
* 分页查找事件
|
* @param pageEventDTO
|
* @return 维护结果
|
*/
|
public R<IPage<EventVO>> query(PageEventDTO pageEventDTO){
|
Page page = new Page(1,10);
|
if(pageEventDTO.getPageNum()!=null) {
|
page.setCurrent(pageEventDTO.getPageNum());
|
}
|
if(pageEventDTO.getPageSize()!=null) {
|
page.setSize(pageEventDTO.getPageSize());
|
}
|
return R.ok(eventMapper.findByPage(page, pageEventDTO));
|
}
|
|
/**
|
* 删除事件
|
* @param EventDeleteDTO
|
* @return 平台用户信息
|
*/
|
public R delete(EventDeleteDTO EventDeleteDTO){
|
return R.fail();
|
}
|
|
/**
|
* 查询事件详细信息
|
* @param id 事件 id
|
* @return 查找结果
|
*/
|
public R<EventDetailsVO> eventDetails(Long id){
|
EventDO eventDO = eventMapper.selectById(id);
|
if(eventDO!=null) {
|
EventDetailsVO eventDetailsVO = new EventDetailsVO();
|
BeanUtils.copyProperties(eventDO, eventDetailsVO);
|
return R.ok(eventDetailsVO);
|
}
|
return R.fail();
|
}
|
|
}
|