forked from kidgrow-microservices-platform

新增接口:判断用户名是否管理员,获取指定医院的所有有效套餐的读片总量
10 files modified
447 ■■■■■ changed files
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/java/com/kidgrow/oprationcenter/service/impl/ProductOrderRecordServiceImpl.java 18 ●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderDetailMapper.xml 14 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-server/src/main/java/com/kidgrow/oprationcenter/controller/ProductOrderRecordController.java 8 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/mapper/SysDoctorMapper.java 6 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/ISysDoctorService.java 6 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysDoctorServiceImpl.java 23 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysUserServiceImpl.java 158 ●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/resources/mapper/SysDoctorMapper.xml 16 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/resources/mapper/SysUserMapper.xml 190 ●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-server/src/main/java/com/kidgrow/usercenter/controller/SysDoctorController.java 8 ●●●●● patch | view | raw | blame | history
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/java/com/kidgrow/oprationcenter/service/impl/ProductOrderRecordServiceImpl.java
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
@@ -96,7 +97,7 @@
    }
    /**
     * 统计用户套餐使用情况
     * 统计用户所有套餐剩余
     * @param hospitalId
     * @param departmentId
     * @return
@@ -108,16 +109,25 @@
            Map<String,Object> selectMap=new HashMap<>();
            selectMap.put("hospitalId",hospitalId);
            List<ProductOrderJoinDetail>  productOrderDetailList=productOrderDetailService.findAllList(selectMap);
            Long userAICount=0l;
            if (productOrderDetailList.size()>0) {
                //
                //包含共享的数据
                List<ProductOrderJoinDetail> productOrderJoinDetailListShare=productOrderDetailList.stream().filter(f->f.getIsShare()).collect(Collectors.toList());
                //科室私有的数据
                List<ProductOrderJoinDetail> productOrderJoinDetailsListDep=productOrderDetailList.stream().filter((f->departmentId.equals(f.getDepartmentId())&&f.getIsShare()==false)).collect(Collectors.toList());
                //本医院可共享的读片总量
                Long shareCount=productOrderJoinDetailListShare.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount));
                //本科室私有读片总量
                Long depCount=productOrderJoinDetailsListDep.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount));
                //可用的总量
                userAICount=shareCount+depCount;
            }
            return null;
            return ResultBody.ok().data(userAICount);
        }
        else
        {
            return ResultBody.failed("医院和科室数据有误!");
        }
    }
    /**
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/resources/mapper/ProductOrderDetailMapper.xml
@@ -146,33 +146,21 @@
        <where>
            <!--查询条件自行添加-->
            DE.is_del=0 and DE.ailight_count>0 and DE.pro_begintime &lt;=now() and DE.pro_endtime >=now() and DE.enabled=1
            <if test="p.recordCount != null and p.recordCount !=''">
                and DE.record_count > #{p.recordCount}
            </if>
            <if test="p.hospitalId != null and p.hospitalId !=''">
                and DE.hospital_id = #{p.hospitalId}
                and PRO.hospital_id = #{p.hospitalId}
            </if>
        </where>
    </sql>
    <!--查询产品的购买记录-->
    <select id="findAllList" resultType="com.kidgrow.oprationcenter.vo.ProductOrderJoinDetail">
        SELECT
        DE.id,
        DE.ailight_count,
        DE.order_id,
        DE.pro_name,
        DE.record_count,
        DE.is_share,
        DE.pro_begintime,
        DE.pro_endtime,
        DE.pro_id,
        DE.create_time,
        DE.is_del,
        DE.enabled,
        PRO.hospital_Id,
        PRO.hospital_name,
        PRO.department_id,
        PRO.department_name,
        DE.pro_type
        FROM
        product_order_detail DE
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-server/src/main/java/com/kidgrow/oprationcenter/controller/ProductOrderRecordController.java
@@ -127,6 +127,14 @@
    }
    /**
     * 查询用户的套餐剩余量
     */
    @ApiOperation(value = "查询")
    @GetMapping("/biUserNowProduct")
    public ResultBody biUserNowProduct(@RequestParam long hospitalId, Long departmentId) {
        return productOrderRecordService.biUserNowProduct(hospitalId,departmentId);
    }
    /**
     * 查询
     */
    @ApiOperation(value = "查询")
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/mapper/SysDoctorMapper.java
@@ -31,4 +31,10 @@
     * @return SysDoctor对象
     */
    SysDoctor findByObject(@Param("p") SysDoctor sysDoctor);
    /**
     * 查询账户名是否管理员
     * @param userName
     * @return SysDoctor
     */
    SysDoctor userIsAdmin(String userName);
}
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/ISysDoctorService.java
@@ -50,5 +50,11 @@
     * @return
     */
    ResultBody setAdminDoctor(Map<String, Object> map);
    /**
     * H端检查用户名是否管理员
     * @param userName
     * @return
     */
    ResultBody userIsAdmin(String userName);
}
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysDoctorServiceImpl.java
@@ -5,6 +5,7 @@
import com.kidgrow.common.constant.SecurityConstants;
import com.kidgrow.common.model.*;
import com.kidgrow.common.service.impl.SuperServiceImpl;
import com.kidgrow.common.utils.StringUtils;
import com.kidgrow.redis.util.RedisConstant;
import com.kidgrow.redis.util.RedisUtils;
import com.kidgrow.usercenter.mapper.SysDoctorMapper;
@@ -288,4 +289,26 @@
            return ResultBody.failed("业务参数有误!").data(false);
        }
    }
    /**
     * 判断用户名是否管理员
     * @param userName
     * @return
     */
    @Override
    public ResultBody userIsAdmin(String userName) {
        if (StringUtils.isNotBlank(userName)) {
            SysDoctor sysDoctor= baseMapper.userIsAdmin(userName);
            if (sysDoctor != null) {
                return ResultBody.ok().data(sysDoctor.getIsAdminUser());
            }
            else
            {
                return ResultBody.failed().data(false);
            }
        }else
        {
            return ResultBody.failed("用户名不能为空!").data(false);
        }
    }
}
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysUserServiceImpl.java
@@ -101,8 +101,8 @@
    }
    /**
     *
     * 获取登录用户的一系列信息 hrj 06-04修改
     *
     * @param sysUser
     * @return
     */
