package com.hssx.cloudmodel.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hssx.cloudmodel.constant.Constant; import com.hssx.cloudmodel.entity.MouldEquipment; import com.hssx.cloudmodel.entity.User; import com.hssx.cloudmodel.entity.vo.MouldEquipmentVO; import com.hssx.cloudmodel.mapper.MouldEquipmentMapper; import com.hssx.cloudmodel.service.MouldEquipmentService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hssx.cloudmodel.util.HttpRespMsg; import com.hssx.cloudmodel.util.PageUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; /** *

* 服务实现类 *

* * @author 吴涛涛 * @since 2019-08-02 */ @Service public class MouldEquipmentServiceImpl extends ServiceImpl implements MouldEquipmentService { @Resource MouldEquipmentMapper mouldEquipmentMapper; @Override public HttpRespMsg addAndUpdateMouldEquipment(MouldEquipment mouldEquipment, User user) { HttpRespMsg msg = new HttpRespMsg(); if (user.getParentId() == 0) { if (mouldEquipment.getId() == null) { //添加设备 mouldEquipmentMapper.insert(mouldEquipment); } else { //修改设备 mouldEquipmentMapper.updateById(mouldEquipment); } } else { msg.setError("对不起,您不是管理员,不具备设备创建或修改的权限"); } return msg; } @Override public HttpRespMsg isUse(MouldEquipment mouldEquipment, User user) { HttpRespMsg msg = new HttpRespMsg(); //判断是不是超级管理员,是才可操作 if (user.getParentId() == 0) { //修改设备 LocalDateTime now = LocalDateTime.now(); mouldEquipment.setStartTime(now); mouldEquipment.setEndTime(now.plusYears(mouldEquipment.getUseLife())); mouldEquipmentMapper.updateById(mouldEquipment); } else { msg.setError("对不起,您不是管理员,不具备启用设备的权限"); } return msg; } @Override public HttpRespMsg getList(User user, PageUtil page) { HttpRespMsg msg = new HttpRespMsg(); if (user != null) { if (Constant.SYS_PARENT_ID == user.getParentId()) { PageHelper.startPage(page.getPageNum(), page.getPageSize()); List mouldEquipments = mouldEquipmentMapper.selectList(new QueryWrapper()); PageInfo pageInfo = new PageInfo<>(mouldEquipments); msg.data = pageInfo; } else { msg.setError("对不起!您不含有查看该列表的权利。"); } } return msg; } @Override public HttpRespMsg getListByCompanyId(MouldEquipmentVO mouldEquipmentVO) { HttpRespMsg msg = new HttpRespMsg(); List list = mouldEquipmentMapper.getListByCompanyId(mouldEquipmentVO.getBelongCompanyId()); msg.data = list; return msg; } }