| package com.doumee.service.business.impl; | 
|   | 
| import com.doumee.core.model.PageData; | 
| import com.doumee.core.model.PageWrap; | 
| import com.doumee.core.utils.Utils; | 
| import com.doumee.dao.business.LocksMapper; | 
| import com.doumee.dao.business.join.LocksJoinMapper; | 
| import com.doumee.dao.business.model.BaseParam; | 
| import com.doumee.dao.business.model.Bikes; | 
| import com.doumee.dao.business.model.Locks; | 
| import com.doumee.dao.business.model.Sites; | 
| import com.doumee.service.business.LocksService; | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
| import com.baomidou.mybatisplus.core.metadata.IPage; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.doumee.service.business.SitesService; | 
| import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.util.CollectionUtils; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * 锁头信息表Service实现 | 
|  * @author 江蹄蹄 | 
|  * @date 2023/09/27 18:06 | 
|  */ | 
| @Service | 
| public class LocksServiceImpl implements LocksService { | 
|   | 
|     @Autowired | 
|     private LocksMapper locksMapper; | 
|   | 
|     @Autowired | 
|     private LocksJoinMapper locksJoinMapper; | 
|   | 
|     @Override | 
|     public String create(Locks locks) { | 
|         locksMapper.insert(locks); | 
|         return locks.getId(); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteById(String id) { | 
|         locksMapper.deleteById(id); | 
|     } | 
|   | 
|     @Override | 
|     public void delete(Locks locks) { | 
|         UpdateWrapper<Locks> deleteWrapper = new UpdateWrapper<>(locks); | 
|         locksMapper.delete(deleteWrapper); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteByIdInBatch(List<String> ids) { | 
|         if (CollectionUtils.isEmpty(ids)) { | 
|             return; | 
|         } | 
|         locksMapper.deleteBatchIds(ids); | 
|     } | 
|   | 
|     @Override | 
|     public void updateById(Locks locks) { | 
|         locksMapper.updateById(locks); | 
|     } | 
|   | 
|     @Override | 
|     public void updateByIdInBatch(List<Locks> lockss) { | 
|         if (CollectionUtils.isEmpty(lockss)) { | 
|             return; | 
|         } | 
|         for (Locks locks: lockss) { | 
|             this.updateById(locks); | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public Locks findById(String id) { | 
|         return locksMapper.selectById(id); | 
|     } | 
|   | 
|     @Override | 
|     public Locks findOne(Locks locks) { | 
|         QueryWrapper<Locks> wrapper = new QueryWrapper<>(locks); | 
|         return locksMapper.selectOne(wrapper.last(" limit 1")); | 
|     } | 
|   | 
|     @Override | 
|     public List<Locks> findList(Locks locks) { | 
|         QueryWrapper<Locks> wrapper = new QueryWrapper<>(locks); | 
|         return locksMapper.selectList(wrapper); | 
|     } | 
|   | 
|     @Override | 
|     public PageData<Locks> findPage(PageWrap<Locks> pageWrap) { | 
|         IPage<Locks> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         MPJLambdaWrapper<Locks> queryWrapper = new MPJLambdaWrapper<>(); | 
|         Utils.MP.blankToNull(pageWrap.getModel()); | 
|   | 
|         if (pageWrap.getModel().getCode() != null) { | 
|             queryWrapper.like(Locks::getCode, pageWrap.getModel().getCode()); | 
|         } | 
|         if (pageWrap.getModel().getSiteId() != null) { | 
|             queryWrapper.like(Locks::getSiteId, pageWrap.getModel().getSiteId()); | 
|         } | 
|         if (pageWrap.getModel().getSiteName() != null) { | 
|             queryWrapper.like(Sites::getName, pageWrap.getModel().getSiteName()); | 
|         } | 
|         queryWrapper.leftJoin(Bikes.class,Bikes::getCode,Locks::getBikeCode) | 
|                     .leftJoin(BaseParam.class,BaseParam::getId,Bikes::getParamId) | 
|                     .leftJoin(Sites.class,Sites::getCode,Locks::getSiteId); | 
|         queryWrapper.orderByDesc(Locks::getBikeCode); | 
|         queryWrapper.selectAll(Locks.class) | 
|                     .selectAs(Sites::getName,Locks::getSiteName) | 
|                     .selectAs(BaseParam::getName,Locks::getBikeType); | 
|         return PageData.from(locksJoinMapper.selectJoinPage(page, Locks.class,queryWrapper)); | 
|     } | 
|   | 
|     @Override | 
|     public long count(Locks locks) { | 
|         QueryWrapper<Locks> wrapper = new QueryWrapper<>(locks); | 
|         return locksMapper.selectCount(wrapper); | 
|     } | 
|   | 
|   | 
| } |