7 files added
23 files modified
New file |
| | |
| | | package com.kidgrow.usercenter.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class SysRoleOrganizationDto { |
| | | /** |
| | | * 1代表全部数据权限,2自定义数据权限,3本部门数据权限,4本部门及以下数据权限,5仅本人数据权限 |
| | | */ |
| | | // @NotEmpty(message = "1代表全部数据权限,2自定义数据权限,3本部门数据权限,4本部门及以下数据权限,5仅本人数据权限不能为空") |
| | | @NotNull(message = "权限范围不能为空") |
| | | private Integer type; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @NotNull(message = "角色不能为空") |
| | | private Long roleId; |
| | | /** |
| | | * 部门id organization_id |
| | | */ |
| | | private List<Long> orgIds; |
| | | } |
| | |
| | | */ |
| | | @NotEmpty(message = "状态,1启用,0停用不能为空") |
| | | private Integer enabled; |
| | | |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.model; |
| | | |
| | | import com.kidgrow.common.model.SuperModel; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.hibernate.validator.constraints.*; |
| | | |
| | | import javax.validation.constraints.*; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @version 1.0 |
| | | * @Description: 角色对应的 部门<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @TableName("sys_role_organization") |
| | | public class SysRoleOrganization extends SuperModel { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 1代表全部数据权限,2自定义数据权限,3本部门数据权限,4本部门及以下数据权限,5仅本人数据权限 |
| | | */ |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private Long roleId; |
| | | /** |
| | | * 部门id organization_id |
| | | */ |
| | | private Long orgId; |
| | | /** |
| | | * 部门code organization_code |
| | | */ |
| | | private String orgCode; |
| | | /** |
| | | * 是否删除,1删除,0未删除 |
| | | */ |
| | | private Boolean isDel; |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.mapper; |
| | | |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.db.mapper.SuperMapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 角色对应的 部门<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | public interface SysRoleOrganizationMapper extends SuperMapper<SysRoleOrganization> { |
| | | /** |
| | | * 分页查询角色对应的 部门列表 |
| | | * @param page |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<SysRoleOrganization> findList(Page<SysRoleOrganization> page, @Param("p") Map<String, Object> params); |
| | | |
| | | /** |
| | | * 根据SysRoleOrganization对象当做查询条件进行查询 |
| | | * @param |
| | | * @return SysRoleOrganization对象 |
| | | */ |
| | | SysRoleOrganization findByObject(@Param("p") SysRoleOrganization sysRoleOrganization); |
| | | } |
| | |
| | | package com.kidgrow.usercenter.service; |
| | | |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.usercenter.model.SysDoctor; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.service.ISuperService; |
| | |
| | | * @param params |
| | | * @return |
| | | */ |
| | | PageResult<SysDoctorVo> findList(Map<String, Object> params); |
| | | PageResult<SysDoctorVo> findList(Map<String, Object> params, SysUser user); |
| | | |
| | | |
| | | /** |
New file |
| | |
| | | package com.kidgrow.usercenter.service; |
| | | |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.usercenter.dto.SysRoleOrganizationDto; |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.service.ISuperService; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 角色对应的 部门<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | public interface ISysRoleOrganizationService extends ISuperService<SysRoleOrganization> { |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | PageResult<SysRoleOrganization> findList(Map<String, Object> params); |
| | | |
| | | |
| | | /** |
| | | * 根据SysRoleOrganization对象当做查询条件进行查询 |
| | | * @param sysRoleOrganization |
| | | * @return SysRoleOrganization对象 |
| | | */ |
| | | SysRoleOrganization findByObject(SysRoleOrganization sysRoleOrganization); |
| | | |
| | | boolean saveOrUpdateSer(SysRoleOrganizationDto sysRoleOrganizationDto, SysUser user); |
| | | |
| | | ResultBody getTree(Map<String, Object> params,SysUser user); |
| | | } |
| | | |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.redis.util.RedisConstant; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.usercenter.mapper.SysRoleMapper; |
| | | import com.kidgrow.usercenter.mapper.SysRoleOrganizationMapper; |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.usercenter.service.ISysRoleOrganizationService; |
| | | import com.kidgrow.usercenter.service.ISysUserOrgService; |
| | | import com.kidgrow.usercenter.service.ISysUserService; |
| | | import com.kidgrow.usercenter.vo.SysDoctorDto; |
| | |
| | | @Autowired |
| | | private ISysUserOrgService sysUserOrgService; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | private RedisUtils redisUtils; |
| | | @Autowired |
| | | private SysRoleOrganizationMapper sysRoleOrganizationMapper; |
| | | @Autowired |
| | | private SysRoleMapper sysRoleMapper; |
| | | |
| | | @Override |
| | | public PageResult<SysDoctorVo> findList(Map<String, Object> params) { |
| | | public PageResult<SysDoctorVo> findList(Map<String, Object> params, SysUser user) { |
| | | Page<SysDoctor> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysRole> roles = user.getRoles(); |
| | | List<Map<SysRole,List<SysRoleOrganization>>> listroleOrg=new ArrayList<>(); |
| | | if (!roles.isEmpty()) { |
| | | roles.forEach(e->{ |
| | | Map<SysRole,List<SysRoleOrganization>> rolemap=new HashMap<>(); |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("role_id",e.getId()); |
| | | List<SysRoleOrganization> sysRoleOrganizations = sysRoleOrganizationMapper.selectByMap(map); |
| | | if(sysRoleOrganizations.size()>0){ |
| | | SysRole sysRole = sysRoleMapper.selectById(e.getId()); |
| | | rolemap.put(sysRole,sysRoleOrganizations); |
| | | listroleOrg.add(rolemap); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | params.put("likes",listroleOrg); |
| | | List<SysDoctor> list = baseMapper.findList(page, params); |
| | | List<SysDoctorVo> listvo = new ArrayList<>(); |
| | | list.forEach(e -> { |
| | |
| | | for (Long id : idList |
| | | ) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", id); |
| | | 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()); |
| | |
| | | @Override |
| | | @Transactional |
| | | public boolean saveOrUpdateSer(SysOrganization sysOrganization) { |
| | | //获取code |
| | | |
| | | if (sysOrganization.getId() == null) { |
| | | //保存 |
| | | String code = this.getCode(sysOrganization); |
| | | sysOrganization.setOrgCode(code); |
| | | baseMapper.insert(sysOrganization); |
| | | } else { |
| | | //更新 |
| | | SysOrganization sysOrg = baseMapper.selectById(sysOrganization.getId()); |
| | | if(sysOrg.getOrgParentId()!=sysOrganization.getOrgParentId()){ |
| | | String code = this.getCode(sysOrganization); |
| | | sysOrganization.setOrgCode(code); |
| | | } |
| | | int i = baseMapper.updateById(sysOrganization); |
| | | } |
| | | redisUtils.hdel(RedisConstant.ORGANIZATION, sysOrganization.getId().toString()); |
| | | redisUtils.hset(RedisConstant.ORGANIZATION, sysOrganization.getId().toString(), sysOrganization); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取自己组织的code |
| | | * @param sysOrganization |
| | | * @return |
| | | */ |
| | | public String getCode(SysOrganization sysOrganization){ |
| | | //获取父级 |
| | | Long orgParentId = sysOrganization.getOrgParentId(); |
| | | if (orgParentId == null) { |
| | | return null; |
| | | } |
| | | SysOrganization sysOrg = baseMapper.selectById(orgParentId); |
| | | if(sysOrg!=null){ |
| | | String orgCode = sysOrg.getOrgCode(); |
| | | //查询 |
| | | QueryWrapper queryWrapper=new QueryWrapper(); |
| | | queryWrapper.eq("org_parent_id",sysOrg.getId()); |
| | | queryWrapper.orderByAsc("id"); |
| | | List<SysOrganization> list = baseMapper.selectList(queryWrapper); |
| | | if (list.size()>0) { |
| | | SysOrganization sysOrganizationLast = list.get(list.size() - 1); |
| | | String orgCodeLast = sysOrganizationLast.getOrgCode(); |
| | | String orgCodeLastQianZhui=orgCodeLast.substring(0,orgCodeLast.length() - 4); |
| | | Integer codenum = Integer.valueOf(orgCodeLast.substring(orgCodeLast.length() - 4)); |
| | | String str="0000"; |
| | | str+=(codenum+1); |
| | | String substring = str.substring(str.length() - 4); |
| | | return orgCodeLastQianZhui+substring; |
| | | }else { |
| | | String fucode = sysOrg.getOrgCode(); |
| | | String str="0001"; |
| | | return fucode+str; |
| | | } |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.usercenter.dto.SysRoleOrganizationDto; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import com.kidgrow.usercenter.service.ISysRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.usercenter.mapper.SysRoleOrganizationMapper; |
| | | import com.kidgrow.usercenter.service.ISysRoleOrganizationService; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @version 1.0 |
| | | * @Description: 角色对应的 部门<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SysRoleOrganizationServiceImpl extends SuperServiceImpl<SysRoleOrganizationMapper, SysRoleOrganization> implements ISysRoleOrganizationService { |
| | | |
| | | |
| | | private final Integer TYPE_QUAN_BU = 1;//全部数据权限 |
| | | private final Integer TYPE_ZI_DING_YI = 2;//自定义数据权限 |
| | | private final Integer TYPE_BEN_BU_MEN = 3;//本部门数据权限 |
| | | private final Integer TYPE_BEN_BU_MEN_YI_XIA = 4;//本部门及以下数据权限 |
| | | private final Integer TYPE_BEN_REN = 5;//仅本人数据权限不能为空 |
| | | @Autowired |
| | | private ISysOrganizationService iSysOrganizationService; |
| | | @Autowired |
| | | private ISysRoleService iSysRoleService; |
| | | @Autowired |
| | | private SysOrganizationServiceImpl sysOrganizationService; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<SysRoleOrganization> findList(Map<String, Object> params) { |
| | | Page<SysRoleOrganization> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysRoleOrganization> list = baseMapper.findList(page, params); |
| | | return PageResult.<SysRoleOrganization>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysRoleOrganization对象当做查询条件进行查询 |
| | | * |
| | | * @param sysRoleOrganization |
| | | * @return SysRoleOrganization |
| | | */ |
| | | @Override |
| | | public SysRoleOrganization findByObject(SysRoleOrganization sysRoleOrganization) { |
| | | return baseMapper.findByObject(sysRoleOrganization); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdateSer(SysRoleOrganizationDto sysRoleOrganizationDto, SysUser user) { |
| | | if (sysRoleOrganizationDto.getRoleId() != null) { |
| | | SysRole sysRole = iSysRoleService.getById(sysRoleOrganizationDto.getRoleId()); |
| | | sysRole.setType(sysRoleOrganizationDto.getType()); |
| | | boolean b = iSysRoleService.updateById(sysRole); |
| | | } |
| | | SysRoleOrganization sysRoleOrganization = new SysRoleOrganization(); |
| | | sysRoleOrganization.setRoleId(sysRoleOrganizationDto.getRoleId()); |
| | | List<SysOrganization> organizations = user.getOrganizations(); |
| | | // 1代表全部数据权限,2自定义数据权限,3本部门数据权限,4本部门及以下数据权限,5仅本人数据权限不能为空") |
| | | //先清除数据 |
| | | if(sysRoleOrganizationDto.getRoleId()!=null){ |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("role_id",sysRoleOrganizationDto.getRoleId()); |
| | | map.put("is_del",0); |
| | | List<SysRoleOrganization> sysRoleOrganizations = baseMapper.selectByMap(map); |
| | | List<Long> collect = sysRoleOrganizations.stream().map(e -> e.getId()).collect(Collectors.toList()); |
| | | if(collect.size()>0){ |
| | | int i = baseMapper.deleteBatchIds(collect); |
| | | } |
| | | } |
| | | |
| | | //全部数据 |
| | | if (sysRoleOrganizationDto.getType() == TYPE_QUAN_BU) { |
| | | // sysRoleOrganization.setOrgCode("10"); |
| | | // if (organizations != null && organizations.size() > 0) { |
| | | // sysRoleOrganization.setOrgId(organizations.get(organizations.size()-1).getId()); |
| | | // } |
| | | // baseMapper.insert(sysRoleOrganization); |
| | | } |
| | | //2自定义数据权限 |
| | | if (sysRoleOrganizationDto.getType() == TYPE_ZI_DING_YI) { |
| | | |
| | | List<Long> orgIds = sysRoleOrganizationDto.getOrgIds(); |
| | | orgIds.forEach(e -> { |
| | | sysRoleOrganization.setId(null); |
| | | sysRoleOrganization.setOrgId(e); |
| | | SysOrganization byId = iSysOrganizationService.getById(e); |
| | | if (byId != null) { |
| | | sysRoleOrganization.setOrgCode(byId.getOrgCode()); |
| | | } |
| | | baseMapper.insert(sysRoleOrganization); |
| | | }); |
| | | }else { |
| | | |
| | | } |
| | | //3本部门数据权限 |
| | | if (sysRoleOrganizationDto.getType() == TYPE_BEN_BU_MEN) { |
| | | if (organizations != null && organizations.size() > 0) { |
| | | sysRoleOrganization.setOrgCode(organizations.get(organizations.size()-1).getOrgCode()); |
| | | sysRoleOrganization.setOrgId(organizations.get(organizations.size()-1).getId()); |
| | | baseMapper.insert(sysRoleOrganization); |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | //4本部门及以下数据权限 |
| | | if (sysRoleOrganizationDto.getType() == TYPE_BEN_BU_MEN_YI_XIA) { |
| | | if (organizations != null && organizations.size() > 0) { |
| | | sysRoleOrganization.setOrgCode(organizations.get(organizations.size()-1).getOrgCode()); |
| | | sysRoleOrganization.setOrgId(organizations.get(organizations.size()-1).getId()); |
| | | baseMapper.insert(sysRoleOrganization); |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | //5仅本人数据权限不能为空 |
| | | if (sysRoleOrganizationDto.getType() == TYPE_BEN_REN) { |
| | | sysRoleOrganization.setOrgCode(organizations.get(organizations.size()-1).getOrgCode()); |
| | | sysRoleOrganization.setOrgId(organizations.get(organizations.size()-1).getId()); |
| | | baseMapper.insert(sysRoleOrganization); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody getTree(Map<String, Object> params, SysUser user) { |
| | | List<SysOrganization> sysOrganizations = sysOrganizationService.listByMap(params); |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | List<Long> roleIdList = user.getRoles().stream().map(e -> e.getId()).collect(Collectors.toList()); |
| | | queryWrapper.in("role_id", roleIdList); |
| | | List<SysRoleOrganization> list = baseMapper.selectList(queryWrapper); |
| | | List<Long> collect = list.stream().map(e -> e.getOrgId()).collect(Collectors.toList()); |
| | | List<Map<String, Object>> treeData = getTreeData(Long.valueOf("-1"), sysOrganizations, collect); |
| | | return ResultBody.ok().data(treeData); |
| | | } |
| | | |
| | | /** |
| | | * 将数据 封装成 tree (递归方式) |
| | | * |
| | | * @param MyId |
| | | * @param sysOrganizations |
| | | * @return |
| | | */ |
| | | public List<Map<String, Object>> getTreeData(Long MyId, List<SysOrganization> sysOrganizations, List<Long> col) { |
| | | 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()); |
| | | map.put("checked", col.contains(id)); |
| | | List<Long> childs = sysOrganizations.stream().filter(e -> e.getOrgParentId() == id).map(e -> e.getId()).collect(Collectors.toList()); |
| | | if (childs.size() > 0) { |
| | | List<Map<String, Object>> treeData = getTreeData(id, sysOrganizations, col); |
| | | map.put("children", treeData); |
| | | } |
| | | listMap.add(map); |
| | | } |
| | | return listMap; |
| | | } |
| | | } |
| | |
| | | <if test="p.updateTime != null and p.updateTime !=''"> |
| | | and update_time = #{p.updateTime} |
| | | </if> |
| | | <if test="p.likes != null and p.likes.size>0"> |
| | | |
| | | <foreach item="item" collection="p.likes" index=""> |
| | | <foreach item="itemto" collection="item" index="inx"> |
| | | |
| | | |
| | | <choose> |
| | | <when test="inx.type == 1"></when> |
| | | |
| | | <when test="inx.type==2"> |
| | | AND |
| | | <foreach item="itemtoto" collection="itemto" separator="or" open="(" close=")" index=""> |
| | | create_user_org_code like '${itemtoto.orgCode}%' |
| | | </foreach> |
| | | </when> |
| | | <when test="inx.type == 3"> |
| | | AND |
| | | <foreach item="itemtoto" collection="itemto" separator="or" open="(" close=")" index=""> |
| | | create_user_org_code = #{itemtoto.orgCode} |
| | | </foreach> |
| | | </when> |
| | | <when test="inx.type == 4"> |
| | | AND |
| | | <foreach item="itemtoto" collection="itemto" separator="or" open="(" close=")" index=""> |
| | | create_user_org_code like '${itemtoto.orgCode}%' |
| | | </foreach> |
| | | </when> |
| | | <when test="inx.type == 5"> |
| | | AND |
| | | <foreach item="itemtoto" collection="itemto" separator="or" open="(" close=")" index=""> |
| | | create_user_id = #{itemtoto.orgCode} |
| | | </foreach> |
| | | </when> |
| | | <otherwise> |
| | | AND id is null |
| | | </otherwise> |
| | | </choose> |
| | | |
| | | </foreach> |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | |
| | | update_time, |
| | | is_del, |
| | | enabled, |
| | | tenant_id |
| | | tenant_id, |
| | | type |
| | | </sql> |
| | | |
| | | <sql id="where"> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <!--角色对应的 部门--> |
| | | <mapper namespace="com.kidgrow.usercenter.mapper.SysRoleOrganizationMapper"> |
| | | <!--定义查询列--> |
| | | <sql id="Column_List"> |
| | | * |
| | | </sql> |
| | | |
| | | <!--sql查询片段--> |
| | | <sql id="where"> |
| | | <where> |
| | | <!--查询条件自行添加--> |
| | | is_del=0 |
| | | <if test="p.id != null and p.id !=''"> |
| | | and id = #{p.id} |
| | | </if> |
| | | <if test="p.type != null and p.type !=''"> |
| | | and type = #{p.type} |
| | | </if> |
| | | <if test="p.roleId != null and p.roleId !=''"> |
| | | and role_id = #{p.roleId} |
| | | </if> |
| | | <if test="p.orgId != null and p.orgId !=''"> |
| | | and org_id = #{p.orgId} |
| | | </if> |
| | | <if test="p.orgCode != null and p.orgCode !=''"> |
| | | and org_code = #{p.orgCode} |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | | <!--定义根据-SysRoleOrganization当作查询条件返回对象--> |
| | | <select id="findByObject" resultType="com.kidgrow.usercenter.model.SysRoleOrganization"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_role_organization |
| | | <include refid="where"/> |
| | | order by id desc |
| | | limit 1 |
| | | </select> |
| | | |
| | | <!--定义根据-SysRoleOrganization当作查询条件返回对象集合--> |
| | | <select id="findList" resultType="com.kidgrow.usercenter.model.SysRoleOrganization"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_role_organization |
| | | <include refid="where"/> |
| | | order by id desc |
| | | </select> |
| | | </mapper> |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.usercenter.vo.SysDoctorVo; |
| | | import com.kidgrow.usercenter.vo.SysDoctorDto; |
| | |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult<SysDoctorVo> list(@RequestParam Map<String, Object> params) { |
| | | public PageResult<SysDoctorVo> list(@RequestParam Map<String, Object> params,@LoginUser SysUser user) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return sysDoctorService.findList(params); |
| | | |
| | | return sysDoctorService.findList(params,user); |
| | | } |
| | | |
| | | /** |
New file |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.usercenter.dto.SysRoleOrganizationDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.usercenter.service.ISysRoleOrganizationService; |
| | | import com.kidgrow.common.model.*; |
| | | |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.validation.ObjectError; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Valid; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 角色对应的 部门 |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version: 1.0 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sysroleorganization") |
| | | @Api(tags = "角色对应的 部门") |
| | | public class SysRoleOrganizationController extends BaseController{ |
| | | @Autowired |
| | | private ISysRoleOrganizationService sysRoleOrganizationService; |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @ApiOperation(value = "查询列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public ResultBody<PageResult> list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return ResultBody.ok().data(sysRoleOrganizationService.findList(params)); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/{id}") |
| | | public ResultBody findById(@PathVariable Long id) { |
| | | SysRoleOrganization model = sysRoleOrganizationService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysRoleOrganization当做查询条件进行查询 |
| | | */ |
| | | @ApiOperation(value = "根据SysRoleOrganization当做查询条件进行查询") |
| | | @PostMapping("/query") |
| | | public ResultBody findByObject(@RequestBody SysRoleOrganization sysRoleOrganization) { |
| | | SysRoleOrganization model = sysRoleOrganizationService.findByObject(sysRoleOrganization); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysRoleOrganizationDto sysRoleOrganizationDto, BindingResult bindingResult, @LoginUser SysUser user, HttpServletRequest request) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | String header = request.getHeader(SecurityConstants.USER_ORG_ID_HEADER); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | | errMsg.add(error.getDefaultMessage()); |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | boolean v= sysRoleOrganizationService.saveOrUpdateSer(sysRoleOrganizationDto,user); |
| | | if(v) { |
| | | return ResultBody.ok().data(sysRoleOrganizationDto).msg("保存成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | } |
| | | } |
| | | @ApiOperation(value = "获取tree") |
| | | @GetMapping("getTree") |
| | | public ResultBody getTree(@RequestParam Map<String, Object> params,@LoginUser SysUser user) { |
| | | return sysRoleOrganizationService.getTree(params,user); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | boolean v= sysRoleOrganizationService.removeById(id); |
| | | if(v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | - sys_department |
| | | - sys_area |
| | | - sys_company |
| | | - sys_role_organization |
| | | ignoreSqls: |
| | | - com.kidgrow.usercenter.mapper.SysRoleMapper.findAll |
| | | |
| | |
| | | String USER_ID_HEADER = "x-userid-header"; |
| | | |
| | | /** |
| | | * 用户所属组织 为集合 |
| | | * 用户所属组织 |
| | | */ |
| | | String USER_ORGS_HEADER="x-user-orgs-header"; |
| | | /** |
| | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateUserName; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUserOrgCode; |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | |
| | | */ |
| | | @Data |
| | | public class SuperEntity<T extends Model<?>> extends Model<T> { |
| | | |
| | | /** |
| | | * 主键ID,防止Long类型四舍五入 |
| | | */ |
| | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateUserName; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUserOrgCode; |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | |
| | | */ |
| | | @Data |
| | | public class SuperModel<T extends Model<?>> extends Model<T>{ |
| | | |
| | | |
| | | /** |
| | | * 主键ID,雪花算法类型 |
| | | */ |
| | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateUserName; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUserOrgCode; |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © 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 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | |
| | | */ |
| | | private Integer orgOrder; |
| | | /** |
| | | * 部门的code |
| | | */ |
| | | private String orgCode; |
| | | /** |
| | | * 是否删除,1删除,0未删除 |
| | | */ |
| | | private Boolean isDel; |
| | |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @TableField(exist = false) |
| | | private Long userId; |
| | | private Integer type; |
| | | } |
| | |
| | | @AllArgsConstructor |
| | | @TableName("sys_user_org") |
| | | public class SysUserOrg extends SuperModel { |
| | | private static final long serialVersionUID=1L; |
| | | // private static final long serialVersionUID = -2071565876962058344L; |
| | | |
| | | /** |
| | | * 用户id |
| | |
| | | package com.kidgrow.db.config; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | |
| | | private final static String UPDATE_USER_ID="updateUserId"; |
| | | private final static String CREATE_USER_NAME="createUserName"; |
| | | private final static String UPDATE_USER_NAME="updateUserName"; |
| | | private final static String CREATE_USER_ORG_CODE = "createUserOrgCode"; |
| | | |
| | | /** |
| | | * 插入填充,字段为空自动填充 |
| | |
| | | Object updateUserId = getFieldValByName(UPDATE_USER_ID, metaObject); |
| | | Object createUserName = getFieldValByName(CREATE_USER_NAME, metaObject); |
| | | Object updateUserName = getFieldValByName(UPDATE_USER_NAME, metaObject); |
| | | if (createTime == null || updateTime == null || createUserId==null || updateUserId==null || createUserName==null || updateUserName==null) { |
| | | Object createUserOrgCode = getFieldValByName(CREATE_USER_ORG_CODE, metaObject); |
| | | if (createTime == null || updateTime == null || createUserId == null || updateUserId == null || createUserName == null || updateUserName == null || createUserOrgCode == null) { |
| | | Date date = new Date(); |
| | | if (createTime == null) { |
| | | setFieldValByName(CREATE_TIME, date, metaObject); |
| | |
| | | setFieldValByName(CREATE_USER_NAME, request.getHeader(SecurityConstants.USER_HEADER), metaObject); |
| | | } |
| | | } |
| | | if (createUserOrgCode == null) { |
| | | if (request.getHeader(SecurityConstants.USER_ORGS_HEADER) != null) { |
| | | //获取orgLevel等级高的 |
| | | List<SysOrganization> sysOrganizations = JSON.parseArray(request.getHeader(SecurityConstants.USER_ORGS_HEADER), SysOrganization.class); |
| | | setFieldValByName(CREATE_USER_ORG_CODE,sysOrganizations.get(sysOrganizations.size()-1).getOrgCode() , metaObject); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | requestHeaders.add(SecurityConstants.USER_DEP_ID_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_DEP_NAME_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORG_ID_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORGS_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORG_NAME_HEADER); |
| | | requestHeaders.add(SecurityConstants.ROLE_HEADER); |
| | | requestHeaders.add(SecurityConstants.CLIENT_HEADER); |
| | |
| | | ##### Redis\u914D\u7F6E |
| | | # \u662F\u5426\u5F00\u542FRedis\u7F13\u5B58 true\u5F00\u542F false \u5173\u95ED |
| | | spring.redis.open=true |
| | | spring.redis.host=192.168.2.240 |
| | | #spring.redis.host=192.168.2.240 |
| | | spring.redis.host=127.0.0.1 |
| | | spring.redis.port=6379 |
| | | spring.redis.password=kidgrow |
| | | spring.redis.timeout=5000 |
| | |
| | | kidgrow.druid.loginpwd=123456 |
| | | |
| | | #eureka \u6CE8\u518C\u4E2D\u5FC3Url |
| | | kidgrow.eureka.client.serviceUrl.defaultZone=http://192.168.2.240:9001/eureka/ |
| | | kidgrow.eureka.client.serviceUrl.defaultZone=http://127.0.0.1:9001/eureka/ |
| | | kidgrow.eureka.instance.hostname=127.0.0.1 |
| | | ##eureka client\u53D1\u9001\u5FC3\u8DF3\u7ED9server\u7AEF\u7684\u9891\u7387 |
| | | eureka.instance.lease-renewal-interval-in-seconds=30 |
| | |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(organizations.get(0).getOrgName(),"UTF-8")); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(organizations.size()-1).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,URLEncoder.encode(organizations.get(organizations.size()-1).getOrgName(),"UTF-8")); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER,JSON.toJSONString(organizations.get(organizations.size()-1))); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER,JSON.toJSONString(organizations)); |
| | | //将角色放到header |
| | | ctx.addZuulRequestHeader(SecurityConstants.ROLE_HEADER, JSON.toJSONString(user.getRoles())); |
| | | tenantId=String.valueOf(organizations.get(0).getId()); |
| | | } |
| | | |
| | | |
| | |
| | | // debugger; |
| | | config.putUser(user); |
| | | admin.putTempData("permissions", user.permissions); |
| | | admin.putTempData("organization",user.organizations[user.organizations.length-1]); |
| | | success(user); |
| | | } else { |
| | | if (data.code === 1000) { |
| | |
| | | </li> |
| | | </ul> |
| | | <ul class="layui-nav layui-layout-right"> |
| | | <!--<li class="layui-nav-item" lay-unselect>--> |
| | | <!--<a id="btnMessage" title="消息"><i class="layui-icon layui-icon-notice"></i></a>--> |
| | | <!--</li>--> |
| | | <!-- <li class="layui-nav-item" lay-unselect> |
| | | <a id="btnMessage" title="消息"><i class="layui-icon layui-icon-notice"></i></a> |
| | | </li> --> |
| | | <li class="layui-nav-item" lay-unselect> |
| | | <a title="消息"><i class="layui-icon layui-icon-notice" id="organization">1231</i></a> |
| | | </li> |
| | | <li class="layui-nav-item layui-hide-xs" lay-unselect> |
| | | <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a> |
| | | </li> |
| | |
| | | <!-- <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>--> |
| | | <!-- </li>--> |
| | | </ul> |
| | | <script> |
| | | layui.use([ 'admin'], function () { |
| | | var admin = layui.admin |
| | | , $ = layui.jquery; |
| | | var organization=admin.getTempData("organization"); |
| | | $("#organization").html("wer"); |
| | | console.log($("#organization").html()) |
| | | }) |
| | | |
| | | </script> |
| | |
| | | if (d.orgAttr == 0) { |
| | | return "集团"; |
| | | } else if (d.orgAttr == 1) { |
| | | return "公司"; |
| | | return "公司/医院"; |
| | | } else if (d.orgAttr == 2) { |
| | | return "部门"; |
| | | return "部门/科室"; |
| | | }else{ |
| | | return "子部门/子科室"; |
| | | } |
| | | } |
| | | }, |
| | |
| | | </div> |
| | | |
| | | <!-- 数据表格 --> |
| | | <table class="layui-table" id="role-table" lay-filter="role-table"></table> |
| | | <table class="layui-hide" id="role-table" lay-filter="role-table"></table> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | </form> |
| | | </script> |
| | | |
| | | <!-- 数据权限 表单弹窗 --> |
| | | <script type="text/html" id="role-model-role"> |
| | | <form id="role-form" lay-filter="role-form" class="layui-form model-form"> |
| | | <input name="id" type="hidden"/> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">角色名</label> |
| | | <div class="layui-input-block"> |
| | | <input name="name" placeholder="请输入角色名" type="text" class="layui-input" maxlength="20" |
| | | lay-verify="required" required/> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">Code</label> |
| | | <div class="layui-input-block"> |
| | | <input name="code" placeholder="请输入Code" type="text" class="layui-input" maxlength="20" |
| | | lay-verify="required" required /> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">权限范围</label> |
| | | <div class="layui-input-block"> |
| | | <select name="type" lay-filter="role_organization"> |
| | | <option value="">请选择权限</option> |
| | | <option value="1">全部数据权限</option> |
| | | <option value="2">自定义数据权限</option> |
| | | <option value="3">本部门数据权限</option> |
| | | <option value="4">本部门及以下数据权限</option> |
| | | <option value="5">仅本人数据权限</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item" id="tree"> |
| | | <!-- <label class="layui-form-label">数据权限</label> --> |
| | | <!-- <div id="orgParentId-tree" class="demo-tree demo-tree-box"></div> --> |
| | | <ul id="treeMenu-role" class="ztree" style="padding: 25px 0px 20px 60px;"></ul> |
| | | </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" lay-filter="role-form-submit-role" lay-submit>保存</button> |
| | | </div> |
| | | </form> |
| | | </script> |
| | | |
| | | <!-- 表格操作列 --> |
| | | <script type="text/html" id="role-table-bar"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> |
| | | <a class="layui-btn layui-btn-xs" lay-event="auth">权限分配</a> |
| | | <a class="layui-btn layui-btn-xs" lay-event="auth_role">分配数据权限</a> |
| | | </script> |
| | | |
| | | <!-- 表格状态列 --> |
| | |
| | | </script> |
| | | |
| | | <script> |
| | | layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects'], function () { |
| | | layui.use(['form', 'table', 'util', 'config', 'tree', 'admin', 'formSelects'], function () { |
| | | var form = layui.form; |
| | | var table = layui.table; |
| | | var config = layui.config; |
| | |
| | | var util = layui.util; |
| | | var admin = layui.admin; |
| | | var formSelects = layui.formSelects; |
| | | //树形插件 |
| | | var tree = layui.tree; |
| | | var layer = layui.layer |
| | | , $ = layui.jquery; |
| | | //常量 |
| | | var clientsAll =null; |
| | | |
| | | //渲染表格 |
| | |
| | | url: config.base_server + 'api-user/roles', |
| | | headers:{'Authorization': 'Bearer ' + config.getToken().access_token}, |
| | | page: true, |
| | | cellMinWidth: 80, |
| | | cols: [[ |
| | | {type: 'numbers'}, |
| | | {field: 'id', sort: true, title: 'ID',width: 80}, |
| | |
| | | }, title: '创建时间' |
| | | }, |
| | | {field: 'enabled', width: 100,sort: true, templet: '#role-tpl-state', title: '状态'}, |
| | | {align: 'center', toolbar: '#role-table-bar', title: '操作',width: 250} |
| | | { align: 'center', toolbar: '#role-table-bar', title: '操作', width: 320 } |
| | | ]] |
| | | }); |
| | | |
| | |
| | | }, $('#role-form').attr('method')); |
| | | return false; |
| | | }); |
| | | // 表单提交事件 |
| | | form.on('submit(role-form-submit-role)', function (data) { |
| | | var array=new Array(); |
| | | var treeObj = $.fn.zTree.getZTreeObj('treeMenu-role'); |
| | | var nodes = treeObj.getCheckedNodes(true); |
| | | $.each(nodes,function(i,item){ |
| | | // console.log(item) |
| | | if(!item.children){ |
| | | array.push(item.id); |
| | | } |
| | | }) |
| | | if(array.length>0){ |
| | | data.field.orgIds=array |
| | | } |
| | | data.field.roleId= data.field.id |
| | | layer.load(2); |
| | | admin.req('api-user/sysroleorganization', JSON.stringify(data.field), function (data) { |
| | | layer.closeAll('loading'); |
| | | console.log(data); |
| | | if (data.code === 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | table.reload('role-table'); |
| | | layer.closeAll('page'); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | } |
| | | }, $('#role-form').attr('method')); |
| | | layer.closeAll('page'); |
| | | return false; |
| | | }); |
| | | |
| | | // 工具条点击事件 |
| | | table.on('tool(role-table)', function (obj) { |
| | |
| | | doDelete(obj); |
| | | } else if (obj.event === 'auth') { // 权限分配 |
| | | showMenuDialog(obj.data.id,obj.data.tenantId); |
| | | } else if (obj.event === 'auth_role') { |
| | | showEditModelRole(data); |
| | | } |
| | | }); |
| | | |
| | |
| | | table.reload('role-table', {where: {searchKey: key, searchValue: value}}); |
| | | }); |
| | | |
| | | var getData = function () { |
| | | admin.req('api-user/sysroleorganization/getTree', { is_del: 0 }, function (data) { |
| | | layer.closeAll('loading'); |
| | | var data1 = [{ |
| | | name: '常用文件夹', |
| | | id: 1, |
| | | children: [ |
| | | { name: '所有未读', id: 11 }, |
| | | { name: '置顶邮件', id: 12 }, |
| | | { name: '标签邮件', id: 13 }] |
| | | }]; |
| | | if (0 === data.code) { |
| | | var setting = { |
| | | check: { enable: true }, |
| | | data: { |
| | | simpleData: { |
| | | enable: true |
| | | } |
| | | } |
| | | }; |
| | | $.fn.zTree.init($('#treeMenu-role'), setting, data.data); |
| | | layer.closeAll('loading'); |
| | | |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | } |
| | | }, 'get'); |
| | | } |
| | | // 显示编辑弹窗 |
| | | var showEditModel = function (data) { |
| | | layer.open({ |
| | |
| | | } |
| | | }); |
| | | }; |
| | | //数据权限的点击事件 |
| | | form.on('select(role_organization)', function (data) { |
| | | console.log(data.value) |
| | | if (data.value == 2) { |
| | | $("#tree").show(); |
| | | }else{ |
| | | $("#tree").hide(); |
| | | } |
| | | }); |
| | | // 显示分配数据权限弹窗 |
| | | var showEditModelRole = function (data) { |
| | | layer.open({ |
| | | type: 1, |
| | | title: "分配数据权限", |
| | | area: '450px', |
| | | offset: '120px', |
| | | content: $('#role-model-role').html(), |
| | | success: function () { |
| | | $('#role-form')[0].reset(); |
| | | $('#role-form').attr('method', 'POST'); |
| | | if (data) { |
| | | getData(); |
| | | console.log(data.type) |
| | | if(data.type!=2){ |
| | | $("#tree").hide(); |
| | | } |
| | | form.render(); |
| | | form.val('role-form', data); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | }; |
| | | // 删除 |
| | | var doDelete = function (obj) { |
| | | layer.confirm('确定要删除吗?', function (i) { |