扩展当前登录用户组织机构信息
1、组织机构ID、名称
2、部门ID、名称
12 files added
13 files modified
New file |
| | |
| | | package com.kidgrow.usercenter.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.db.mapper.SuperMapper; |
| | | 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-03-31 11:01:35 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | public interface SysOrganizationMapper extends SuperMapper<SysOrganization> { |
| | | /** |
| | | * 分页查询组织架构表列表 |
| | | * @param page |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<SysOrganization> findList(Page<SysOrganization> page, @Param("p") Map<String, Object> params); |
| | | |
| | | /** |
| | | * 根据SysOrganization对象当做查询条件进行查询 |
| | | * @param |
| | | * @return SysOrganization对象 |
| | | */ |
| | | SysOrganization findByObject(SysOrganization sysOrganization); |
| | | |
| | | |
| | | /** |
| | | * 根据用户ID获取用户组织机构列表 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<SysOrganization> findListByUserId(Long userId); |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.db.mapper.SuperMapper; |
| | | 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-03-31 11:01:35 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | public interface SysUserOrgMapper extends SuperMapper<SysUserOrg> { |
| | | /** |
| | | * 分页查询用户和组织关系表列表 |
| | | * @param page |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<SysUserOrg> findList(Page<SysUserOrg> page, @Param("p") Map<String, Object> params); |
| | | |
| | | /** |
| | | * 根据SysUserOrg对象当做查询条件进行查询 |
| | | * @param |
| | | * @return SysUserOrg对象 |
| | | */ |
| | | SysUserOrg findByObject(SysUserOrg sysUserOrg); |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.service; |
| | | |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.service.ISuperService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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 |
| | | */ |
| | | public interface ISysOrganizationService extends ISuperService<SysOrganization> { |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | PageResult<SysOrganization> findList(Map<String, Object> params); |
| | | |
| | | |
| | | /** |
| | | * 根据SysOrganization对象当做查询条件进行查询 |
| | | * @param sysOrganization |
| | | * @return SysOrganization对象 |
| | | */ |
| | | SysOrganization findByObject(SysOrganization sysOrganization); |
| | | |
| | | |
| | | /** |
| | | * 通过用户ID获取用户所属组织机构列表 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<SysOrganization> findListByUserId(Long userId); |
| | | } |
| | | |
New file |
| | |
| | | package com.kidgrow.usercenter.service; |
| | | |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.common.service.ISuperService; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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 |
| | | */ |
| | | public interface ISysUserOrgService extends ISuperService<SysUserOrg> { |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | PageResult<SysUserOrg> findList(Map<String, Object> params); |
| | | |
| | | |
| | | /** |
| | | * 根据SysUserOrg对象当做查询条件进行查询 |
| | | * @param sysUserOrg |
| | | * @return SysUserOrg对象 |
| | | */ |
| | | SysUserOrg findByObject(SysUserOrg sysUserOrg); |
| | | } |
| | | |
New file |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.usercenter.mapper.SysOrganizationMapper; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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 { |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | 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); |
| | | return PageResult.<SysOrganization>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysOrganization对象当做查询条件进行查询 |
| | | * @param sysOrganization |
| | | * @return SysOrganization |
| | | */ |
| | | @Override |
| | | public SysOrganization findByObject(SysOrganization sysOrganization){ |
| | | return baseMapper.findByObject(sysOrganization); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysOrganization> findListByUserId(Long userId) { |
| | | return baseMapper.findListByUserId(userId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.usercenter.mapper.SysUserOrgMapper; |
| | | import com.kidgrow.usercenter.service.ISysUserOrgService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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 SysUserOrgServiceImpl extends SuperServiceImpl<SysUserOrgMapper, SysUserOrg> implements ISysUserOrgService { |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<SysUserOrg> findList(Map<String, Object> params){ |
| | | Page<SysUserOrg> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<SysUserOrg> list = baseMapper.findList(page, params); |
| | | return PageResult.<SysUserOrg>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysUserOrg对象当做查询条件进行查询 |
| | | * @param sysUserOrg |
| | | * @return SysUserOrg |
| | | */ |
| | | @Override |
| | | public SysUserOrg findByObject(SysUserOrg sysUserOrg){ |
| | | return baseMapper.findByObject(sysUserOrg); |
| | | } |
| | | } |
| | |
| | | import com.kidgrow.usercenter.mapper.SysUserMapper; |
| | | import com.kidgrow.usercenter.model.SysRoleUser; |
| | | import com.kidgrow.usercenter.model.SysUserExcel; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import com.kidgrow.usercenter.service.ISysRoleUserService; |
| | | import com.kidgrow.usercenter.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Resource |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | @Autowired |
| | | private ISysOrganizationService organizationService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | |
| | | if (sysUser != null) { |
| | | LoginAppUser loginAppUser = new LoginAppUser(); |
| | | BeanUtils.copyProperties(sysUser, loginAppUser); |
| | | |
| | | //获取用户所属组织机构列表 |
| | | List<SysOrganization> sysOrganizations = organizationService.findListByUserId(sysUser.getId()); |
| | | //设置组织机构集合 |
| | | loginAppUser.setOrganizations(sysOrganizations); |
| | | List<SysRole> sysRoles = roleUserService.findRolesByUserId(sysUser.getId()); |
| | | // 设置角色 |
| | | loginAppUser.setRoles(sysRoles); |
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.SysOrganizationMapper"> |
| | | <!--定义查询列--> |
| | | <sql id="Column_List"> |
| | | * |
| | | </sql> |
| | | |
| | | <!--sql查询片段--> |
| | | <sql id="where"> |
| | | <where> |
| | | <!--查询条件自行添加--> |
| | | is_del=0 |
| | | <if test="id != null and id !=''"> |
| | | and id = #{id} |
| | | </if> |
| | | <if test="orgLevel != null and orgLevel !=''"> |
| | | and org_level = #{orgLevel} |
| | | </if> |
| | | <if test="orgAttr != null and orgAttr !=''"> |
| | | and org_attr = #{orgAttr} |
| | | </if> |
| | | <if test="orgParentId != null and orgParentId !=''"> |
| | | and org_parent_id = #{orgParentId} |
| | | </if> |
| | | <if test="orgName != null and orgName !=''"> |
| | | and org_name = #{orgName} |
| | | </if> |
| | | <if test="orgOrder != null and orgOrder !=''"> |
| | | and org_order = #{orgOrder} |
| | | </if> |
| | | <if test="isDel != null and isDel !=''"> |
| | | and is_del = #{isDel} |
| | | </if> |
| | | <if test="enabled != null and enabled !=''"> |
| | | and enabled = #{enabled} |
| | | </if> |
| | | <if test="createUserId != null and createUserId !=''"> |
| | | and create_user_id = #{createUserId} |
| | | </if> |
| | | <if test="createUserName != null and createUserName !=''"> |
| | | and create_user_name = #{createUserName} |
| | | </if> |
| | | <if test="updateUserId != null and updateUserId !=''"> |
| | | and update_user_id = #{updateUserId} |
| | | </if> |
| | | <if test="updateUserName != null and updateUserName !=''"> |
| | | and update_user_name = #{updateUserName} |
| | | </if> |
| | | <if test="createTime != null and createTime !=''"> |
| | | and create_time = #{createTime} |
| | | </if> |
| | | <if test="updateTime != null and updateTime !=''"> |
| | | and update_time = #{updateTime} |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | | <!--定义根据-SysOrganization当作查询条件返回对象--> |
| | | <select id="findByObject" resultType="com.kidgrow.common.model.SysOrganization"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_organization |
| | | <include refid="where"/> |
| | | </select> |
| | | |
| | | <!--定义根据-SysOrganization当作查询条件返回对象集合--> |
| | | <select id="findList" resultType="com.kidgrow.common.model.SysOrganization"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_organization |
| | | <include refid="where"/> |
| | | order by id desc |
| | | </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} |
| | | </select> |
| | | </mapper> |
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.SysUserOrgMapper"> |
| | | <!--定义查询列--> |
| | | <sql id="Column_List"> |
| | | * |
| | | </sql> |
| | | |
| | | <!--sql查询片段--> |
| | | <sql id="where"> |
| | | <where> |
| | | <!--查询条件自行添加--> |
| | | is_del=0 |
| | | <if test="id != null and id !=''"> |
| | | and id = #{id} |
| | | </if> |
| | | <if test="userId != null and userId !=''"> |
| | | and user_id = #{userId} |
| | | </if> |
| | | <if test="orgId != null and orgId !=''"> |
| | | and org_id = #{orgId} |
| | | </if> |
| | | <if test="enabled != null and enabled !=''"> |
| | | and enabled = #{enabled} |
| | | </if> |
| | | <if test="isDel != null and isDel !=''"> |
| | | and is_del = #{isDel} |
| | | </if> |
| | | <if test="createUserId != null and createUserId !=''"> |
| | | and create_user_id = #{createUserId} |
| | | </if> |
| | | <if test="createUserName != null and createUserName !=''"> |
| | | and create_user_name = #{createUserName} |
| | | </if> |
| | | <if test="updateUserId != null and updateUserId !=''"> |
| | | and update_user_id = #{updateUserId} |
| | | </if> |
| | | <if test="updateUserName != null and updateUserName !=''"> |
| | | and update_user_name = #{updateUserName} |
| | | </if> |
| | | <if test="createTime != null and createTime !=''"> |
| | | and create_time = #{createTime} |
| | | </if> |
| | | <if test="updateTime != null and updateTime !=''"> |
| | | and update_time = #{updateTime} |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | | <!--定义根据-SysUserOrg当作查询条件返回对象--> |
| | | <select id="findByObject" resultType="com.kidgrow.common.model.SysUserOrg"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_user_org |
| | | <include refid="where"/> |
| | | </select> |
| | | |
| | | <!--定义根据-SysUserOrg当作查询条件返回对象集合--> |
| | | <select id="findList" resultType="com.kidgrow.common.model.SysUserOrg"> |
| | | select |
| | | <include refid="Column_List"/> |
| | | from sys_user_org |
| | | <include refid="where"/> |
| | | order by id desc |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | 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 org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 组织架构表 |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-03-31 11:01:35 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version: 1.0 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sysorganization") |
| | | @Api(tags = "组织架构表") |
| | | public class SysOrganizationController extends BaseController{ |
| | | @Autowired |
| | | private ISysOrganizationService sysOrganizationService; |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @ApiOperation(value = "查询列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return sysOrganizationService.findList(params); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/{id}") |
| | | public ResultBody findById(@PathVariable Long id) { |
| | | SysOrganization model = sysOrganizationService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysOrganization当做查询条件进行查询 |
| | | */ |
| | | @ApiOperation(value = "根据SysOrganization当做查询条件进行查询") |
| | | @PostMapping("/query") |
| | | public ResultBody findByObject(@RequestBody SysOrganization sysOrganization) { |
| | | SysOrganization model = sysOrganizationService.findByObject(sysOrganization); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysOrganization sysOrganization, BindingResult bindingResult) { |
| | | if (bindingResult.hasErrors()) { |
| | | return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage()); |
| | | } else { |
| | | sysOrganizationService.saveOrUpdate(sysOrganization); |
| | | return ResultBody.ok().data(sysOrganization).msg("保存成功"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | sysOrganizationService.removeById(id); |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysUserOrg; |
| | | import com.kidgrow.usercenter.service.ISysUserOrgService; |
| | | 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 org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 用户和组织关系表 |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-03-31 11:01:35 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version: 1.0 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sysuserorg") |
| | | @Api(tags = "用户和组织关系表") |
| | | public class SysUserOrgController extends BaseController{ |
| | | @Autowired |
| | | private ISysUserOrgService sysUserOrgService; |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @ApiOperation(value = "查询列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public PageResult list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return sysUserOrgService.findList(params); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/{id}") |
| | | public ResultBody findById(@PathVariable Long id) { |
| | | SysUserOrg model = sysUserOrgService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysUserOrg当做查询条件进行查询 |
| | | */ |
| | | @ApiOperation(value = "根据SysUserOrg当做查询条件进行查询") |
| | | @PostMapping("/query") |
| | | public ResultBody findByObject(@RequestBody SysUserOrg sysUserOrg) { |
| | | SysUserOrg model = sysUserOrgService.findByObject(sysUserOrg); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysUserOrg sysUserOrg, BindingResult bindingResult) { |
| | | if (bindingResult.hasErrors()) { |
| | | return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage()); |
| | | } else { |
| | | sysUserOrgService.saveOrUpdate(sysUserOrg); |
| | | return ResultBody.ok().data(sysUserOrg).msg("保存成功"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | sysUserOrgService.removeById(id); |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | } |
| | |
| | | - sys_role |
| | | - sys_menu |
| | | - sys_user_logs |
| | | - sys_organization |
| | | - sys_user_org |
| | | ignoreSqls: |
| | | - com.kidgrow.usercenter.mapper.SysRoleMapper.findAll |
| | | |
| | |
| | | String USER_ID_HEADER = "x-userid-header"; |
| | | |
| | | /** |
| | | * 用户所属组织ID |
| | | */ |
| | | String USER_ORG_ID_HEADER="x-user-org-id-header"; |
| | | |
| | | /** |
| | | * 用户所属组织名称 |
| | | */ |
| | | String USER_ORG_NAME_HEADER="x-user-org-name-header"; |
| | | |
| | | /** |
| | | * 用户所属部门ID |
| | | */ |
| | | String USER_DEP_ID_HEADER="x-user-dep-id-header"; |
| | | |
| | | /** |
| | | * 用户所属部门名称 |
| | | */ |
| | | String USER_DEP_NAME_HEADER="x-user-dep-name-header"; |
| | | |
| | | /** |
| | | * 角色信息头 |
| | | */ |
| | | String ROLE_HEADER = "x-role-header"; |
| | |
| | | public String getUserId() { |
| | | return getOpenId(); |
| | | } |
| | | |
| | | // @Override |
| | | // public List<SysOrganization> getOrganizations() { |
| | | // return getOrganizations(); |
| | | // } |
| | | } |
| | | |
New file |
| | |
| | | package com.kidgrow.common.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 java.util.Date; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @TableName("sys_organization") |
| | | public class SysOrganization extends SuperModel { |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | /** |
| | | * 节点级别取值 0-9 |
| | | */ |
| | | @NotBlank(message = "节点级别取值 0-9不能为空") |
| | | private Integer orgLevel; |
| | | /** |
| | | * 节点属性(集团/公司/部门等,取值0,1,2,3,4) |
| | | */ |
| | | private Integer orgAttr; |
| | | /** |
| | | * 上级组织ID |
| | | */ |
| | | private Long orgParentId; |
| | | /** |
| | | * 组织名称 |
| | | */ |
| | | @NotBlank(message = "组织名称不能为空") |
| | | private String orgName; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer orgOrder; |
| | | /** |
| | | * 是否删除,1删除,0未删除 |
| | | */ |
| | | private Boolean isDel; |
| | | /** |
| | | * 状态,1启用,0停用 |
| | | */ |
| | | private Boolean enabled; |
| | | } |
| | |
| | | private String oldPassword; |
| | | @TableField(exist = false) |
| | | private String newPassword; |
| | | @TableField(exist = false) |
| | | private List<SysOrganization> organizations; |
| | | } |
New file |
| | |
| | | package com.kidgrow.common.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 java.util.Date; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @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) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @TableName("sys_user_org") |
| | | public class SysUserOrg extends SuperModel { |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @NotBlank(message = "用户id不能为空") |
| | | private Long userId; |
| | | /** |
| | | * 组织ID |
| | | */ |
| | | @NotBlank(message = "组织ID不能为空") |
| | | private Long orgId; |
| | | /** |
| | | * 状态,1启用,0停用 |
| | | */ |
| | | private Boolean enabled; |
| | | /** |
| | | * 是否删除,1删除,0未删除 |
| | | */ |
| | | private Boolean isDel; |
| | | } |
| | |
| | | ########################## bootstrap\u7EA7\u522B\u901A\u7528\u914D\u7F6E ########################## |
| | | # \u9ED8\u8BA4\u5F00\u53D1\u73AF\u5883 |
| | | spring.profiles.active=fat |
| | | spring.profiles.active=dev |
| | | |
| | | ##### spring-boot-actuator\u914D\u7F6E |
| | | management.endpoints.web.exposure.include=* |
| | |
| | | eureka: |
| | | instance: |
| | | ###注册中心ip地址 |
| | | hostname: 172.17.97.143 |
| | | # hostname: 172.17.97.143 |
| | | hostname: 127.0.0.1 |
| | | lease-renewal-interval-in-seconds: 30 |
| | | lease-expiration-duration-in-seconds: 30 |
| | | instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port} |
| | |
| | | ##注册地址 |
| | | #defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:9002/eureka/,http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:9003/eureka/ |
| | | #defaultZone: http://${eureka.instance.hostname}:9002/eureka/,http://${eureka.instance.hostname}:9003/eureka/ |
| | | defaultZone: http://172.17.97.143:9001/eureka/,http://192.168.1.202:9001/eureka/ |
| | | # defaultZone: http://172.17.97.143:9001/eureka/,http://192.168.2.240:9001/eureka/ |
| | | defaultZone: http://127.0.0.1:9001/eureka/ |
| | | ####因为自己是注册中心,是否需要将自己注册给自己的注册中心(集群的时候是需要是为true) |
| | | register-with-eureka: false |
| | | ###因为自己是注册中心, 不需要去检索服务信息 |
| | |
| | | <artifactId>spring-boot-configuration-processor</artifactId> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | <!--网关限流模块--> |
| | | <dependency> |
| | | <groupId>com.marcosbarbero.cloud</groupId> |
| | | <artifactId>spring-cloud-zuul-ratelimit</artifactId> |
| | | </dependency> |
| | | <!--web 模块--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.security.core.Authentication; |
| | |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | |
| | | public Mono<Void> onAuthenticationSuccess(WebFilterExchange webFilterExchange, Authentication authentication) { |
| | | MultiValueMap<String, String> headerValues = new LinkedMultiValueMap(4); |
| | | Object principal = authentication.getPrincipal(); |
| | | String tenantId=""; |
| | | //客户端模式只返回一个clientId |
| | | if (principal instanceof SysUser) { |
| | | SysUser user = (SysUser)authentication.getPrincipal(); |
| | | headerValues.add(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId())); |
| | | headerValues.add(SecurityConstants.USER_HEADER, user.getUsername()); |
| | | |
| | | List<SysOrganization> organizations = (List<SysOrganization>)user.getOrganizations(); |
| | | //如果有组织架构 |
| | | if(organizations.size()==2){ |
| | | headerValues.add(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId())); |
| | | headerValues.add(SecurityConstants.USER_ORG_NAME_HEADER,organizations.get(0).getOrgName()); |
| | | headerValues.add(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(1).getId())); |
| | | headerValues.add(SecurityConstants.USER_DEP_NAME_HEADER,organizations.get(1).getOrgName()); |
| | | tenantId=String.valueOf(organizations.get(0).getId()); |
| | | } |
| | | } |
| | | OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication; |
| | | String clientId = oauth2Authentication.getOAuth2Request().getClientId(); |
| | | String tenantId=""; |
| | | //保存租户id,租户id根据业务尽进行替换 |
| | | switch (clientId){ |
| | | case "hospital": |
| | | tenantId="1"; |
| | | tenantId=tenantId; |
| | | break; |
| | | case "webApp": |
| | | tenantId="webApp"; |
| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.common.utils.AddrUtil; |
| | | import com.netflix.zuul.ZuulFilter; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | |
| | | import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER; |
| | | |
| | |
| | | SysUser user = (SysUser)authentication.getPrincipal(); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername()); |
| | | tenantId=String.valueOf(user.getId()); |
| | | List<SysOrganization> organizations = (List<SysOrganization>)user.getOrganizations(); |
| | | //如果有组织架构 |
| | | if(organizations.size()==2){ |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER,organizations.get(0).getOrgName()); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(organizations.get(1).getId())); |
| | | ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,organizations.get(1).getOrgName()); |
| | | tenantId=String.valueOf(organizations.get(0).getId()); |
| | | } |
| | | // log.error("用户ID写入Header成功,用户ID为:"+String.valueOf(user.getId())); |
| | | } |
| | | |
| | |
| | | uri-encoding: UTF-8 |
| | | max-threads: 1000 |
| | | min-spare-threads: 30 |
| | | port: 8887 |
| | | port: 8888 |
| | | |
| | | |
| | | eureka: |
| | |
| | | var my_api_server_url = 'http://zuul.kidgrow.com/'; |
| | | // var my_api_server_url = 'http://zuul.kidgrow.com/'; |
| | | // var my_api_server_url = 'http://192.168.2.240:8888/'; |
| | | // var my_api_server_url = 'http://127.0.0.1:8888/'; |
| | | var my_api_server_url = 'http://127.0.0.1:8888/'; |
| | | |
| | |
| | | <javax.activatio.version>1.1.1</javax.activatio.version> |
| | | <jaxb-runtime.version>2.3.0</jaxb-runtime.version> |
| | | <jaxb-impl.version>2.3.0</jaxb-impl.version> |
| | | <zuul-ratelimit.version>2.0.4.RELEASE</zuul-ratelimit.version> |
| | | <sonar.exclusions>kidgrow-jobs/**/* kidgrow-web/**/*</sonar.exclusions> |
| | | <docker.baseImage>openjdk:8-jre-alpine</docker.baseImage> |
| | | <docker.volumes>/tmp</docker.volumes> |
| | |
| | | <artifactId>mybatis-plus</artifactId> |
| | | <version>${mybatis-plus-boot-starter.version}</version> |
| | | </dependency> |
| | | <!--网关限流插件--> |
| | | <dependency> |
| | | <groupId>com.marcosbarbero.cloud</groupId> |
| | | <artifactId>spring-cloud-zuul-ratelimit</artifactId> |
| | | <version>${zuul-ratelimit.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>p6spy</groupId> |
| | | <artifactId>p6spy</artifactId> |