package com.xzx.gc.user.service; import cn.hutool.core.bean.BeanUtil; import com.xzx.gc.common.exception.RestException; import com.xzx.gc.entity.JhyInfo; import com.xzx.gc.user.dto.JhyApplyDto; import com.xzx.gc.user.mapper.JhyInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import java.util.Date; public class JhyInfoService { @Autowired private JhyInfoMapper jhyInfoMapper; public void applyJhy(JhyApplyDto applyDto) { JhyInfo mobileIsExist = jhyInfoMapper.selectExistJhyByIndeityOrMobile(applyDto.getMobile(), applyDto.getIdentity()); if (mobileIsExist != null) { if (applyDto.getUserId().equals(mobileIsExist.getUserId())) { throw new RestException(-3, "审核中或审核成功, 请勿重复提交"); } throw new RestException(-3, "手机号/身份证号已注册集物员"); } JhyInfo jhyInfo = new JhyInfo(); BeanUtil.copyProperties(applyDto, jhyInfo); jhyInfo.setCreatedTime(new Date()); jhyInfoMapper.insert(jhyInfo); } public int applyStatus(String userId) { JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId); if (jhyInfo == null) { return 0; } return jhyInfo.getStatus(); } }