From bfbfe7d5fd6c90d5f7359762223ce4bd1cc7cfa1 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期一, 15 八月 2022 09:56:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/lyq_battery_shop' into diandongche --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelRelationServiceImpl.java | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 158 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelRelationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelRelationServiceImpl.java new file mode 100644 index 0000000..e45ac7f --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComChangeCarModelRelationServiceImpl.java @@ -0,0 +1,158 @@ +package com.panzhihua.service_community.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.panzhihua.common.model.vos.common.ComChangeCarModelRelationVo; +import com.panzhihua.common.model.vos.common.ComChangeCarModelVo; +import com.panzhihua.service_community.entity.ComChangeCarModelRelation; +import com.panzhihua.service_community.dao.ComChangeCarModelRelationMapper; +import com.panzhihua.service_community.service.ComChangeCarModelRelationService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import com.panzhihua.common.model.dtos.common.*; +import com.panzhihua.common.model.vos.R; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.List; + +/** + * title: 换新车-车型与规格关联表表服务实现类 + * <p> + * projectName 成都呐喊信息技术有限公司-智慧社区项目 + * <p> + * description: 换新车-车型与规格关联表表服务实现类 + * + * @author lyq + * @date 2022-04-07 13:55:30 + */ +@Service("comChangeCarModelRelationService") +public class ComChangeCarModelRelationServiceImpl extends ServiceImpl<ComChangeCarModelRelationMapper, ComChangeCarModelRelation> implements ComChangeCarModelRelationService { + + /** + * description queryByPage 分页查询 + * + * @param comChangeCarModelRelation 请求参数 + * @return 分页查询列表数据 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R queryByPage(PageComChangeCarModelRelationDto comChangeCarModelRelation) { + return R.ok(this.baseMapper.queryAllByLimit(comChangeCarModelRelation, new Page(comChangeCarModelRelation.getPageNum(), comChangeCarModelRelation.getPageSize()))); + } + + /** + * description insert 新增数据 + * + * @param comChangeCarModelRelation 请求参数 + * @return 新增结果 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R insert(AddComChangeCarModelRelationDto comChangeCarModelRelation) { + ComChangeCarModelRelation entity = this.baseMapper.selectOne(new QueryWrapper<ComChangeCarModelRelation>().lambda() + .eq(ComChangeCarModelRelation::getModelId,comChangeCarModelRelation.getModelId()) + .eq(ComChangeCarModelRelation::getModelSpecsId,comChangeCarModelRelation.getModelSpecsId())); + if(entity == null){ + entity = new ComChangeCarModelRelation(); + BeanUtils.copyProperties(comChangeCarModelRelation, entity); + if (this.baseMapper.insert(entity) > 0) { + return R.ok(); + } + }else{ + if(entity.getModelSpecsChildrenId() == null){ + BeanUtils.copyProperties(comChangeCarModelRelation, entity); + if (this.baseMapper.updateById(entity) > 0) { + return R.ok(); + } + }else{ + return R.fail("已关联该规格,不可重复关联"); + } + } + return R.fail("添加失败"); + } + + /** + * description update 修改数据 + * + * @param editDto 请求参数 + * @return 修改结果 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R update(EditComChangeCarModelRelationDto editDto) { + ComChangeCarModelRelation entity = this.baseMapper.selectById(editDto.getId()); + if (entity == null) { + return R.fail("未查询到该记录"); + } + BeanUtils.copyProperties(editDto, entity); + if (this.baseMapper.updateById(entity) > 0) { + return R.ok(); + } + return R.fail("修改失败"); + } + + /** + * description deleteById 通过主键删除数据 + * + * @param id 主键id + * @return 删除结果 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R deleteById(Long id) { + if (this.baseMapper.deleteById(id) > 0) { + return R.ok(); + } + return R.fail("删除失败"); + } + + /** + * description detailById 查询详情 + * + * @param id 主键id + * @return 详情数据 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R detailById(Long id) { + return R.ok(this.baseMapper.queryById(id)); + } + + /** + * description queryByPage 查询列表 + * + * @param comChangeCarModelRelation 请求参数 + * @return 列表数据 + * @author lyq + * @date 2022-04-07 13:55:30 + */ + @Override + public R queryByList(PageComChangeCarModelRelationDto comChangeCarModelRelation) { + return R.ok(this.baseMapper.queryAllByList(comChangeCarModelRelation)); + } + + /** + * description queryByPage 小程序分页查询 + * + * @param comChangeCarModelRelation 请求参数 + * @return 小程序分页查询返回参数 + * @author lyq + * @date 2022-04-07 13:55:29 + */ + @Override + public R queryByAppletsPage(PageComChangeCarModelRelationDto comChangeCarModelRelation) { + IPage<ComChangeCarModelVo> carModelVoIPage = this.baseMapper.queryAllByAppletsLimit(comChangeCarModelRelation, new Page(comChangeCarModelRelation.getPageNum(), comChangeCarModelRelation.getPageSize())); + carModelVoIPage.getRecords().forEach(carModel -> { + //查询车型规格列表 + List<ComChangeCarModelRelationVo> carModelRelationVoList = this.baseMapper.queryAllByModelId(carModel.getId()); + carModel.setCarModelRelationList(carModelRelationVoList); + }); + return R.ok(carModelVoIPage); + } +} -- Gitblit v1.7.1