@@ -130,7 +130,7 @@
                }
            }
            //是否医院管理员
            com.kidgrow.usercenter.model.SysDoctor sysDoctor=findDoctorByUserId(sysUser.getId());
            com.kidgrow.usercenter.model.SysDoctor sysDoctor = findDoctorByUserId(sysUser.getId());
            if (sysDoctor.getIsAdminUser() != null) {
                sysUser.setHAdminUser(sysDoctor.getIsAdminUser());
            }
@@ -215,7 +215,7 @@
    @Transactional
    @Override
    public ResultBody updatePassword(Long id, String oldPassword, String newPassword,Boolean isdefault) {
    public ResultBody updatePassword(Long id, String oldPassword, String newPassword, Boolean isdefault) {
        SysUser sysUser = baseMapper.selectById(id);
        if (StrUtil.isNotBlank(oldPassword)) {
            if (!passwordEncoder.matches(oldPassword, sysUser.getPassword())) {
@@ -223,7 +223,7 @@
            }
        }
        if (StrUtil.isBlank(newPassword)) {
            newPassword =com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
            newPassword = com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
        }
        SysUser user = new SysUser();
        user.setId(id);
@@ -232,10 +232,9 @@
            user.setDefaultAuth(true);
        }
        baseMapper.updateById(user);
        if (isdefault){
        if (isdefault) {
            return ResultBody.ok().msg("密码重置成功!").data(newPassword);
        }
        else{
        } else {
            return ResultBody.ok().msg("密码修改成功!").data(true);
        }
    }
@@ -249,7 +248,7 @@
        String authCode = MapUtils.getString(params, "authCode");
        String userPassword = MapUtils.getString(params, "userPassword");
        if (id > 0 && StringUtils.isNotBlank(oldTel)&& StringUtils.isNotBlank(newTel) && StringUtils.isNotBlank(authCode) && StringUtils.isNotBlank(userPassword)) {
        if (id > 0 && StringUtils.isNotBlank(oldTel) && StringUtils.isNotBlank(newTel) && StringUtils.isNotBlank(authCode) && StringUtils.isNotBlank(userPassword)) {
            //检查验证码
            Object hget = redisUtils.hget(ConstantSMS.PHONE_SMS, newTel);
            if (hget != null) {
@@ -277,9 +276,9 @@
                                user.setMobile(newTel);
                                user.setUsername(newTel);
                                //修改doctor表
                                com.kidgrow.usercenter.model.SysDoctor sysDoctorModel= findDoctorByUserId(user.getId());
                                com.kidgrow.usercenter.model.SysDoctor newsysDoctorModel= new com.kidgrow.usercenter.model.SysDoctor();
                                if (sysDoctorModel!=null) {
                                com.kidgrow.usercenter.model.SysDoctor sysDoctorModel = findDoctorByUserId(user.getId());
                                com.kidgrow.usercenter.model.SysDoctor newsysDoctorModel = new com.kidgrow.usercenter.model.SysDoctor();
                                if (sysDoctorModel != null) {
                                    //理论上只有一个,如果有多个 只取第一个
                                    newsysDoctorModel.setId(sysDoctorModel.getId());
                                    newsysDoctorModel.setDoctorTel(newTel);
@@ -287,7 +286,7 @@
                                }
                                if (baseMapper.updateById(user) > 0) {
                                    //将Redis清除
                                    redisUtils.hdel(ConstantSMS.PHONE_SMS,newTel);
                                    redisUtils.hdel(ConstantSMS.PHONE_SMS, newTel);
                                    return ResultBody.ok().msg("手机号修改成功!");
                                } else {
                                    return ResultBody.failed("手机号修改失败!");
@@ -359,7 +358,7 @@
            if (StringUtils.isBlank(sysUser.getType())) {
                sysUser.setType(UserType.BACKEND.name());
            }
            String defaultPassWord=com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
            String defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
            sysUser.setPassword(passwordEncoder.encode(defaultPassWord));
            sysUser.setEnabled(Boolean.TRUE);
        }
@@ -447,6 +446,7 @@
    /**
     * 通过手机号  修改密码
     *
     * @param map
     * @return
     */
@@ -503,6 +503,7 @@
    /**
     * 通过手机号 注册验证
     *
     * @param map
     * @return
     */
@@ -517,19 +518,20 @@
            return ResultBody.failed("该手机号已经注册");
        }
        Map<String, Object> mapDto=new HashMap();
        mapDto.put("phone",phone);
        mapDto.put("type",ConstantSMS.REGISTER_SMS);
        Map<String, Object> mapDto = new HashMap();
        mapDto.put("phone", phone);
        mapDto.put("type", ConstantSMS.REGISTER_SMS);
        return smsChuangLanService.sendVerificationCode(mapDto);
    }
    /**
     * 通过手机号修改 手机号
     *
     * @param map
     * @return
     */
    @Override
    public ResultBody updatePhone(Map<String, Object> map,SysUser sysUser) {
    public ResultBody updatePhone(Map<String, Object> map, SysUser sysUser) {
        String password = MapUtils.getString(map, "password");
        if (StringUtils.isBlank(password)) {
            return ResultBody.failed("请输入密码");
@@ -538,14 +540,14 @@
        if (StringUtils.isBlank(phone)) {
            return ResultBody.failed("请输入新手机号");
        }
        if(!sysUser.getMobile().equals(password)){
        if (!sysUser.getMobile().equals(password)) {
            return ResultBody.failed("请输入原手机号");
        }
        String verificationCode = MapUtils.getString(map, "verificationCode");
        if (StringUtils.isBlank(verificationCode)) {
            return ResultBody.failed("请输入验证码");
        }
        if (!passwordEncoder.matches(sysUser.getPassword(),password)) {
        if (!passwordEncoder.matches(sysUser.getPassword(), password)) {
            return ResultBody.failed("密码错误");
        }
        Object hget = redisUtils.hget(ConstantSMS.PHONE_SMS, map.get("phone").toString());
@@ -586,24 +588,27 @@
    @Override
    public ResultBody findAppointUsers(Integer type) {
    List<SysUser> list = baseMapper.findAppointUsers(type);
    return ResultBody.ok().data(list);
}
        List<SysUser> list = baseMapper.findAppointUsers(type);
        return ResultBody.ok().data(list);
    }
    /**
     * 根据userid获取用户其它信息
     *
     * @param userId
     * @return
     */
    @Override
    public ResultBody findDoctorUserAllData(Long userId) {
        if (userId>0) {
        if (userId > 0) {
            return ResultBody.ok().data(baseMapper.findDoctorUserAllData(userId));
        }
        return ResultBody.ok().data(null);
    }
    /**
     * H端用户注册  管理员添加用户
     *
     * @param userRegVo
     * @return
     */
@@ -617,24 +622,24 @@
        if (StringUtils.isBlank(userRegVo.getHospitalId().toString())) {
            userRegVo.setDoctorState(true);
            //添加医院组织结构数据
            List<SysOrganization> sysOrganizationList=new ArrayList<SysOrganization>();
            SysOrganization sysOrganizationHos=new SysOrganization();
            List<SysOrganization> sysOrganizationList = new ArrayList<SysOrganization>();
            SysOrganization sysOrganizationHos = new SysOrganization();
            sysOrganizationHos.setOrgAttr(1);
            sysOrganizationHos.setOrgLevel(1);
            sysOrganizationHos.setOrgName(userRegVo.getHospitalName());
            sysOrganizationList.add(sysOrganizationHos);
            //添加科室组织数据
            SysOrganization sysOrganizationDe=new SysOrganization();
            SysOrganization sysOrganizationDe = new SysOrganization();
            sysOrganizationDe.setOrgAttr(2);
            sysOrganizationDe.setOrgLevel(2);
            sysOrganizationDe.setOrgName(userRegVo.getDepartmentName());
            sysOrganizationList.add(sysOrganizationDe);
            //批量写入
            boolean orgRe= organizationService.saveBatch(sysOrganizationList);
            boolean orgRe = organizationService.saveBatch(sysOrganizationList);
            if (orgRe) {
                //写医院数据
                SysHospital sysHospital=new SysHospital();
                SysHospital sysHospital = new SysHospital();
                sysHospital.setHospitalName(userRegVo.getHospitalName());
                sysHospital.setOrgId(sysOrganizationHos.getId());
                sysHospital.setAccountsCount(1);
@@ -642,11 +647,11 @@
                sysHospital.setCreateUserId(0L);
                sysHospital.setCreateUserName("自主注册");
                boolean h=hospitalService.save(sysHospital);
                boolean h = hospitalService.save(sysHospital);
                if (h) {
                    userRegVo.setHospitalId(sysHospital.getId());
                    //保存科室数据
                    SysDepartment sysDepartment=new SysDepartment();
                    SysDepartment sysDepartment = new SysDepartment();
                    sysDepartment.setHospitalId(sysHospital.getId());
                    sysDepartment.setOrgId(sysOrganizationDe.getId());
                    sysDepartment.setDepartmentName(userRegVo.getDepartmentName());
@@ -655,37 +660,30 @@
                    sysDepartment.setSaleUserTel("0");
                    sysDepartment.setServerUserId(0L);
                    sysDepartment.setServerUserTel("0");
                    boolean d=departmentService.save(sysDepartment);
                    boolean d = departmentService.save(sysDepartment);
                    if (!d) {
                        return ResultBody.failed("科室数据写入失败");
                    }
                    else
                    {
                    } else {
                        userRegVo.setDepartmentId(sysDepartment.getId());
                    }
                }
                else
                {
                } else {
                    return ResultBody.failed("医院数据写入失败");
                }
            }
            else
            {
            } else {
                return ResultBody.failed("组织数据写入失败");
            }
        }
        //添加用户数据  如果没有输入密码,将会创建一个默认密码返回
        String defaultPassWord="";
        SysUser sysUser=new SysUser();
        String defaultPassWord = "";
        SysUser sysUser = new SysUser();
        sysUser.setUsername(userRegVo.getUsername());
        sysUser.setMobile(userRegVo.getMobile());
        if (StringUtils.isBlank(userRegVo.getPassword())) {
            defaultPassWord=com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
            defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6);
            sysUser.setPassword(passwordEncoder.encode(defaultPassWord));
            sysUser.setDefaultAuth(true);
            userRegVo.setPassword(defaultPassWord);
        }
        else {
        } else {
            sysUser.setPassword(passwordEncoder.encode(userRegVo.getPassword()));
            sysUser.setDefaultAuth(false);
        }
@@ -694,35 +692,30 @@
        sysUser.setEnabled(true);
        if (StringUtils.isNotBlank(userRegVo.getType())) {
            sysUser.setType(userRegVo.getType());
        }
        else
        {
        } else {
            sysUser.setType(UserType.DOCTOR.name());
        }
        sysUser.setHAdminUser(false);
        sysUser.setOpenId(userRegVo.getOpenId());
        sysUser.setDel(false);
        boolean u=this.save(sysUser);
        if(u)
        {
        boolean u = this.save(sysUser);
        if (u) {
            //写入职务数据
            if (StringUtils.isNotBlank(userRegVo.getDoctorRank())) {
                //检查医生职务是否存在
                Map<String, Object> selectMap = new HashMap<>();
                selectMap.put("dictionaries_name", userRegVo.getDoctorRank());
                List<SysDictionaries> dictionariesList=sysDictionariesService.findAll(selectMap);
                if (dictionariesList.size()>0) {
                List<SysDictionaries> dictionariesList = sysDictionariesService.findAll(selectMap);
                if (dictionariesList.size() > 0) {
                    for (int i = dictionariesList.size() - 1; i >= 0; i--) {
                        if (dictionariesList.get(i).getDictionariesName().equals(userRegVo.getDoctorRank())) {
                            userRegVo.setDoctorRankId(dictionariesList.get(i).getId());
                            break;
                        }
                    }
                }
                else
                {
                } else {
                    //创建字典数据
                    SysDictionaries sysDictionaries=new SysDictionaries();
                    SysDictionaries sysDictionaries = new SysDictionaries();
                    sysDictionaries.setDictionariesKey(DictionariesConstants.DOCTOR_RANK);
                    sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK_ID.toString());
                    //将名称汉字转为拼音
@@ -730,14 +723,14 @@
                    sysDictionaries.setDictionariesName(userRegVo.getDoctorRank());
                    sysDictionaries.setCreateUserId(0L);
                    sysDictionaries.setCreateUserName("自动创建");
                    boolean d=sysDictionariesService.save(sysDictionaries);
                    boolean d = sysDictionariesService.save(sysDictionaries);
                    if (d) {
                        userRegVo.setDoctorRankId(sysDictionaries.getId());
                    }
                }
            }
            //写入医生数据
            SysDoctor sysDoctor=new SysDoctor();
            SysDoctor sysDoctor = new SysDoctor();
            sysDoctor.setUserId(sysUser.getId());
            sysDoctor.setHospitalId(userRegVo.getHospitalId());
            sysDoctor.setHospitalName(userRegVo.getHospitalName());
@@ -752,56 +745,61 @@
            sysDoctor.setDoctorName(userRegVo.getNickname());
            sysDoctor.setServerUserId(0L);
            sysDoctor.setServerUserName("自主注册");
            if (sysDoctorMapper.insert(sysDoctor)==1) {
            if (sysDoctorMapper.insert(sysDoctor) == 1) {
                sysUser.setPassword(userRegVo.getPassword());
                return ResultBody.ok(200,"注册成功").data(sysUser);
            }
            else
            {
                return ResultBody.ok(200, "注册成功").data(sysUser);
            } else {
                return ResultBody.failed("医生数据写入失败");
            }
        }
        else
        {
        } else {
            return ResultBody.failed("用户数据写入失败");
        }
    }
    /**
     * 检查手机号是否已经注册 true存在  false不存在
     *
     * @param phone
     * @return
     */
    private boolean phoneIsUsed(String phone)
    {
    private boolean phoneIsUsed(String phone) {
        Map<String, Object> selectMap = new HashMap<>();
        selectMap.put("mobile", phone);
        List<SysUser> sysUsers = baseMapper.selectByMap(selectMap);
        return (sysUsers.size()>0);
        return (sysUsers.size() > 0);
    }
    /**
     * 检查用户登录名是否已经注册 true存在  false不存在
     *
     * @param userName
     * @return
     */
    private boolean userNameIsUsed(String userName)
    {
    private boolean userNameIsUsed(String userName) {
        Map<String, Object> selectMap = new HashMap<>();
        selectMap.put("username", userName);
        List<SysUser> sysUsers = baseMapper.selectByMap(selectMap);
        return (sysUsers.size()>0);
        return (sysUsers.size() > 0);
    }
    public com.kidgrow.usercenter.model.SysDoctor findDoctorByUserId(Long userId)
    {
    public com.kidgrow.usercenter.model.SysDoctor findDoctorByUserId(Long userId) {
        Map<String, Object> doctorMap = new HashMap<>();
        doctorMap.put("user_id",userId);
        doctorMap.put("enabled",1);
        doctorMap.put("is_del",0);
        List<com.kidgrow.usercenter.model.SysDoctor> sysDoctorList=sysDoctorMapper.selectByMap(doctorMap);
        if (sysDoctorList.size()>0) {
        doctorMap.put("user_id", userId);
        doctorMap.put("enabled", 1);
        doctorMap.put("is_del", 0);
        List<com.kidgrow.usercenter.model.SysDoctor> sysDoctorList = sysDoctorMapper.selectByMap(doctorMap);
        if (sysDoctorList.size() > 0) {
            return sysDoctorList.get(0);
        }
        return new com.kidgrow.usercenter.model.SysDoctor();
    }
    public ResultBody userIsAdmin(String userName) {
        Map<String, Object> selectMap = new HashMap<>();
        selectMap.put("username", userName);
        List<SysUser> sysUsers = baseMapper.selectByMap(selectMap);
        return null;
    }
}
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/resources/mapper/SysDoctorMapper.xml
@@ -112,4 +112,20 @@
        <include refid="where"/>
        order by id desc
    </select>
    <select id="userIsAdmin" parameterType="string" resultType="com.kidgrow.usercenter.model.SysDoctor">
        SELECT
        is_admin_user
        FROM
            sys_doctor
        WHERE
        user_id IN (
        SELECT
            id
        FROM
            sys_user
        WHERE
        username = #{userName}
        OR mobile = #{userName})
    </select>
</mapper>
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/resources/mapper/SysUserMapper.xml
@@ -2,102 +2,104 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kidgrow.usercenter.mapper.SysUserMapper">
    <sql id="where">
        <where>
            t.is_del=0
            <if test="u.id != null and u.id != ''">
                and t.id like concat('%', #{u.id}, '%')
            </if>
            <if test="u.username != null and u.username != ''">
                and t.username like concat('%', #{u.username}, '%')
            </if>
            <if test="u.nickname != null and u.nickname != ''">
                and t.nickname like concat('%', #{u.nickname}, '%')
            </if>
            <if test="u.enabled != null and u.enabled != ''">
                and t.enabled = #{u.enabled}
            </if>
            <if test="u.type != null and u.type != ''">
                and t.type = #{u.type}
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='user_id'">
                and t.id  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='username'">
                and t.username  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='nick_name'">
                and t.nickname  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='mobile'">
                and t.mobile  like concat('%', #{u.searchValue}, '%')
            </if>
        </where>
    </sql>
    <sql id="where_map">
        <where>
            <if test="u.id != null and u.id != ''">
                and t.id like concat('%', #{u.id}, '%')
            </if>
            <if test="u.username != null and u.username != ''">
                and t.username = #{u.username}
            </if>
            <if test="u.nickname != null and u.nickname != ''">
                and t.nickname like concat('%', #{u.nickname}, '%')
            </if>
            <if test="u.enabled != null and u.enabled != ''">
                and t.enabled = #{u.enabled}
            </if>
            <if test="u.type != null and u.type != ''">
                and t.type = #{u.type}
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='user_id'">
                and t.id  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='username'">
                and t.username  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='nick_name'">
                and t.nickname  like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='mobile'">
                and t.mobile  like concat('%', #{u.searchValue}, '%')
            </if>
        </where>
    </sql>
    <sql id="where">
        <where>
            t.is_del=0
            <if test="u.id != null and u.id != ''">
                and t.id like concat('%', #{u.id}, '%')
            </if>
            <if test="u.username != null and u.username != ''">
                and t.username like concat('%', #{u.username}, '%')
            </if>
            <if test="u.nickname != null and u.nickname != ''">
                and t.nickname like concat('%', #{u.nickname}, '%')
            </if>
            <if test="u.enabled != null and u.enabled != ''">
                and t.enabled = #{u.enabled}
            </if>
            <if test="u.type != null and u.type != ''">
                and t.type = #{u.type}
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='user_id'">
                and t.id like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='username'">
                and t.username like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='nick_name'">
                and t.nickname like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='mobile'">
                and t.mobile like concat('%', #{u.searchValue}, '%')
            </if>
        </where>
    </sql>
    <sql id="where_map">
        <where>
            <if test="u.id != null and u.id != ''">
                and t.id like concat('%', #{u.id}, '%')
            </if>
            <if test="u.username != null and u.username != ''">
                and t.username = #{u.username}
            </if>
            <if test="u.nickname != null and u.nickname != ''">
                and t.nickname like concat('%', #{u.nickname}, '%')
            </if>
            <if test="u.enabled != null and u.enabled != ''">
                and t.enabled = #{u.enabled}
            </if>
            <if test="u.type != null and u.type != ''">
                and t.type = #{u.type}
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='user_id'">
                and t.id like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='username'">
                and t.username like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='nick_name'">
                and t.nickname like concat('%', #{u.searchValue}, '%')
            </if>
            <if test="u.searchKey != null and u.searchKey != '' and u.searchKey=='mobile'">
                and t.mobile like concat('%', #{u.searchValue}, '%')
            </if>
        </where>
    </sql>
    <select id="findList" resultType="com.kidgrow.common.model.SysUser">
        select * from sys_user t
        <include refid="where" />
        order by t.id desc
    </select>
    <select id="selectCountByMap" parameterType="map" resultType="integer">
        select count(*) from  sys_user t <include refid="where_map" />
    </select>
    <select id="findList" resultType="com.kidgrow.common.model.SysUser">
        select * from sys_user t
        <include refid="where"/>
        order by t.id desc
    </select>
    <select id="selectCountByMap" parameterType="map" resultType="integer">
        select count(*) from sys_user t
        <include refid="where_map"/>
    </select>
    <select id="findAppointUsers" parameterType="integer" resultType="com.kidgrow.common.model.SysUser">
        SELECT
            USERS.id,
            USERS.nickname,
            USERS.mobile
        FROM
            `sys_role_user`  RU
            LEFT JOIN sys_user USERS ON RU.user_id = USERS.id
            LEFT JOIN sys_role ROLE  ON RU.role_id = ROLE.id
        WHERE
            USERS.is_del = 0
            <if test="type == 0">
                AND ROLE.`code` IN (
                'salemanager',
                'sale')
            </if>
            <if test="type == 1">
                AND ROLE.`code` IN (
                'oprationmanager',
                'opration')
            </if>
    </select>
    <select  id="findDoctorUserAllData"  resultType="com.kidgrow.common.model.DoctorUserAll">
    <select id="findAppointUsers" parameterType="integer" resultType="com.kidgrow.common.model.SysUser">
        SELECT
        USERS.id,
        USERS.nickname,
        USERS.mobile
        FROM
        `sys_role_user` RU
        LEFT JOIN sys_user USERS ON RU.user_id = USERS.id
        LEFT JOIN sys_role ROLE ON RU.role_id = ROLE.id
        WHERE
        USERS.is_del = 0
        <if test="type == 0">
            AND ROLE.`code` IN (
            'salemanager',
            'sale')
        </if>
        <if test="type == 1">
            AND ROLE.`code` IN (
            'oprationmanager',
            'opration')
        </if>
    </select>
    <select id="findDoctorUserAllData" resultType="com.kidgrow.common.model.DoctorUserAll">
        SELECT sysuser.id,
        sysdoctor.doctor_name,
        sysdoctor.doctor_ccie,
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-server/src/main/java/com/kidgrow/usercenter/controller/SysDoctorController.java
@@ -71,6 +71,14 @@
        return ResultBody.ok().data(model).msg("查询成功");
    }
    /**
     * 判断用户名是否管理员
     */
    @ApiOperation(value = "判断用户名是否管理员")
    @GetMapping("/userName")
    public ResultBody findById(@RequestParam String userName) {
        return sysDoctorService.userIsAdmin(userName);
    }
    /**
     * 根据 Map 查询
     */
    @ApiOperation(value = "查询")