|
|
@@ -1,20 +1,122 @@
|
|
|
package com.template.services.impl;
|
|
|
|
|
|
-import com.template.model.pojo.WelcomeVisitor;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.template.common.exception.MyCustomException;
|
|
|
+import com.template.common.result.ResponseStatusEnum;
|
|
|
+import com.template.common.utils.BeanUtil;
|
|
|
+import com.template.common.utils.IPageUtil;
|
|
|
import com.template.mapper.WelcomeVisitorMapper;
|
|
|
+import com.template.model.pojo.WelcomeVisitor;
|
|
|
+import com.template.model.query.WelcomeVisitorQuery;
|
|
|
+import com.template.model.request.WelcomeVisitorRequest;
|
|
|
+import com.template.model.result.PageUtils;
|
|
|
+import com.template.model.vo.WelcomeVisitorVO;
|
|
|
import com.template.services.WelcomeVisitorService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-/**
|
|
|
- * <p>
|
|
|
- * 服务实现类
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @author ceshi
|
|
|
- * @since 2025-06-16
|
|
|
- */
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Service
|
|
|
public class WelcomeVisitorServiceImpl extends ServiceImpl<WelcomeVisitorMapper, WelcomeVisitor> implements WelcomeVisitorService {
|
|
|
|
|
|
+ @Override
|
|
|
+ public void addVisitor(WelcomeVisitorRequest visitorRequest) {
|
|
|
+ // TODO 获取studyCard
|
|
|
+ String studyCard = "";
|
|
|
+
|
|
|
+ // 查询当前用户是否已有访客记录
|
|
|
+ LambdaQueryWrapper<WelcomeVisitor> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(WelcomeVisitor::getStudentCard, studyCard);
|
|
|
+ if (this.count(queryWrapper) > 0) {
|
|
|
+ throw new MyCustomException(ResponseStatusEnum.EXISTS);
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO 查询学生学费缴纳情况
|
|
|
+
|
|
|
+ // 新增访客记录
|
|
|
+ WelcomeVisitor visitor = new WelcomeVisitor();
|
|
|
+ BeanUtils.copyProperties(visitorRequest, visitor);
|
|
|
+ visitor.setStudentCard(studyCard);
|
|
|
+
|
|
|
+ save(visitor);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WelcomeVisitorVO getByCurUser() {
|
|
|
+ // TODO 获取studyCard
|
|
|
+ String studyCard = "";
|
|
|
+
|
|
|
+ LambdaQueryWrapper<WelcomeVisitor> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(WelcomeVisitor::getStudentCard, studyCard);
|
|
|
+
|
|
|
+ WelcomeVisitor visitor = this.getOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isNull(visitor)) {
|
|
|
+ throw new MyCustomException(ResponseStatusEnum.DATA_NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ WelcomeVisitorVO vo = new WelcomeVisitorVO();
|
|
|
+ BeanUtils.copyProperties(visitor, vo);
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WelcomeVisitorVO getOneById(Long id) {
|
|
|
+ WelcomeVisitor visitor = this.getById(id);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(visitor)) {
|
|
|
+ throw new MyCustomException(ResponseStatusEnum.DATA_NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ WelcomeVisitorVO vo = new WelcomeVisitorVO();
|
|
|
+ BeanUtils.copyProperties(visitor, vo);
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteByCurUser() {
|
|
|
+ // TODO 获取studyCard
|
|
|
+ String studyCard = "";
|
|
|
+
|
|
|
+ LambdaQueryWrapper<WelcomeVisitor> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(WelcomeVisitor::getStudentCard, studyCard);
|
|
|
+
|
|
|
+ remove(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addVisitorByAdmin(WelcomeVisitorRequest visitorRequest) {
|
|
|
+ // 查询当前用户是否已有访客记录
|
|
|
+ LambdaQueryWrapper<WelcomeVisitor> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(WelcomeVisitor::getStudentCard, visitorRequest.getStudentCard());
|
|
|
+ if (this.count(queryWrapper) > 0) {
|
|
|
+ throw new MyCustomException(ResponseStatusEnum.EXISTS);
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO 查询学生学费缴纳情况
|
|
|
+
|
|
|
+ // 新增访客记录
|
|
|
+ WelcomeVisitor visitor = new WelcomeVisitor();
|
|
|
+ BeanUtils.copyProperties(visitorRequest, visitor);
|
|
|
+
|
|
|
+ save(visitor);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageUtils<WelcomeVisitorVO> page(WelcomeVisitorQuery visitorQuery) {
|
|
|
+ LambdaQueryWrapper<WelcomeVisitor> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.like(StrUtil.isNotBlank(visitorQuery.getCarNumber()), WelcomeVisitor::getCarNumber, visitorQuery.getCarNumber());
|
|
|
+ wrapper.like(StrUtil.isNotBlank(visitorQuery.getName()), WelcomeVisitor::getName, visitorQuery.getName());
|
|
|
+
|
|
|
+ IPage<WelcomeVisitor> page = baseMapper.selectPage(new IPageUtil<WelcomeVisitor>().getPage(visitorQuery), wrapper);
|
|
|
+
|
|
|
+ List<WelcomeVisitorVO> welcomeVisitorVOS = BeanUtil.copyListProperties(page.getRecords(), WelcomeVisitorVO::new);
|
|
|
+ return new PageUtils<>(welcomeVisitorVOS, (int) page.getTotal(), (int) page.getSize(), (int) page.getCurrent());
|
|
|
+ }
|
|
|
}
|