kongzy
2023-11-27 59ae9759fd50568059fa44f43832f5a414edb3e9
assess-system/src/main/java/com/gkhy/assess/system/service/impl/SysUserServiceImpl.java
@@ -7,6 +7,7 @@
import com.gkhy.assess.common.constant.CacheConstant;
import com.gkhy.assess.common.domain.vo.AccountVO;
import com.gkhy.assess.common.domain.vo.LoginBody;
import com.gkhy.assess.common.enums.AttachTypeEnum;
import com.gkhy.assess.common.enums.UserIdentityEnum;
import com.gkhy.assess.common.enums.UserTypeEnum;
import com.gkhy.assess.common.exception.ApiException;
@@ -17,6 +18,7 @@
import com.gkhy.assess.system.domain.*;
import com.gkhy.assess.system.mapper.SysAgencyMapper;
import com.gkhy.assess.system.mapper.SysUserMapper;
import com.gkhy.assess.system.service.SysAttachService;
import com.gkhy.assess.system.service.SysConfigService;
import com.gkhy.assess.system.utils.ShiroUtils;
import com.gkhy.assess.system.service.SysUserService;
@@ -30,6 +32,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.validation.Validator;
import java.util.ArrayList;
import java.util.List;
@@ -55,11 +58,14 @@
    @Autowired
    private SysAgencyMapper agencyMapper;
    @Autowired
    private SysAttachService attachService;
    @Override
    public AccountVO login(LoginBody loginBody) {
        // 验证码校验
        validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid());
       // validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid());
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(loginBody.getUsername(), loginBody.getPassword(), false);
        Subject subject= SecurityUtils.getSubject();
        String msg ;
@@ -202,6 +208,7 @@
    }
    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public int addExpert(SysUser user) {
        //校验用户信息
        if(!checkUsernameUnique(new SysUser().setUsername(user.getUsername()))){
@@ -216,6 +223,26 @@
        if(!b){
            throw new ApiException("创建专家信息失败");
        }
        List<SysAttach> socialAttach=user.getSocialAttach();
        List<SysAttach> medicalAttach=user.getMedicalAttach();
        List<SysAttach> salaryAttach=user.getSalaryAttach();
        List<SysAttach> attaches=new ArrayList<>();
        for(SysAttach attach:socialAttach){
            attach.setType(AttachTypeEnum.SOCIAL.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        for(SysAttach attach:medicalAttach){
            attach.setType(AttachTypeEnum.MEDICAL.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        for(SysAttach attach:salaryAttach){
            attach.setType(AttachTypeEnum.SALARY.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        attachService.saveBatch(attaches);
        return 1;
    }
@@ -281,6 +308,30 @@
        if(!b){
            throw new ApiException("更新专家信息失败");
        }
        //刪除旧数据
        attachService.deleteAttachsByUserId(user.getId(),null);
        List<SysAttach> socialAttach=user.getSocialAttach();
        List<SysAttach> medicalAttach=user.getMedicalAttach();
        List<SysAttach> salaryAttach=user.getSalaryAttach();
        List<SysAttach> attaches=new ArrayList<>();
        for(SysAttach attach:socialAttach){
            attach.setType(AttachTypeEnum.SOCIAL.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        for(SysAttach attach:medicalAttach){
            attach.setType(AttachTypeEnum.MEDICAL.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        for(SysAttach attach:salaryAttach){
            attach.setType(AttachTypeEnum.SALARY.getCode());
            attach.setUserId(user.getId());
            attaches.add(attach);
        }
        attachService.saveBatch(attaches);
        return 1;
    }