forked from kidgrow-microservices-platform

zhaoxiaohao
2020-06-24 4dabf145f35d9cedc37804cee8d36cf437766699
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysDoctorServiceImpl.java
@@ -110,6 +110,17 @@
        return true;
    }
    /**
     * 根据userid删除医生数据
     * @param userId
     * @return
     */
    @Override
    public int deleteByUserId(Long userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        return baseMapper.deleteByMap(params);
    }
    @Override
    public ResultBody enable(Map<String, Object> params) {
        Long aLong = MapUtils.getLong(params,"id");
@@ -133,7 +144,7 @@
    }
    @Override
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdateSer(SysDoctorDto sysDoctor, HttpServletRequest request,SysUser user) {
        String id = request.getHeader(SecurityConstants.USER_ID_HEADER);
        if(null==sysDoctor){
@@ -228,19 +239,23 @@
    }
    @Override
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public ResultBody setAdminDoctor(Map<String, Object> params) {
        Long id = MapUtils.getLong(params, "id");
        Long adminId = MapUtils.getLong(params, "adminId");
        if (id>0&&adminId>0) {
            Map<String,Object> map= new HashMap<>();
            map.put("id",adminId);
            SysDoctor sysDoctor=baseMapper.selectById(adminId);
            map.put("user_id",adminId);
            List<SysDoctor> sysDoctors = baseMapper.selectByMap(map);
            if(sysDoctors==null||sysDoctors.size()<=0){
                return ResultBody.failed("当前操作用户不是管理员");
            }
            SysDoctor sysDoctor = sysDoctors.get(0);
            //先检查操作用户是否管理员
            if(sysDoctor!=null){
                if (sysDoctor.getIsAdminUser()) {
                    //现将操作人员设为非管理
                    sysDoctor=new SysDoctor();
//                    sysDoctor=new SysDoctor();
                    sysDoctor.setIsAdminUser(false);
                    if(baseMapper.updateById(sysDoctor)>0)
                    {
@@ -248,7 +263,7 @@
                        sysDoctor=baseMapper.selectById(id);
                        if (sysDoctor != null) {
                            if (!sysDoctor.getIsAdminUser()) {
                                sysDoctor=new SysDoctor();
//                                sysDoctor=new SysDoctor();
                                sysDoctor.setIsAdminUser(true);
                                if (baseMapper.updateById(sysDoctor)>0) {
                                    return ResultBody.ok().data(true).msg("管理员设置成功!");