| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.panzhihua.common.model.dtos.community.microCommercialStreet.McsEvaluateDTO; |
| | | import com.panzhihua.service_community.dao.McsCouponDAO; |
| | | import com.panzhihua.service_community.entity.McsCoupon; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.panzhihua.service_community.entity.McsEvaluate; |
| | | import com.panzhihua.service_community.service.McsEvaluateService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | /** |
| | | * (McsEvaluate)表服务实现类 |
| | | * |
| | |
| | | */ |
| | | @Service("mcsEvaluateService") |
| | | public class McsEvaluateServiceImpl extends ServiceImpl<McsEvaluateDAO, McsEvaluate> implements McsEvaluateService { |
| | | |
| | | @Resource |
| | | private McsCouponDAO mcsCouponDAO; |
| | | |
| | | /** |
| | | * 分页查询评价记录 |
| | |
| | | this.baseMapper.deleteById(evaluateId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 新增评价记录 |
| | | * @param mcsEvaluateDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R addMcsEvaluate(McsEvaluateDTO mcsEvaluateDTO) { |
| | | McsCoupon mcsCoupon = mcsCouponDAO.selectById(mcsEvaluateDTO.getCouponId()); |
| | | if (isNull(mcsCoupon)) { |
| | | return R.fail("资源不存在"); |
| | | } |
| | | McsEvaluate mcsEvaluate = this.baseMapper.selectOne(new QueryWrapper<McsEvaluate>().lambda().eq(McsEvaluate::getCouponId, mcsEvaluateDTO.getCouponId())); |
| | | if (nonNull(mcsEvaluate)) { |
| | | return R.fail("请勿重复评论"); |
| | | } |
| | | mcsEvaluate = new McsEvaluate(); |
| | | BeanUtils.copyProperties(mcsEvaluateDTO, mcsEvaluate); |
| | | mcsEvaluate.setGameId(mcsCoupon.getGameId()); |
| | | int num = this.baseMapper.insert(mcsEvaluate); |
| | | if (num > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("请求失败,请重试"); |
| | | } |
| | | } |