提交 70d266f5 编写于 作者: M ManongJu

重构

上级 ee117dea
@echo on
mvn clean -e -U package -Dmaven.test.skip=true
\ No newline at end of file
......@@ -44,8 +44,6 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
@Autowired
private RedisConnectionFactory redisConnectionFactory;
@Autowired
RedisTemplate redisTemplate;
@Bean
RedisTokenStore redisTokenStore(){
......
@echo on
mvn clean -e -U package -Dmaven.test.skip=true
\ No newline at end of file
......@@ -3,9 +3,11 @@ package com.microservice.skeleton.upms;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import tk.mybatis.spring.annotation.MapperScan;
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan(basePackages = {"com.microservice.skeleton.upms.mapper"})
public class UpmsApplication {
public static void main(String[] args) {
......
package com.microservice.skeleton.upms.controller;
import com.microservice.skeleton.common.vo.Result;
import com.microservice.skeleton.upms.entity.RcMenu;
import com.microservice.skeleton.upms.entity.SysMenu;
import com.microservice.skeleton.upms.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,7 +27,7 @@ public class PermissionController {
private PermissionService permissionService;
@GetMapping("getRolePermission/{roleId}")
public Result getRolePermission(@PathVariable("roleId") Integer roleId){
List<RcMenu> menuList = permissionService.getPermissionsByRoleId(roleId);
List<SysMenu> menuList = permissionService.getPermissionsByRoleId(roleId);
return Result.ok().setData(menuList);
}
......
package com.microservice.skeleton.upms.controller;
import com.microservice.skeleton.common.vo.Result;
import com.microservice.skeleton.upms.entity.RcRole;
import com.microservice.skeleton.upms.entity.SysRole;
import com.microservice.skeleton.upms.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -25,7 +25,7 @@ public class RoleController {
private RoleService roleService;
@GetMapping("getRoleByUserId/{userId}")
public Result getRoleByUserId(@PathVariable("userId") Integer userId){
List<RcRole> roleList = roleService.getRoleByUserId(userId);
List<SysRole> roleList = roleService.getRoleByUserId(userId);
return Result.ok().setData(roleList);
}
......
package com.microservice.skeleton.upms.controller;
import com.microservice.skeleton.common.vo.Result;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.entity.SysUser;
import com.microservice.skeleton.upms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -24,7 +24,7 @@ public class UserController {
@GetMapping("findByUsername/{username}")
public Result findByUsername(@PathVariable("username") String username){
RcUser user = userService.findByUsername(username);
SysUser user = userService.findByUsername(username);
if (user == null){
return Result.failure(100,"用户不存在");
}
......
......@@ -3,8 +3,8 @@ package com.microservice.skeleton.upms.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "rc_menu")
public class RcMenu {
@Table(name = "sys_menu")
public class SysMenu {
@Id
@GeneratedValue(generator = "JDBC")
private String id;
......
......@@ -3,8 +3,8 @@ package com.microservice.skeleton.upms.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "rc_role")
public class RcRole {
@Table(name = "sys_role")
public class SysRole {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
......
......@@ -3,8 +3,8 @@ package com.microservice.skeleton.upms.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "rc_user")
public class RcUser {
@Table(name = "sys_user")
public class SysUser {
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
......
package com.microservice.skeleton.upms.mapper;
import com.microservice.skeleton.upms.entity.RcRole;
import com.microservice.skeleton.upms.entity.SysMenu;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
@org.apache.ibatis.annotations.Mapper
public interface RcRoleMapper extends Mapper<RcRole> {
@Select(value = "select role.* from rc_role role,rc_user_role ur where role.id=ur.role_id and ur.user_id=#{userId}")
List<RcRole> getRoleByUserId(Integer userId);
public interface SysMenuMapper extends Mapper<SysMenu> {
@Select(value = "select menu.* from sys_menu menu,sys_privilege p where menu.id=p.menu_id and p.role_id=#{roleId}")
List<SysMenu> getPermissionsByRoleId(Integer roleId);
}
\ No newline at end of file
package com.microservice.skeleton.upms.mapper;
import com.microservice.skeleton.upms.entity.RcMenu;
import com.microservice.skeleton.upms.entity.SysRole;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
@org.apache.ibatis.annotations.Mapper
public interface RcMenuMapper extends Mapper<RcMenu> {
@Select(value = "select menu.* from rc_menu menu,rc_privilege p where menu.id=p.menu_id and p.role_id=#{roleId}")
List<RcMenu> getPermissionsByRoleId(Integer roleId);
public interface SysRoleMapper extends Mapper<SysRole> {
@Select(value = "select role.* from sys_role role,sys_user_role ur where role.id=ur.role_id and ur.user_id=#{userId}")
List<SysRole> getRoleByUserId(Integer userId);
}
\ No newline at end of file
package com.microservice.skeleton.upms.mapper;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.entity.SysUser;
import tk.mybatis.mapper.common.Mapper;
@org.apache.ibatis.annotations.Mapper
public interface RcUserMapper extends Mapper<RcUser> {
public interface SysUserMapper extends Mapper<SysUser> {
}
\ No newline at end of file
package com.microservice.skeleton.upms.service;
import com.microservice.skeleton.upms.entity.RcMenu;
import com.microservice.skeleton.upms.entity.SysMenu;
import java.util.List;
......@@ -12,5 +12,5 @@ import java.util.List;
* Time: 10:12
*/
public interface PermissionService {
List<RcMenu> getPermissionsByRoleId(Integer roleId);
List<SysMenu> getPermissionsByRoleId(Integer roleId);
}
package com.microservice.skeleton.upms.service;
import com.microservice.skeleton.upms.entity.RcRole;
import com.microservice.skeleton.upms.entity.SysRole;
import java.util.List;
......@@ -12,5 +12,5 @@ import java.util.List;
* Time: 20:26
*/
public interface RoleService {
List<RcRole> getRoleByUserId(Integer userId);
List<SysRole> getRoleByUserId(Integer userId);
}
package com.microservice.skeleton.upms.service;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.entity.SysUser;
/**
* Created with IntelliJ IDEA.
......@@ -10,5 +10,5 @@ import com.microservice.skeleton.upms.entity.RcUser;
* Time: 9:48
*/
public interface UserService {
RcUser findByUsername(String username);
SysUser findByUsername(String username);
}
package com.microservice.skeleton.upms.service.impl;
import com.microservice.skeleton.upms.entity.RcMenu;
import com.microservice.skeleton.upms.mapper.RcMenuMapper;
import com.microservice.skeleton.upms.entity.SysMenu;
import com.microservice.skeleton.upms.mapper.SysMenuMapper;
import com.microservice.skeleton.upms.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -18,9 +18,9 @@ import java.util.List;
@Service
public class PermissionServiceImpl implements PermissionService {
@Autowired
private RcMenuMapper menuMapper;
private SysMenuMapper menuMapper;
@Override
public List<RcMenu> getPermissionsByRoleId(Integer roleId) {
public List<SysMenu> getPermissionsByRoleId(Integer roleId) {
return menuMapper.getPermissionsByRoleId(roleId);
}
}
package com.microservice.skeleton.upms.service.impl;
import com.microservice.skeleton.upms.entity.RcRole;
import com.microservice.skeleton.upms.mapper.RcRoleMapper;
import com.microservice.skeleton.upms.entity.SysRole;
import com.microservice.skeleton.upms.mapper.SysRoleMapper;
import com.microservice.skeleton.upms.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -19,10 +19,10 @@ import java.util.List;
public class RoleServiceImpl implements RoleService {
@Autowired
private RcRoleMapper roleMapper;
private SysRoleMapper roleMapper;
@Override
public List<RcRole> getRoleByUserId(Integer userId) {
public List<SysRole> getRoleByUserId(Integer userId) {
return roleMapper.getRoleByUserId(userId);
}
}
package com.microservice.skeleton.upms.service.impl;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.mapper.RcUserMapper;
import com.microservice.skeleton.upms.entity.SysUser;
import com.microservice.skeleton.upms.mapper.SysUserMapper;
import com.microservice.skeleton.upms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -19,11 +19,11 @@ import tk.mybatis.mapper.util.Sqls;
public class UserServiceImpl implements UserService {
@Autowired
private RcUserMapper userMapper;
private SysUserMapper userMapper;
@Override
public RcUser findByUsername(String username) {
Example example = Example.builder(RcUser.class)
public SysUser findByUsername(String username) {
Example example = Example.builder(SysUser.class)
.where(Sqls.custom().andEqualTo("username",username))
.build();
return userMapper.selectOneByExample(example);
......
<?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.microservice.skeleton.upms.mapper.RcMenuMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.RcMenu">
<mapper namespace="com.microservice.skeleton.upms.mapper.SysMenuMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.SysMenu">
<!--
WARNING - @mbg.generated
-->
......
<?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.microservice.skeleton.upms.mapper.RcRoleMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.RcRole">
<mapper namespace="com.microservice.skeleton.upms.mapper.SysRoleMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.SysRole">
<!--
WARNING - @mbg.generated
-->
......
<?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.microservice.skeleton.upms.mapper.RcUserMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.RcUser">
<mapper namespace="com.microservice.skeleton.upms.mapper.SysUserMapper">
<resultMap id="BaseResultMap" type="com.microservice.skeleton.upms.entity.SysUser">
<!--
WARNING - @mbg.generated
-->
......@@ -19,9 +19,8 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap id="userVoMap" type="com.microservice.skeleton.common.vo.UserVo">
<id column="id" jdbcType="INTEGER" property="userId" />
<id column="id" jdbcType="INTEGER" property="id" />
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="salt" jdbcType="VARCHAR" property="salt" />
......
package com.microservice.skeleton.upms;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.entity.SysUser;
import com.microservice.skeleton.upms.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -26,7 +26,7 @@ public class GeneratorTests {
@Test
public void contextLoads() {
RcUser user = userService.findByUsername("admin");
SysUser user = userService.findByUsername("admin");
System.out.println(user);
}
@Test
......
......@@ -47,14 +47,14 @@
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"/>
<javaClientGenerator targetPackage="com.microservice.skeleton.upms.mapper" targetProject="src/main/java"
type="XMLMAPPER"/>
<!--<table tableName="rc_user">-->
<!--<generatedKey column="id" sqlStatement="JDBC"/>-->
<!--</table>-->
<!--<table tableName="rc_role"-->
<!--&gt;-->
<!--<generatedKey column="id" sqlStatement="JDBC"/>-->
<!--</table>-->
<table tableName="rc_menu">
<table tableName="sys_user">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table tableName="sys_role"
>
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table tableName="sys_menu">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
</context>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册