14 files modified
8 files added
| | |
| | | * @return |
| | | */ |
| | | ResultBody getTree(Map<String, Object> params); |
| | | |
| | | boolean saveOrUpdateSer(SysOrganization sysOrganization); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<SysCompanyVo> findList(Map<String, Object> params){ |
| | | public PageResult findList(Map<String, Object> params){ |
| | | Page<SysCompany> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysCompany> list = baseMapper.findList(page, params); |
| | | List<SysCompanyVo> listVo=new ArrayList<>(); |
| | | list.forEach(e -> { |
| | | SysCompanyVo vo=new SysCompanyVo(); |
| | | BeanCopier beanCopier = BeanCopier.create(SysCompany.class, SysCompanyVo.class, false); |
| | | beanCopier.copy(e,vo,null); |
| | | if(vo.getCompanyArea()!=null){ |
| | | SysArea byId = sysAreaService.getById(vo.getCompanyArea()); |
| | | if(byId.getAreaLeveltype()==XIAN){ |
| | | vo.setXianId(byId.getId()); |
| | | vo.setXian(byId.getAreaName()); |
| | | SysArea shi = sysAreaService.getById(byId.getAreaParentId()); |
| | | if(shi!=null){ |
| | | vo.setShi(shi.getAreaName()); |
| | | vo.setShiId(shi.getId()); |
| | | SysArea sheng = sysAreaService.getById(shi.getAreaParentId()); |
| | | if (sheng != null) { |
| | | vo.setSheng(sheng.getAreaName()); |
| | | vo.setShengId(sheng.getId()); |
| | | } |
| | | } |
| | | } |
| | | if(byId.getAreaLeveltype()==SHI){ |
| | | vo.setShi(byId.getAreaName()); |
| | | vo.setShiId(byId.getId()); |
| | | SysArea sheng = sysAreaService.getById(byId.getAreaParentId()); |
| | | if (sheng != null) { |
| | | vo.setSheng(sheng.getAreaName()); |
| | | vo.setShengId(sheng.getId()); |
| | | } |
| | | } |
| | | if(byId.getAreaLeveltype()==SHENG){ |
| | | vo.setSheng(byId.getAreaName()); |
| | | vo.setShengId(byId.getId()); |
| | | } |
| | | } |
| | | listVo.add(vo); |
| | | }); |
| | | return PageResult.<SysCompanyVo>builder().data(listVo).code(0).count(page.getTotal()).build(); |
| | | // List<SysCompanyVo> listVo=new ArrayList<>(); |
| | | // list.forEach(e -> { |
| | | // SysCompanyVo vo=new SysCompanyVo(); |
| | | // BeanCopier beanCopier = BeanCopier.create(SysCompany.class, SysCompanyVo.class, false); |
| | | // beanCopier.copy(e,vo,null); |
| | | // if(vo.getCompanyArea()!=null){ |
| | | // SysArea byId = sysAreaService.getById(vo.getCompanyArea()); |
| | | // if(byId.getAreaLeveltype()==XIAN){ |
| | | // vo.setXianId(byId.getId()); |
| | | // vo.setXian(byId.getAreaName()); |
| | | // SysArea shi = sysAreaService.getById(byId.getAreaParentId()); |
| | | // if(shi!=null){ |
| | | // vo.setShi(shi.getAreaName()); |
| | | // vo.setShiId(shi.getId()); |
| | | // SysArea sheng = sysAreaService.getById(shi.getAreaParentId()); |
| | | // if (sheng != null) { |
| | | // vo.setSheng(sheng.getAreaName()); |
| | | // vo.setShengId(sheng.getId()); |
| | | // } |
| | | // } |
| | | // } |
| | | // if(byId.getAreaLeveltype()==SHI){ |
| | | // vo.setShi(byId.getAreaName()); |
| | | // vo.setShiId(byId.getId()); |
| | | // SysArea sheng = sysAreaService.getById(byId.getAreaParentId()); |
| | | // if (sheng != null) { |
| | | // vo.setSheng(sheng.getAreaName()); |
| | | // vo.setShengId(sheng.getId()); |
| | | // } |
| | | // } |
| | | // if(byId.getAreaLeveltype()==SHENG){ |
| | | // vo.setSheng(byId.getAreaName()); |
| | | // vo.setShengId(byId.getId()); |
| | | // } |
| | | // } |
| | | // listVo.add(vo); |
| | | // }); |
| | | return PageResult.<SysCompany>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.redis.util.RedisConstant; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.usercenter.service.ISysUserOrgService; |
| | | import com.kidgrow.usercenter.service.ISysUserService; |
| | | import com.kidgrow.usercenter.vo.SysDoctorDto; |
| | | import com.kidgrow.usercenter.vo.SysDoctorVo; |
| | |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private ISysUserService iSysUserService; |
| | | @Autowired |
| | | private PasswordEncoder passwordEncoder; |
| | | @Autowired |
| | | private ISysUserOrgService sysUserOrgService; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | |
| | | @Override |
| | | public PageResult<SysDoctorVo> findList(Map<String, Object> params) { |
| | |
| | | beanCopier.copy(sysDoctor,sysDoc,null); |
| | | sysDoc.setUserId(sysUser.getId()); |
| | | baseMapper.insert(sysDoc); |
| | | //保存将sys_user_org |
| | | SysUserOrg sysUserOrg=new SysUserOrg(); |
| | | sysUserOrg.setUserId(sysUser.getId()); |
| | | sysUserOrg.setEnabled(false); |
| | | sysUserOrg.setOrgId(sysDoctor.getDepartmentId()); |
| | | sysUserOrg.setCreateTime(new Date()); |
| | | sysUserOrgService.saveOrUpdate(sysUserOrg); |
| | | //保存到Redis |
| | | boolean hset = redisUtils.hset(RedisConstant.USER_ORGANIZATION, sysUserOrg.getUserId().toString(), sysUserOrg); |
| | | }else { |
| | | //更新 |
| | | redisUtils.hdel(RedisConstant.USER_ORGANIZATION, sysDoctor.getUserId().toString()); |
| | | // List<SysUserOrg> sysOrganizations = JSON.parseArray(JSON.toJSONString(redisUtils.hget(RedisConstant.USER_ORGANIZATION, sysDoctor.getUserId().toString())), SysUserOrg.class); |
| | | // sysOrganizations.forEach( e-> { |
| | | // if(e.getId()==sysDoctor.getId()){ |
| | | // sysOrganizations.set(0,sysDoctor); |
| | | // } |
| | | // }); |
| | | Map<String, Object> columnMap=new HashMap<>(); |
| | | columnMap.put("user_id",sysDoctor.getUserId()); |
| | | boolean b = sysUserOrgService.removeByMap(columnMap); |
| | | //保存将sys_user_org |
| | | SysUserOrg sysUserOrg=new SysUserOrg(); |
| | | sysUserOrg.setUserId(sysDoctor.getUserId()); |
| | | sysUserOrg.setEnabled(false); |
| | | sysUserOrg.setOrgId(sysDoctor.getDepartmentId()); |
| | | sysUserOrg.setCreateTime(new Date()); |
| | | sysUserOrgService.saveOrUpdate(sysUserOrg); |
| | | baseMapper.updateById(sysDoctor); |
| | | redisUtils.hset(RedisConstant.USER_ORGANIZATION, sysUserOrg.getUserId().toString(), sysUserOrg); |
| | | } |
| | | } |
| | | return true; |
| | |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.redis.util.RedisConstant; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.usercenter.mapper.SysOrganizationMapper; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import com.kidgrow.usercenter.vo.SysOrganizationVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @version 1.0 |
| | | * @Description: 组织架构表<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-03-31 11:01:35 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SysOrganizationServiceImpl extends SuperServiceImpl<SysOrganizationMapper, SysOrganization> implements ISysOrganizationService { |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<SysOrganization> findList(Map<String, Object> params){ |
| | | public PageResult<SysOrganization> findList(Map<String, Object> params) { |
| | | Page<SysOrganization> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysOrganization> list = baseMapper.findList(page, params); |
| | | List<SysOrganization> list = baseMapper.findList(page, params); |
| | | return PageResult.<SysOrganization>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysOrganization对象当做查询条件进行查询 |
| | | * @param sysOrganization |
| | | * @return SysOrganization |
| | | */ |
| | | * 根据SysOrganization对象当做查询条件进行查询 |
| | | * |
| | | * @param sysOrganization |
| | | * @return SysOrganization |
| | | */ |
| | | @Override |
| | | public SysOrganization findByObject(SysOrganization sysOrganization){ |
| | | public SysOrganization findByObject(SysOrganization sysOrganization) { |
| | | return baseMapper.findByObject(sysOrganization); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户 获取组织 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据map 查询, 将参数中的 access_token 去掉 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | //将access_token 参数去掉 |
| | | params.remove("access_token"); |
| | | List<SysOrganization> sysOrganizations = baseMapper.selectByMap(params); |
| | | List<SysOrganizationVo> sysOrganizationVos=new ArrayList<>(); |
| | | sysOrganizations.forEach(e ->{ |
| | | if(e.getOrgParentId()!=null){ |
| | | SysOrganizationVo sysOrganizationVo=new SysOrganizationVo(); |
| | | List<SysOrganizationVo> sysOrganizationVos = new ArrayList<>(); |
| | | sysOrganizations.forEach(e -> { |
| | | if (e.getOrgParentId() != null) { |
| | | SysOrganizationVo sysOrganizationVo = new SysOrganizationVo(); |
| | | BeanCopier beanCopier = BeanCopier.create(SysOrganization.class, SysOrganizationVo.class, false); |
| | | beanCopier.copy(e,sysOrganizationVo,null); |
| | | beanCopier.copy(e, sysOrganizationVo, null); |
| | | SysOrganization sysOrganization = baseMapper.selectById(e.getOrgParentId()); |
| | | if(sysOrganization!=null){ |
| | | if (sysOrganization != null) { |
| | | sysOrganizationVo.setOrgParentName(sysOrganization.getOrgName()); |
| | | } |
| | | sysOrganizationVos.add(sysOrganizationVo); |
| | |
| | | |
| | | /** |
| | | * 更新状态 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody updateEnabled(Map<String, Object> params) { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | if(id==null){ |
| | | if (id == null) { |
| | | return ResultBody.failed("请选取一条数据"); |
| | | } |
| | | SysOrganization sysOrganization = baseMapper.selectById(id); |
| | | if (sysOrganization != null) { |
| | | sysOrganization.setEnabled(MapUtils.getBoolean(params,"enabled")); |
| | | sysOrganization.setEnabled(MapUtils.getBoolean(params, "enabled")); |
| | | int i = baseMapper.updateById(sysOrganization); |
| | | if(i>0){ |
| | | return ResultBody.ok(); |
| | | }else { |
| | | redisUtils.hdel(RedisConstant.ORGANIZATION, sysOrganization.getId().toString()); |
| | | redisUtils.hset(RedisConstant.ORGANIZATION, sysOrganization.getId().toString(), sysOrganization); |
| | | if (i > 0) { |
| | | return ResultBody.ok(); |
| | | } else { |
| | | return ResultBody.failed("更新失败"); |
| | | } |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("更新失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取树状图 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 将数据 封装成 tree (递归方式) |
| | | * |
| | | * @param MyId |
| | | * @param sysOrganizations |
| | | * @return |
| | | */ |
| | | public List<Map<String,Object>> getTreeData(Long MyId,List<SysOrganization> sysOrganizations){ |
| | | List<Map<String,Object>> listMap=new ArrayList<>(); |
| | | public List<Map<String, Object>> getTreeData(Long MyId, List<SysOrganization> sysOrganizations) { |
| | | List<Map<String, Object>> listMap = new ArrayList<>(); |
| | | Map<Long, SysOrganization> collect = sysOrganizations.stream().collect(Collectors.toMap(SysOrganization::getId, SysOrganization -> SysOrganization)); |
| | | List<Long> idList = sysOrganizations.stream().filter(e -> e.getOrgParentId()==MyId).map(e -> e.getId()).collect(Collectors.toList()); |
| | | for (Long id:idList |
| | | ) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("id",id); |
| | | map.put("name",collect.get(id).getOrgName()); |
| | | map.put("level",collect.get(id).getOrgLevel()); |
| | | List<Long> idList = sysOrganizations.stream().filter(e -> e.getOrgParentId() == MyId).map(e -> e.getId()).collect(Collectors.toList()); |
| | | for (Long id : idList |
| | | ) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", id); |
| | | map.put("name", collect.get(id).getOrgName()); |
| | | map.put("level", collect.get(id).getOrgLevel()); |
| | | List<Long> childs = sysOrganizations.stream().filter(e -> e.getOrgParentId() == id).map(e -> e.getId()).collect(Collectors.toList()); |
| | | if(childs.size()>0){ |
| | | if (childs.size() > 0) { |
| | | List<Map<String, Object>> treeData = getTreeData(id, sysOrganizations); |
| | | map.put("children",treeData); |
| | | map.put("children", treeData); |
| | | } |
| | | listMap.add(map); |
| | | } |
| | | return listMap; |
| | | } |
| | | |
| | | /** |
| | | * 保存或者更新 |
| | | * |
| | | * @param sysOrganization |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public boolean saveOrUpdateSer(SysOrganization sysOrganization) { |
| | | if (sysOrganization.getId() == null) { |
| | | //保存 |
| | | baseMapper.insert(sysOrganization); |
| | | } else { |
| | | //更新 |
| | | int i = baseMapper.updateById(sysOrganization); |
| | | } |
| | | redisUtils.hdel(RedisConstant.ORGANIZATION, sysOrganization.getId().toString()); |
| | | redisUtils.hset(RedisConstant.ORGANIZATION, sysOrganization.getId().toString(), sysOrganization); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | </select> |
| | | |
| | | <!--根据用户ID查询用户所属组织机构列表--> |
| | | <!-- <select id="findListByUserId" resultType="com.kidgrow.common.model.SysOrganization">--> |
| | | <!-- SELECT--> |
| | | <!-- org.id,--> |
| | | <!-- org.org_parent_id,--> |
| | | <!-- org.org_name ,--> |
| | | <!-- org.org_attr,--> |
| | | <!-- org.org_level--> |
| | | <!-- FROM sys_user_org uo--> |
| | | <!-- LEFT JOIN sys_organization org ON uo.org_id = org.id--> |
| | | <!-- AND (uo.enabled = TRUE AND uo.is_del = FALSE) AND (org.is_del = FALSE AND org.enabled = TRUE)--> |
| | | <!-- where uo.user_id=#{userId}--> |
| | | <!-- order by org_level--> |
| | | <!-- </select>--> |
| | | <select id="findListByUserId" resultType="com.kidgrow.common.model.SysOrganization"> |
| | | SELECT |
| | | org.id, |
| | | org.org_parent_id, |
| | | org.org_name , |
| | | org.org_attr, |
| | | org.org_level |
| | | FROM sys_user_org uo |
| | | LEFT JOIN sys_organization org ON uo.org_id = org.id |
| | | AND (uo.enabled = TRUE AND uo.is_del = FALSE) AND (org.is_del = FALSE AND org.enabled = TRUE) |
| | | where uo.user_id=#{userId} |
| | | order by org_level |
| | | SELECT |
| | | * |
| | | FROM |
| | | sys_user_org uo |
| | | LEFT JOIN sys_organization org ON uo.org_id = org.id |
| | | WHERE |
| | | org.is_del = FALSE |
| | | AND org.enabled = TRUE |
| | | AND uo.enabled = TRUE |
| | | AND uo.is_del = FALSE |
| | | and uo.user_id=#{userId} |
| | | ORDER BY |
| | | org_level |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | boolean v= sysOrganizationService.saveOrUpdate(sysOrganization); |
| | | boolean v= sysOrganizationService.saveOrUpdateSer(sysOrganization); |
| | | if(v) { |
| | | return ResultBody.ok().data(sysOrganization).msg("保存成功"); |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import com.kidgrow.usercenter.service.ISysUserOrgService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sysuserorg") |
| | | @Api(tags = "") |
| | | public class SysUserOrgController { |
| | | @Autowired |
| | | private ISysUserOrgService iSysUserOrgService; |
| | | @PostMapping("getListByMap") |
| | | public List<SysUserOrg> getListByMap(@RequestParam Map<String,Object> map){ |
| | | List<SysUserOrg> sysUserOrgs = iSysUserOrgService.listByMap(map); |
| | | return sysUserOrgs; |
| | | } |
| | | } |
| | |
| | | String USER_ID_HEADER = "x-userid-header"; |
| | | |
| | | /** |
| | | * 用户所属组织 为集合 |
| | | */ |
| | | String USER_ORGS_HEADER="x-user-orgs-header"; |
| | | /** |
| | | * 用户所属组织ID |
| | | */ |
| | | String USER_ORG_ID_HEADER="x-user-org-id-header"; |
| | |
| | | import com.kidgrow.common.feign.UserService; |
| | | import com.kidgrow.common.model.SysRole; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.web.bind.support.WebDataBinderFactory; |
| | |
| | | user.setUsername(username); |
| | | } |
| | | List<SysRole> sysRoleList = new ArrayList<>(); |
| | | Arrays.stream(roles.split(",")).forEach(role -> { |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setCode(role); |
| | | sysRoleList.add(sysRole); |
| | | }); |
| | | if(StringUtils.isNotBlank(roles)){ |
| | | Arrays.stream(roles.split(",")).forEach(role -> { |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setCode(role); |
| | | sysRoleList.add(sysRole); |
| | | }); |
| | | } |
| | | user.setRoles(sysRoleList); |
| | | return user; |
| | | } |
New file |
| | |
| | | package com.kidgrow.redis.util; |
| | | |
| | | /** |
| | | * Redis 中的常量 |
| | | */ |
| | | public interface RedisConstant { |
| | | /** |
| | | * 用户与组织的关系 |
| | | */ |
| | | String USER_ORGANIZATION="USER_ORGANIZATION"; |
| | | |
| | | String ORGANIZATION="ORGANIZATION"; |
| | | } |
New file |
| | |
| | | package com.kidgrow.redis.util; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Component |
| | | public class RedisUtils { |
| | | @Autowired |
| | | |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | // =============================common============================ |
| | | |
| | | /** |
| | | * 指定缓存失效时间 |
| | | * |
| | | * @param key 键 |
| | | * @param time 时间(秒) |
| | | * @return |
| | | */ |
| | | |
| | | public boolean expire(String key, long time) { |
| | | |
| | | try { |
| | | if (time > 0) { |
| | | redisTemplate.expire(key, time, TimeUnit.SECONDS); |
| | | } |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据key 获取过期时间 |
| | | * |
| | | * @param key 键 不能为null |
| | | * @return 时间(秒) 返回0代表为永久有效 |
| | | */ |
| | | |
| | | public long getExpire(String key) { |
| | | return redisTemplate.getExpire(key, TimeUnit.SECONDS); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断key是否存在 |
| | | * |
| | | * @param key 键 |
| | | * @return true 存在 false不存在 |
| | | */ |
| | | |
| | | public boolean hasKey(String key) { |
| | | |
| | | try { |
| | | return redisTemplate.hasKey(key); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除缓存 |
| | | * |
| | | * @param key 可以传一个值 或多个 |
| | | */ |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | |
| | | public void del(String... key) { |
| | | |
| | | if (key != null && key.length > 0) { |
| | | |
| | | if (key.length == 0) { |
| | | redisTemplate.delete(key[0]); |
| | | } else { |
| | | redisTemplate.delete(CollectionUtils.arrayToList(key)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | // ============================String============================= |
| | | |
| | | /** |
| | | * 普通缓存获取 |
| | | * |
| | | * @param key 键 |
| | | * @return 值 |
| | | */ |
| | | |
| | | public Object get(String key) { |
| | | return key == null ? null : redisTemplate.opsForValue().get(key); |
| | | } |
| | | |
| | | /** |
| | | * 普通缓存放入 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @return true成功 false失败 |
| | | */ |
| | | |
| | | public boolean set(String key, Object value) { |
| | | |
| | | try { |
| | | redisTemplate.opsForValue().set(key, value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 普通缓存放入并设置时间 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 |
| | | * @return true成功 false 失败 |
| | | */ |
| | | |
| | | public boolean set(String key, Object value, long time) { |
| | | |
| | | try { |
| | | if (time > 0) { |
| | | redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); |
| | | } else { |
| | | set(key, value); |
| | | } |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * 递增 |
| | | * |
| | | * @param key 键 |
| | | * @param delta 要增加几(大于0) |
| | | * @return |
| | | */ |
| | | |
| | | public long incr(String key, long delta) { |
| | | if (delta < 0) { |
| | | throw new RuntimeException("递增因子必须大于0"); |
| | | } |
| | | return redisTemplate.opsForValue().increment(key, delta); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 递减 |
| | | * |
| | | * @param key 键 |
| | | * @param delta 要减少几(小于0) |
| | | * @return |
| | | */ |
| | | |
| | | public long decr(String key, long delta) { |
| | | if (delta < 0) { |
| | | throw new RuntimeException("递减因子必须大于0"); |
| | | } |
| | | return redisTemplate.opsForValue().increment(key, -delta); |
| | | } |
| | | |
| | | |
| | | // ================================Map================================= |
| | | |
| | | /** |
| | | * HashGet |
| | | * |
| | | * @param key 键 不能为null |
| | | * @param item 项 不能为null |
| | | * @return 值 |
| | | */ |
| | | |
| | | public Object hget(String key, String item) { |
| | | return redisTemplate.opsForHash().get(key, item); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取hashKey对应的所有键值 |
| | | * |
| | | * @param key 键 |
| | | * @return 对应的多个键值 |
| | | */ |
| | | |
| | | public Map<Object, Object> hmget(String key) { |
| | | return redisTemplate.opsForHash().entries(key); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * HashSet |
| | | * |
| | | * @param key 键 |
| | | * @param map 对应多个键值 |
| | | * @return true 成功 false 失败 |
| | | */ |
| | | |
| | | public boolean hmset(String key, Map<String, Object> map) { |
| | | |
| | | try { |
| | | redisTemplate.opsForHash().putAll(key, map); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * HashSet 并设置时间 |
| | | * |
| | | * @param key 键 |
| | | * @param map 对应多个键值 |
| | | * @param time 时间(秒) |
| | | * @return true成功 false失败 |
| | | */ |
| | | |
| | | public boolean hmset(String key, Map<String, Object> map, long time) { |
| | | |
| | | try { |
| | | redisTemplate.opsForHash().putAll(key, map); |
| | | if (time > 0) { |
| | | expire(key, time); |
| | | } |
| | | return true; |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 向一张hash表中放入数据,如果不存在将创建 |
| | | * |
| | | * @param key 键 |
| | | * @param item 项 |
| | | * @param value 值 |
| | | * @return true 成功 false失败 |
| | | */ |
| | | |
| | | public boolean hset(String key, String item, Object value) { |
| | | |
| | | try { |
| | | redisTemplate.opsForHash().put(key, item, value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 向一张hash表中放入数据,如果不存在将创建 |
| | | * |
| | | * @param key 键 |
| | | * @param item 项 |
| | | * @param value 值 |
| | | * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 |
| | | * @return true 成功 false失败 |
| | | */ |
| | | |
| | | public boolean hset(String key, String item, Object value, long time) { |
| | | |
| | | try { |
| | | redisTemplate.opsForHash().put(key, item, value); |
| | | if (time > 0) { |
| | | expire(key, time); |
| | | } |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除hash表中的值 |
| | | * |
| | | * @param key 键 不能为null |
| | | * @param item 项 可以使多个 不能为null |
| | | */ |
| | | |
| | | public void hdel(String key, Object... item) { |
| | | redisTemplate.opsForHash().delete(key, item); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断hash表中是否有该项的值 |
| | | * |
| | | * @param key 键 不能为null |
| | | * @param item 项 不能为null |
| | | * @return true 存在 false不存在 |
| | | */ |
| | | |
| | | public boolean hHasKey(String key, String item) { |
| | | return redisTemplate.opsForHash().hasKey(key, item); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * hash递增 如果不存在,就会创建一个 并把新增后的值返回 |
| | | * |
| | | * @param key 键 |
| | | * @param item 项 |
| | | * @param by 要增加几(大于0) |
| | | * @return |
| | | */ |
| | | |
| | | public double hincr(String key, String item, double by) { |
| | | return redisTemplate.opsForHash().increment(key, item, by); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * hash递减 |
| | | * |
| | | * @param key 键 |
| | | * @param item 项 |
| | | * @param by 要减少记(小于0) |
| | | * @return |
| | | */ |
| | | |
| | | public double hdecr(String key, String item, double by) { |
| | | return redisTemplate.opsForHash().increment(key, item, -by); |
| | | |
| | | } |
| | | |
| | | |
| | | // ============================set============================= |
| | | |
| | | /** |
| | | * 根据key获取Set中的所有值 |
| | | * |
| | | * @param key 键 |
| | | * @return |
| | | */ |
| | | |
| | | public Set<Object> sGet(String key) { |
| | | try { |
| | | return redisTemplate.opsForSet().members(key); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据value从一个set中查询,是否存在 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @return true 存在 false不存在 |
| | | */ |
| | | |
| | | public boolean sHasKey(String key, Object value) { |
| | | |
| | | try { |
| | | return redisTemplate.opsForSet().isMember(key, value); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将数据放入set缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param values 值 可以是多个 |
| | | * @return 成功个数 |
| | | */ |
| | | |
| | | public long sSet(String key, Object... values) { |
| | | |
| | | try { |
| | | return redisTemplate.opsForSet().add(key, values); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将set数据放入缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param time 时间(秒) |
| | | * @param values 值 可以是多个 |
| | | * @return 成功个数 |
| | | */ |
| | | |
| | | public long sSetAndTime(String key, long time, Object... values) { |
| | | |
| | | try { |
| | | Long count = redisTemplate.opsForSet().add(key, values); |
| | | if (time > 0) |
| | | expire(key, time); |
| | | return count; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取set缓存的长度 |
| | | * |
| | | * @param key 键 |
| | | * @return |
| | | */ |
| | | |
| | | public long sGetSetSize(String key) { |
| | | try { |
| | | return redisTemplate.opsForSet().size(key); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 移除值为value的 |
| | | * |
| | | * @param key 键 |
| | | * @param values 值 可以是多个 |
| | | * @return 移除的个数 |
| | | */ |
| | | |
| | | public long setRemove(String key, Object... values) { |
| | | |
| | | try { |
| | | Long count = redisTemplate.opsForSet().remove(key, values); |
| | | return count; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | // ===============================list================================= |
| | | |
| | | |
| | | /** |
| | | * 获取list缓存的内容 |
| | | * |
| | | * @param key 键 |
| | | * @param start 开始 |
| | | * @param end 结束 0 到 -代表所有值 |
| | | * @return |
| | | */ |
| | | |
| | | public List<Object> lGet(String key, long start, long end) { |
| | | |
| | | try { |
| | | return redisTemplate.opsForList().range(key, start, end); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取list缓存的长度 |
| | | * |
| | | * @param key 键 |
| | | * @return |
| | | */ |
| | | |
| | | public long lGetListSize(String key) { |
| | | |
| | | try { |
| | | return redisTemplate.opsForList().size(key); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过索引 获取list中的值 |
| | | * |
| | | * @param key 键 |
| | | * @param index 索引 index>=0时, 0 表头, 第二个元素,依次类推;index<0时,-,表尾,-倒数第二个元素,依次类推 |
| | | * @return |
| | | */ |
| | | |
| | | public Object lGetIndex(String key, long index) { |
| | | |
| | | try { |
| | | return redisTemplate.opsForList().index(key, index); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将list放入缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @return |
| | | */ |
| | | |
| | | public boolean lSet(String key, Object value) { |
| | | try { |
| | | redisTemplate.opsForList().rightPush(key, value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将list放入缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @param time 时间(秒) |
| | | * @return |
| | | */ |
| | | |
| | | public boolean lSet(String key, Object value, long time) { |
| | | |
| | | try { |
| | | |
| | | redisTemplate.opsForList().rightPush(key, value); |
| | | |
| | | if (time > 0) |
| | | |
| | | expire(key, time); |
| | | |
| | | return true; |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | e.printStackTrace(); |
| | | |
| | | return false; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将list放入缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @return |
| | | */ |
| | | |
| | | public boolean lSet(String key, List<Object> value) { |
| | | try { |
| | | redisTemplate.opsForList().rightPushAll(key, value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将list放入缓存 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @param time 时间(秒) |
| | | * @return |
| | | */ |
| | | public boolean lSet(String key, List<Object> value, long time) { |
| | | try { |
| | | redisTemplate.opsForList().rightPushAll(key, value); |
| | | if (time > 0) |
| | | expire(key, time); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据索引修改list中的某条数据 |
| | | * |
| | | * @param key 键 |
| | | * @param index 索引 |
| | | * @param value 值 |
| | | * @return |
| | | */ |
| | | public boolean lUpdateIndex(String key, long index, Object value) { |
| | | try { |
| | | redisTemplate.opsForList().set(key, index, value); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 移除N个值为value |
| | | * |
| | | * @param key 键 |
| | | * @param count 移除多少个 |
| | | * @param value 值 |
| | | * @return 移除的个数 |
| | | */ |
| | | public long lRemove(String key, long count, Object value) { |
| | | try { |
| | | Long remove = redisTemplate.opsForList().remove(key, count, value); |
| | | return remove; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | } |
| | |
| | | <groupId>com.github.zlt2000</groupId> |
| | | <artifactId>swagger-butler-core</artifactId> |
| | | </dependency> |
| | | <!-- redis--> |
| | | <dependency> |
| | | <groupId>com.kidgrow</groupId> |
| | | <artifactId>kidgrow-redis-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
New file |
| | |
| | | package com.kidgrow.zuul.feign; |
| | | |
| | | import com.kidgrow.common.constant.ServiceNameConstants; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysMenu; |
| | | import com.kidgrow.zuul.feign.fallback.SysOrganizationServiceFallbackFactory; |
| | | import com.kidgrow.zuul.feign.fallback.SysUserOrgServiceFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/22 14:33 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = SysOrganizationServiceFallbackFactory.class, decode404 = true) |
| | | public interface SysOrganizationService { |
| | | |
| | | @GetMapping("sysorganization/getListByMap") |
| | | public ResultBody getListByMap(@RequestParam Map<String, Object> params); |
| | | } |
New file |
| | |
| | | package com.kidgrow.zuul.feign; |
| | | |
| | | import com.kidgrow.common.constant.ServiceNameConstants; |
| | | import com.kidgrow.common.model.SysMenu; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.zuul.feign.fallback.MenuServiceFallbackFactory; |
| | | import com.kidgrow.zuul.feign.fallback.SysUserOrgServiceFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/22 14:33 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = SysUserOrgServiceFallbackFactory.class, decode404 = true) |
| | | public interface SysUserOrgService { |
| | | /** |
| | | * 根据条件查询 |
| | | * @param map |
| | | */ |
| | | @PostMapping(value = "/sysuserorg/getListByMap") |
| | | List<SysUserOrg> getListByMap(@RequestParam Map<String,Object> map); |
| | | } |
New file |
| | |
| | | package com.kidgrow.zuul.feign.fallback; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.zuul.feign.MenuService; |
| | | import com.kidgrow.zuul.feign.SysOrganizationService; |
| | | import feign.hystrix.FallbackFactory; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/22 14:33 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class SysOrganizationServiceFallbackFactory implements FallbackFactory<SysOrganizationService> { |
| | | |
| | | @Override |
| | | public SysOrganizationService create(Throwable throwable) { |
| | | return new SysOrganizationService() { |
| | | @Override |
| | | public ResultBody getListByMap(Map<String, Object> params) { |
| | | return ResultBody.failed().msg("FeignClient调用参数传递测试失败"); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.kidgrow.zuul.feign.fallback; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysMenu; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.zuul.feign.MenuService; |
| | | import com.kidgrow.zuul.feign.SysUserOrgService; |
| | | import feign.hystrix.FallbackFactory; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/22 14:33 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class SysUserOrgServiceFallbackFactory implements FallbackFactory<SysUserOrgService> { |
| | | @Override |
| | | public SysUserOrgService create(Throwable throwable) { |
| | | return new SysUserOrgService() { |
| | | @Override |
| | | public List<SysUserOrg> getListByMap(Map<String, Object> map) { |
| | | return null; |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.kidgrow.zuul.filter; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.common.utils.AddrUtil; |
| | | import com.kidgrow.redis.util.RedisConstant; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.zuul.feign.SysOrganizationService; |
| | | import com.kidgrow.zuul.feign.SysUserOrgService; |
| | | import com.netflix.zuul.ZuulFilter; |
| | | import com.netflix.zuul.context.RequestContext; |
| | | import eu.bitwalker.useragentutils.UserAgent; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.hibernate.validator.constraints.NotBlank; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.security.authentication.AnonymousAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.oauth2.provider.OAuth2Authentication; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 将认证用户的相关信息放入header中, 后端服务可以直接读取使用 包含了----组织的拦截---<br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 10:12 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class OrganizationFilter extends ZuulFilter { |
| | | @Override |
| | | public String filterType() { |
| | | return FilterConstants.PRE_TYPE; |
| | | } |
| | | |
| | | @Override |
| | | public int filterOrder() { |
| | | return PRE_DECORATION_FILTER_ORDER; |
| | | } |
| | | |
| | | @Override |
| | | public boolean shouldFilter() { |
| | | return true; |
| | | } |
| | | |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | @Autowired |
| | | private SysUserOrgService sysUserOrgService; |
| | | @Autowired |
| | | private SysOrganizationService sysOrganizationService; |
| | | |
| | | private final String CLIENTID = "webApp";//运营端 |
| | | |
| | | @SneakyThrows |
| | | @Override |
| | | public Object run() { |
| | | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
| | | if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) { |
| | | Object principal = authentication.getPrincipal(); |
| | | RequestContext ctx = RequestContext.getCurrentContext(); |
| | | if (principal instanceof SysUser) { |
| | | //运营端进行 |
| | | OAuth2Authentication oauth2Authentication = (OAuth2Authentication) authentication; |
| | | String clientId = oauth2Authentication.getOAuth2Request().getClientId(); |
| | | if (CLIENTID.equals(clientId)) { |
| | | SysUser user = (SysUser) authentication.getPrincipal(); |
| | | /** |
| | | * 将组织中为空的拦截 |
| | | */ |
| | | List<SysUserOrg> sysUserOrgs = getSysUserOrg(user.getId()); |
| | | if (sysUserOrgs == null || sysUserOrgs.isEmpty()) { |
| | | ctx.setSendZuulResponse(false); |
| | | ctx.setResponseBody(JSON.toJSONString(ResultBody.fail(1000, "您的组织已经被禁用,请联系管理员"))); |
| | | } else { |
| | | List<Long> collect = sysUserOrgs.stream().map(e -> e.getOrgId()).collect(Collectors.toList()); |
| | | List<SysOrganization> sysOrganizations = getSysOrganization(); |
| | | List<Long> orgIds = sysOrganizations.stream().filter(e -> e.getEnabled() == true && collect.contains(e.getId())).map(e -> e.getId()).collect(Collectors.toList()); |
| | | if (orgIds == null || orgIds.size() <= 0) { |
| | | ctx.setSendZuulResponse(false); |
| | | ctx.setResponseBody(JSON.toJSONString(ResultBody.fail(1000, "您的组织已经被禁用,请联系管理员"))); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 通过userID 获取组织的关系 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public List<SysUserOrg> getSysUserOrg(Long str) { |
| | | //获取组织 Redis中获取 |
| | | List<SysUserOrg> sysUserOrgs = JSON.parseArray(JSON.toJSONString(redisUtils.hget(RedisConstant.USER_ORGANIZATION, str.toString())), SysUserOrg.class); |
| | | if (sysUserOrgs == null || sysUserOrgs.size() <= 0) { |
| | | //在数据库查询 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("user_id", str); |
| | | sysUserOrgs = sysUserOrgService.getListByMap(map); |
| | | redisUtils.hset(RedisConstant.USER_ORGANIZATION, str.toString(), sysUserOrgs); |
| | | } |
| | | return sysUserOrgs; |
| | | } |
| | | |
| | | public List<SysOrganization> getSysOrganization() { |
| | | Map<Object, Object> hmget = redisUtils.hmget(RedisConstant.ORGANIZATION); |
| | | List<SysOrganization> sysOrganizations = new ArrayList<>(); |
| | | if (hmget == null || hmget.size() <= 0) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("is_del", 0); |
| | | sysOrganizations = JSON.parseArray(JSON.toJSONString(sysOrganizationService.getListByMap(map).getData()), SysOrganization.class); |
| | | sysOrganizations.forEach(e -> { |
| | | redisUtils.hset(RedisConstant.ORGANIZATION, e.getId().toString(), e); |
| | | }); |
| | | |
| | | } else { |
| | | Set<Object> objects = hmget.keySet(); |
| | | Iterator<Object> iterator = objects.iterator(); |
| | | while (iterator.hasNext()) { |
| | | sysOrganizations.add((SysOrganization) hmget.get(iterator.next())); |
| | | } |
| | | } |
| | | return sysOrganizations; |
| | | } |
| | | } |
| | | |
| | |
| | | package com.kidgrow.zuul.filter; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.ResultBody; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | |
| | | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER; |
| | | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 将认证用户的相关信息放入header中, 后端服务可以直接读取使用<br> |
| | | * @Description: 将认证用户的相关信息放入header中, 后端服务可以直接读取使用 包含了----组织的拦截---<br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 10:12 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | |
| | | RequestContext ctx = RequestContext.getCurrentContext(); |
| | | HttpServletRequest req = ctx.getRequest(); |
| | | UserAgent userAgent = UserAgent.parseUserAgentString(req.getHeader("User-Agent")); |
| | | String tenantId=""; |
| | | String tenantId = ""; |
| | | //客户端模式只返回一个clientId |
| | | if (principal instanceof SysUser) { |
| | | SysUser user = (SysUser)authentication.getPrincipal(); |
| | | SysUser user = (SysUser) authentication.getPrincipal(); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername()); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_REAL_NAME, "");//待完善 |
| | | List<SysOrganization> organizations = (List<SysOrganization>)user.getOrganizations(); |
| | | //如果有组织架构 |
| | | if(organizations!=null && organizations.size()==2){ |
| | | if(organizations.get(0)!=null){ |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(organizations.get(0).getOrgName(),"UTF-8")); |
| | | tenantId=String.valueOf(organizations.get(0).getId()); |
| | | }else{ |
| | | return ResultBody.failed("您的组织,已经被禁用,请联系管理员"); |
| | | } |
| | | if(organizations.get(1)!=null){ |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(1).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,URLEncoder.encode(organizations.get(1).getOrgName(),"UTF-8")); |
| | | }else { |
| | | return ResultBody.failed("您组织部门或者科室,已经被禁用,请联系管理员"); |
| | | } |
| | | } |
| | | List<SysOrganization> organizations = (List<SysOrganization>) user.getOrganizations(); |
| | | //如果没有有组织架构 |
| | | //将组织数据 存到header 里面 |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER, JSON.toJSONString(organizations)); |
| | | // log.error("用户ID写入Header成功,用户ID为:"+String.valueOf(user.getId())); |
| | | } |
| | | |
| | | |
| | | OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication; |
| | | OAuth2Authentication oauth2Authentication = (OAuth2Authentication) authentication; |
| | | String clientId = oauth2Authentication.getOAuth2Request().getClientId(); |
| | | |
| | | //保存租户id,租户id根据业务尽进行替换 |
| | | switch (clientId){ |
| | | switch (clientId) { |
| | | case "hospital": |
| | | tenantId=tenantId; |
| | | tenantId = tenantId; |
| | | break; |
| | | case "webApp": |
| | | tenantId="webApp"; |
| | | tenantId = "webApp"; |
| | | break; |
| | | default: |
| | | tenantId=clientId; |
| | | tenantId = clientId; |
| | | break; |
| | | } |
| | | ctx.addZuulRequestHeader(CommonConstant.USER_AGENT_BROWSER, userAgent.getBrowser().toString()); |
| | |
| | | spring: |
| | | application: |
| | | name: zuul-server |
| | | #配置Redis |
| | | redis: |
| | | host: ${spring.redis.host} |
| | | port: ${spring.redis.port} |
| | | password: ${spring.redis.password} |
| | | timeout: ${spring.redis.timeout} |
| | | server: |
| | | tomcat: |
| | | uri-encoding: UTF-8 |
| | |
| | | butler: |
| | | auto-generate-from-zuul-routes: true |
| | | generate-routes: user,file,log,codegenerator,auth |
| | | apiDocsPath: v2/api-docs |
| | | |
| | | |
| | | apiDocsPath: v2/api-docs |
| | |
| | | //add by owen 修复 path 无法引用http://页面的问题 begin |
| | | String.prototype.startWith = function(str) { |
| | | if (str == null || str == "" || this.length == 0 |
| | | || str.length > this.length) |
| | | return false; |
| | | if (this.substr(0, str.length) == str) |
| | | return true; |
| | | else |
| | | return false; |
| | | return true; |
| | | String.prototype.startWith = function (str) { |
| | | if (str == null || str == "" || this.length == 0 |
| | | || str.length > this.length) |
| | | return false; |
| | | if (this.substr(0, str.length) == str) |
| | | return true; |
| | | else |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | return; |
| | | } |
| | | if ($parent.hasClass('layui-tab-item')) { |
| | | $parent.css({'padding': '0', 'overflow-y': 'hidden'}); |
| | | $parent.css({ 'padding': '0', 'overflow-y': 'hidden' }); |
| | | } else { |
| | | $parent.css({'width': '100%', 'height': '100%'}); |
| | | $parent.css({ 'width': '100%', 'height': '100%' }); |
| | | } |
| | | } |
| | | //add by owen 修复 path 无法引用http://页面的问题 end |
| | |
| | | var laytpl = layui.laytpl; |
| | | var element = layui.element; |
| | | var form = layui.form; |
| | | |
| | | |
| | | var index = { |
| | | // 渲染左侧菜单栏 |
| | | initLeftNav: function () { |
| | |
| | | //data = data[1]; |
| | | // console.log(data); |
| | | // debugger; |
| | | admin.putTempData("menus",data.data); |
| | | admin.putTempData("menus", data.data); |
| | | var menus = data.data; |
| | | // 判断权限 |
| | | for (var i = menus.length - 1; i >= 0; i--) { |
| | |
| | | window.open(data.path); |
| | | } else { |
| | | //临时保存url |
| | | data.path.startWith("http://") ? admin.putTempData("params",data.path) : null ; |
| | | data.path.startWith("http://") ? admin.putTempData("params", data.path) : null; |
| | | |
| | | var menuId = data.url.substring(2); |
| | | //add by owen 修复 path 无法引用http://页面的问题 |
| | |
| | | var contentDom = '.layui-layout-admin .layui-body'; |
| | | admin.showLoading('.layui-layout-admin .layui-body'); |
| | | var flag; // 选项卡是否添加 |
| | | flag = menuPath.startWith("http://") ? false : flag ; |
| | | flag = menuPath.startWith("http://") ? false : flag; |
| | | // 判断是否开启了选项卡功能 |
| | | if (config.pageTabs) { |
| | | $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) { |
| | |
| | | if (!flag) { |
| | | element.tabAdd('admin-pagetabs', { |
| | | title: menuName, |
| | | //add by owen 修复 path 无法引用http://页面的问题 |
| | | content: menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0" marginheight="0" width="100%" height="100%" frameborder="0" onload="initIFrame()"></iframe> </div>' : '<div id="' + menuId + '"></div>' , |
| | | //add by owen 修复 path 无法引用http://页面的问题 |
| | | content: menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0" marginheight="0" width="100%" height="100%" frameborder="0" onload="initIFrame()"></iframe> </div>' : '<div id="' + menuId + '"></div>', |
| | | id: menuId |
| | | }); |
| | | } |
| | |
| | | layer.load(2); |
| | | admin.req('api-user/users/current', {}, function (data) { |
| | | layer.closeAll('loading'); |
| | | // console.log(data.code); |
| | | // debugger; |
| | | // console.log(data); |
| | | if (data && data.code === 0) { |
| | | let user = data.data; |
| | | // console.log(user); |
| | | // debugger; |
| | | config.putUser(user); |
| | | admin.putTempData("permissions",user.permissions); |
| | | admin.putTempData("permissions", user.permissions); |
| | | success(user); |
| | | } else { |
| | | layer.msg('获取用户失败', {icon: 2}); |
| | | config.removeToken(); |
| | | location.replace('login.html'); |
| | | if (data.code === 1000) { |
| | | layer.msg(data.msg, { icon: 2, time: 4 * 1000 }, function () { |
| | | //回调 |
| | | config.removeToken(); |
| | | location.replace('login.html'); |
| | | }) |
| | | |
| | | } else { |
| | | layer.msg('获取用户失败,请联系管理员', { icon: 2, time: 4 * 1000 }, function () { |
| | | //回调 |
| | | config.removeToken(); |
| | | location.replace('login.html'); |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | }, 'GET'); |
| | | }, |
| | | //获取菜单 |
| | | getMenus: function () { |
| | | admin.req('api-user/menus/current', {}, function (data) { |
| | | admin.putTempData("menus",data); |
| | | admin.putTempData("menus", data); |
| | | }, 'GET'); |
| | | }, |
| | | // 页面元素绑定事件监听 |
| | |
| | | layer.confirm('确定退出登录?', function () { |
| | | //通过认证中心 tuic |
| | | admin.req('api-uaa/oauth/remove/token', {}, function (data) { |
| | | config.removeToken(); |
| | | location.replace('login.html'); |
| | | config.removeToken(); |
| | | location.replace('login.html'); |
| | | }, 'POST'); |
| | | }); |
| | | }); |
| | |
| | | <option value="false">试用</option> |
| | | </select> |
| | | <select id="hospitalName-seach" placeholder="选择一个应用" lay-filter="role_clients"> |
| | | <option value="">-请选择-</option> |
| | | <option value="">-请选择医院-</option> |
| | | </select> |
| | | <input id="doctorTel" class="layui-input search-input" type="text" placeholder="按手机号..." />  |
| | | <input id="doctorName" class="layui-input search-input" type="text" placeholder="按医生..." />  |
| | |
| | | |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="app-model"> |
| | | <form id="app-form" lay-filter="app-form" class="layui-form model-form"> |
| | | <form id="app-form" lay-filter="app-form" class="layui-form model-form" > |
| | | <input name="id" type="hidden"/> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医院名称</label> |
| | | <div class="layui-input-block"> |
| | |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生姓名</label> |
| | | <div class="layui-input-block"> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生的头像</label> |
| | | <div class="layui-input-block" id="demo"> |
| | | <button type="button" class="layui-btn" id="phonto"> |
| | | <i class="layui-icon"></i>上传图片 |
| | | </button> |
| | | <input name="doctorLogo" id="doctorLogo-add" type="hidden" class="layui-input" maxlength="20"/> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | 预览图: |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | <label class="layui-form-label" >销售代表名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="serverUserName" type="text" class="layui-input" maxlength="15"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">联系方式</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorRank" type="text" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">其它联系方式</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorEmail" type="text" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生简介</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="isAnswer" id="isAnswer-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">是否签约医生</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="isTop" id="isTop-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> 医生状态</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorState" id="doctorState-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label" >销售代表名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="serverUserName" type="text" class="layui-input" maxlength="15"/> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生的头像</label> |
| | | <div class="layui-input-block" id="demo" > |
| | | <button type="button" class="layui-btn" id="phonto"> |
| | | <i class="layui-icon"></i>上传图片 |
| | | </button> |
| | | <input name="doctorLogo" id="doctorLogo-add" type="hidden" class="layui-input" maxlength="20"/> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px; width:150px"> |
| | | 预览图: |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item model-form-footer"> |
| | | <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button> |
| | | <button class="layui-btn" id="sure" lay-filter="user-form-submit" lay-submit>保存</button> |
| | |
| | | |
| | | <!-- 表单弹窗 添加--> |
| | | <script type="text/html" id="app-model-add"> |
| | | |
| | | |
| | | <form id="app-form-add" lay-filter="app-form-add" class="layui-form model-form"> |
| | | <input name="id" type="hidden"/> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医院名称</label> |
| | | <div class="layui-input-block"> |
| | |
| | | lay-verify="required" required /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">科室</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorRank" id='doctorRank' type="hidden" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">联系电话</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorOtherLink" type="text" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生的email</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="doctorAbout" type="text" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">医生的头像</label> |
| | | <div class="layui-input-block" id="demo"> |
| | | <button type="button" class="layui-btn" id="phonto"> |
| | | <i class="layui-icon"></i>上传图片 |
| | | </button> |
| | | <input name="doctorLogo" id="doctorLogo-add" type="hidden" class="layui-input" maxlength="20"/> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | 预览图: |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | <label class="layui-form-label" >销售代表名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="serverUserName" id="serverUserName-add" type="hidden" class="layui-input" maxlength="15"/> |
| | | <select id="serverUserId-add" name="serverUserId" lay-filter="serverUserId-add" placeholder="选择一个应用" lay-filter="role_clients"> |
| | | <option value="">-请选择-</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> 是否置顶</label> |
| | | <div class="layui-input-block"> |
| | | <input name="isTop" id="isTop-shi" type="radio" checked value="true" title="是" class="layui-input" maxlength="20"/> |
| | | <input name="isTop" id="isTop-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> 是否置顶</label> |
| | | <div class="layui-input-block"> |
| | | <input name="isTop" id="isTop-shi" type="radio" checked value="true" title="是" class="layui-input" maxlength="20"/> |
| | | <input name="isTop" id="isTop-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">是否医答</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="isSigning" id="isSigning-fou" type="radio" value="false" title="否" class="layui-input" maxlength="20"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label"> 医生状态</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="username" type="text" class="layui-input" maxlength="15"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label" >登录密码</label> |
| | | <div class="layui-input-block"> |
| | |
| | | <input name="passwordSure" type="text" class="layui-input" maxlength="15"/> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="display:flex"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label" >销售代表名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="serverUserName" id="serverUserName-add" type="hidden" class="layui-input" maxlength="15"/> |
| | | <select id="serverUserId-add" name="serverUserId" lay-filter="serverUserId-add" placeholder="选择一个应用" lay-filter="role_clients"> |
| | | <option value="">-请选择-</option> |
| | | </select> |
| | | <label class="layui-form-label">医生的头像</label> |
| | | <div class="layui-input-block" id="demo"> |
| | | <button type="button" class="layui-btn" id="phonto"> |
| | | <i class="layui-icon"></i>上传图片 |
| | | </button> |
| | | <input name="doctorLogo" id="doctorLogo-add" type="hidden" class="layui-input" maxlength="20"/> |
| | | <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> |
| | | 预览图: |
| | | <div class="layui-upload-list" id="demo2"></div> |
| | | </blockquote> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item model-form-footer"> |
| | | <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button> |
| | | <button class="layui-btn" id="sure" lay-filter="user-form-submit" lay-submit>保存</button> |
| | |
| | | //销售代表 |
| | | var user = ""; |
| | | //职称 |
| | | var doctorRank=""; |
| | | var doctorRank = ""; |
| | | // 获取应用列表 |
| | | // layer.load(2); |
| | | admin.req('api-user/syshospital/findAll', JSON.stringify({ is_del: 0 }), function (data) { |
| | |
| | | layer.open({ |
| | | type: 1, |
| | | title: '新增', |
| | | area: '450px', |
| | | area: '600px', |
| | | offset: '120px', |
| | | content: $('#app-model-add').html(), |
| | | success: function () { |
| | | $('#app-form-add')[0].reset(); |
| | | $('#app-form-add').attr('method', 'POST'); |
| | | $('.layui-layer-content').css('overflow','auto'); |
| | | $('.layui-layer-content').css('overflow', 'auto'); |
| | | //将医院的数据保存到下拉表 |
| | | let selected = false; |
| | | //获取职称的 |
| | |
| | | layer.open({ |
| | | type: 1, |
| | | title: title, |
| | | area: '450px', |
| | | area: '650px', |
| | | offset: '120px', |
| | | content: $('#app-model').html(), |
| | | success: function () { |
| | |
| | | //新增 点击职称的触发事件 |
| | | form.on('select(doctorRankId)', function (data) { |
| | | //将部门名称赋值 |
| | | |
| | | |
| | | $.each(doctorRank, function (index, item) { |
| | | if (item.id == data.value) { |
| | | console.log(12312312312) |
| | |
| | | if (0 === data.code) { |
| | | department = data.data; |
| | | $('#departmentId').empty(); |
| | | if(data.data.length>0){ |
| | | if (data.data.length > 0) { |
| | | $('#departmentName').val(data.data[0].departmentName); |
| | | } |
| | | $.each(data.data, function (index, item) { |
| | |
| | | page: false, |
| | | cols: [[ |
| | | { type: 'numbers' }, |
| | | { field: 'orgName', align: 'right', title: '组织名称' }, |
| | | { field: 'orgName', minWidth: 200, title: '组织名称' }, |
| | | { |
| | | field: 'orgAttr', align: 'right', title: '所属类型', templet: function (d) { |
| | | //节点属性(集团/公司/部门等,取值0,1,2,3,4) |