Commit f83b40ba authored by lijun's avatar lijun

将mysql转化成oracle数据库2

parent d6495c28
10.10.10.112 smart-register
10.10.10.112 smart-redis
10.10.10.112 smart-mq
127.0.0.1 smart-gateway
10.10.10.99 smart-oracle
\ No newline at end of file
...@@ -77,25 +77,25 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In ...@@ -77,25 +77,25 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
.collect(Collectors.toList()); .collect(Collectors.toList());
Entity query = Db.use(dataSource) Entity query = Db.use(dataSource)
.query("SELECT * FROM sys_role where role_id IN (" + CollUtil.join(roleIdList, ",") + ")") .query("SELECT * FROM SYS_ROLE where ROLE_ID IN (" + CollUtil.join(roleIdList, ",") + ")")
.stream().min(Comparator.comparingInt(o -> o.getInt("ds_type"))).get(); .stream().min(Comparator.comparingInt(o -> o.getInt("DS_TYPE"))).get();
Integer dsType = query.getInt("ds_type"); Integer dsType = query.getInt("DS_TYPE");
// 查询全部 // 查询全部
if (DataScopeTypeEnum.ALL.getType() == dsType) { if (DataScopeTypeEnum.ALL.getType() == dsType) {
return invocation.proceed(); return invocation.proceed();
} }
// 自定义 // 自定义
if (DataScopeTypeEnum.CUSTOM.getType() == dsType) { if (DataScopeTypeEnum.CUSTOM.getType() == dsType) {
String dsScope = query.getStr("ds_scope"); String dsScope = query.getStr("DS_SCOPE");
deptIds.addAll(Arrays.stream(dsScope.split(StrUtil.COMMA)) deptIds.addAll(Arrays.stream(dsScope.split(StrUtil.COMMA))
.map(Integer::parseInt).collect(Collectors.toList())); .map(Integer::parseInt).collect(Collectors.toList()));
} }
// 查询本级及其下级 // 查询本级及其下级
if (DataScopeTypeEnum.OWN_CHILD_LEVEL.getType() == dsType) { if (DataScopeTypeEnum.OWN_CHILD_LEVEL.getType() == dsType) {
List<Integer> deptIdList = Db.use(dataSource) List<Integer> deptIdList = Db.use(dataSource)
.findBy("sys_dept_relation", "ancestor", user.getDeptId()) .findBy("SYS_DEPT_RELATION", "ANCESTOR", user.getDeptId())
.stream().map(entity -> entity.getInt("descendant")) .stream().map(entity -> entity.getInt("DESCENDANT"))
.collect(Collectors.toList()); .collect(Collectors.toList());
deptIds.addAll(deptIdList); deptIds.addAll(deptIdList);
} }
......
package com.smart.hospital.admin.api.feign; package com.smart.hospital.admin.api.feign;
import com.smart.hospital.common.core.constant.SecurityConstants; import com.smart.hospital.common.core.constant.SecurityConstants;
...@@ -25,7 +23,7 @@ public interface RemoteTenantService { ...@@ -25,7 +23,7 @@ public interface RemoteTenantService {
* @param from 内部标志 * @param from 内部标志
* @return * @return
*/ */
@GetMapping("/tenant/list") // @GetMapping("/tenant/list")
R<List<SysTenant>> list(@RequestHeader(SecurityConstants.FROM) String from); // R<List<SysTenant>> list(@RequestHeader(SecurityConstants.FROM) String from);
} }
...@@ -92,7 +92,7 @@ public class UserVO implements Serializable { ...@@ -92,7 +92,7 @@ public class UserVO implements Serializable {
* 租户ID * 租户ID
*/ */
@ApiModelProperty(value = "所属租户") @ApiModelProperty(value = "所属租户")
private Integer tenantId; private Integer hospitalId;
/** /**
* 部门名称 * 部门名称
*/ */
......
package com.smart.hospital.admin.controller.upms;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.hospital.common.core.constant.CacheConstants;
import com.smart.hospital.common.core.util.R;
import com.smart.hospital.common.log.annotation.SysLog;
import com.smart.hospital.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 租户管理
*
* @author giaogiao
* @date 2019-05-15 15:55:41
*/
@RestController
@AllArgsConstructor
@RequestMapping("/tenant")
@Api(value = "tenant", tags = "租户管理")
public class SysTenantController {
private final SysTenantService sysTenantService;
/**
* 分页查询
*
* @param page 分页对象
* @param sysTenant 租户
* @return
*/
@GetMapping("/page")
public R getSysTenantPage(Page page, SysTenant sysTenant) {
return R.ok(sysTenantService.page(page, Wrappers.query(sysTenant)));
}
/**
* 通过id查询租户
*
* @param id id
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
return R.ok(sysTenantService.getById(id));
}
/**
* 新增租户
*
* @param sysTenant 租户
* @return R
*/
@SysLog("新增租户")
@PostMapping
@PreAuthorize("@pms.hasPermission('admin_systenant_add')")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
public R save(@RequestBody SysTenant sysTenant) {
return R.ok(sysTenantService.saveTenant(sysTenant));
}
/**
* 修改租户
*
* @param sysTenant 租户
* @return R
*/
@SysLog("修改租户")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_systenant_edit')")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
public R updateById(@RequestBody SysTenant sysTenant) {
return R.ok(sysTenantService.updateById(sysTenant));
}
/**
* 通过id删除租户
*
* @param id id
* @return R
*/
@SysLog("删除租户")
@DeleteMapping("/{id}")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
@PreAuthorize("@pms.hasPermission('admin_systenant_del')")
public R removeById(@PathVariable Integer id) {
return R.ok(sysTenantService.removeById(id));
}
/**
* 查询全部有效的租户
*
* @return
*/
@Inner(value = false)
@GetMapping("/list")
@Cacheable(value = CacheConstants.TENANT_DETAILS)
public R list() {
return R.ok(sysTenantService.getNormal());
}
}
package com.smart.hospital.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 租户
*
* @author giaogiao
* @date 2019-05-15 15:55:41
*/
public interface SysTenantMapper extends BaseMapper<SysTenant> {
}
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="remarks" column="remarks"/> <result property="remarks" column="remarks"/>
<result property="delFlag" column="del_flag"/> <result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/> <result property="hospitalId" column="hospital_id"/>
</resultMap> </resultMap>
</mapper> </mapper>
...@@ -12,6 +12,6 @@ ...@@ -12,6 +12,6 @@
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="remarks" column="remarks"/> <result property="remarks" column="remarks"/>
<result property="delFlag" column="del_flag"/> <result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/> <result property="hospitalId" column="hospital_id"/>
</resultMap> </resultMap>
</mapper> </mapper>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<result column="lock_flag" property="lockFlag"/> <result column="lock_flag" property="lockFlag"/>
<result column="udel_flag" property="delFlag"/> <result column="udel_flag" property="delFlag"/>
<result column="deptId" property="deptId"/> <result column="deptId" property="deptId"/>
<result column="tenantId" property="tenantId"/> <result column="hospitalId" property="hospitalId"/>
<result column="deptName" property="deptName"/> <result column="deptName" property="deptName"/>
<collection property="roleList" ofType="com.smart.hospital.admin.api.entity.SysRole" <collection property="roleList" ofType="com.smart.hospital.admin.api.entity.SysRole"
select="com.smart.hospital.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id"> select="com.smart.hospital.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id">
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<result column="lock_flag" property="lockFlag"/> <result column="lock_flag" property="lockFlag"/>
<result column="udel_flag" property="delFlag"/> <result column="udel_flag" property="delFlag"/>
<result column="deptId" property="deptId"/> <result column="deptId" property="deptId"/>
<result column="tenantId" property="tenantId"/> <result column="hospitalId" property="hospitalId"/>
<result column="deptName" property="deptName"/> <result column="deptName" property="deptName"/>
<collection property="roleList" ofType="com.smart.hospital.admin.api.entity.SysRole"> <collection property="roleList" ofType="com.smart.hospital.admin.api.entity.SysRole">
<id column="role_id" property="roleId"/> <id column="role_id" property="roleId"/>
...@@ -51,21 +51,21 @@ ...@@ -51,21 +51,21 @@
</resultMap> </resultMap>
<sql id="userRoleSql"> <sql id="userRoleSql">
`user`.user_id, u.user_id,
`user`.username, u.username,
`user`.`password`, u.password,
`user`.salt, u.salt,
`user`.phone, u.phone,
`user`.avatar, u.avatar,
`user`.wx_openid, u.wx_openid,
`user`.qq_openid, u.qq_openid,
`user`.dept_id, u.dept_id,
`user`.create_time AS ucreate_time, u.create_time AS ucreate_time,
`user`.update_time AS uupdate_time, u.update_time AS uupdate_time,
`user`.del_flag AS udel_flag, u.del_flag AS udel_flag,
`user`.lock_flag AS lock_flag, u.lock_flag AS lock_flag,
`user`.dept_id AS deptId, u.dept_id AS deptId,
`user`.tenant_id AS tenantId, u.hospital_id AS hospitalId,
r.role_id, r.role_id,
r.role_name, r.role_name,
r.role_code, r.role_code,
...@@ -75,19 +75,19 @@ ...@@ -75,19 +75,19 @@
</sql> </sql>
<sql id="userRoleDeptSql"> <sql id="userRoleDeptSql">
`user`.user_id, u.user_id,
`user`.username, u.username,
`user`.`password`, u.password,
`user`.salt, u.salt,
`user`.phone, u.phone,
`user`.avatar, u.avatar,
`user`.wx_openid, u.wx_openid,
`user`.qq_openid, u.qq_openid,
`user`.create_time AS ucreate_time, u.create_time AS ucreate_time,
`user`.update_time AS uupdate_time, u.update_time AS uupdate_time,
`user`.del_flag AS udel_flag, u.del_flag AS udel_flag,
`user`.lock_flag AS lock_flag, u.lock_flag AS lock_flag,
`user`.tenant_id AS tenantId, u.hospital_id AS hospitalId,
r.role_id, r.role_id,
r.role_name, r.role_name,
r.role_code, r.role_code,
...@@ -96,59 +96,59 @@ ...@@ -96,59 +96,59 @@
r.update_time AS rupdate_time, r.update_time AS rupdate_time,
d.name AS deptName, d.name AS deptName,
d.dept_id AS deptId d.dept_id AS deptId
</sql> </sql>
<select id="getUserVoByUsername" resultMap="userVoResultMap"> <select id="getUserVoByUsername" resultMap="userVoResultMap">
SELECT SELECT
<include refid="userRoleSql"/> <include refid="userRoleSql"/>
FROM FROM
sys_user AS `user` sys_user u
LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
LEFT JOIN sys_role AS r ON r.role_id = ur.role_id LEFT JOIN sys_role r ON r.role_id = ur.role_id
WHERE `user`.username = #{username} WHERE u.username = #{username}
</select> </select>
<select id="getUserVoById" resultMap="userVoResultMap"> <select id="getUserVoById" resultMap="userVoResultMap">
SELECT SELECT
<include refid="userRoleDeptSql"/> <include refid="userRoleDeptSql"/>
FROM FROM
sys_user AS `user` sys_user u
LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
LEFT JOIN sys_role AS r ON r.role_id = ur.role_id LEFT JOIN sys_role r ON r.role_id = ur.role_id
LEFT JOIN sys_dept AS d ON d.dept_id = `user`.dept_id LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
WHERE WHERE
`user`.user_id = #{id} u.user_id = #{id}
</select> </select>
<select id="getUserVosPage" resultMap="baseResultMap"> <select id="getUserVosPage" resultMap="baseResultMap">
SELECT SELECT
`user`.user_id, u.user_id,
`user`.username, u.username,
`user`.`password`, u.password,
`user`.salt, u.salt,
`user`.phone, u.phone,
`user`.avatar, u.avatar,
`user`.wx_openid, u.wx_openid,
`user`.qq_openid, u.qq_openid,
`user`.dept_id AS deptId, u.dept_id AS deptId,
`user`.create_time AS ucreate_time, u.create_time AS ucreate_time,
`user`.update_time AS uupdate_time, u.update_time AS uupdate_time,
`user`.del_flag AS udel_flag, u.del_flag AS udel_flag,
`user`.lock_flag AS lock_flag, u.lock_flag AS lock_flag,
`user`.tenant_id AS tenantId, u.hospital_id AS hospitalId,
d.name AS deptName d.name AS deptName
FROM FROM
sys_user AS `user` sys_user u
LEFT JOIN sys_dept AS d ON d.dept_id = `user`.dept_id LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
<where> <where>
`user`.del_flag = '0' u.del_flag = '0'
<if test="query.username != null and query.username != ''"> <if test="query.username != null and query.username != ''">
AND `user`.username LIKE CONCAT('%',#{query.username},'%') AND u.username LIKE CONCAT('%',#{query.username},'%')
</if> </if>
<if test="query.deptId != null and query.deptId != ''"> <if test="query.deptId != null and query.deptId != ''">
AND `user`.dept_id = #{query.deptId} AND u.dept_id = #{query.deptId}
</if> </if>
</where> </where>
ORDER BY `user`.create_time DESC ORDER BY u.create_time DESC
</select> </select>
</mapper> </mapper>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment