瀏覽代碼

代码优化

黄远 5 年之前
父節點
當前提交
d97c0e1243

+ 3 - 3
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/Menu.java

@@ -4,13 +4,13 @@ import lombok.Data;
 
 /**
  * 实体类 - 表:menu
- * @since 2019-12-01 15:46:21
+ * @since 2019-12-01 16:52:41
  */
 @Data
 public class Menu {
-	private Integer id;
+	private Long id;
 
-	private Integer parentId;
+	private Long parentId;
 
 	private String name;
 

+ 2 - 2
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/Role.java

@@ -6,11 +6,11 @@ import java.util.Date;
 
 /**
  * 实体类 - 表:role
- * @since 2019-12-01 15:46:21
+ * @since 2019-12-01 16:52:41
  */
 @Data
 public class Role {
-	private Integer id;
+	private Long id;
 
 	private String name;
 

+ 4 - 4
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/RoleMenu.java

@@ -4,15 +4,15 @@ import lombok.Data;
 
 /**
  * 实体类 - 表:role_menu
- * @since 2019-12-01 15:46:21
+ * @since 2019-12-01 16:52:41
  */
 @Data
 public class RoleMenu {
-	private Integer id;
+	private Long id;
 
-	private Integer roleId;
+	private Long roleId;
 
-	private Integer menuId;
+	private Long menuId;
 
 	private String operate;
 

+ 4 - 4
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/UserRole.java

@@ -4,13 +4,13 @@ import lombok.Data;
 
 /**
  * 实体类 - 表:user_role
- * @since 2019-12-01 15:46:21
+ * @since 2019-12-01 16:52:41
  */
 @Data
 public class UserRole {
-	private Integer id;
+	private Long id;
 
-	private Integer userId;
+	private Long userId;
 
-	private Integer roleId;
+	private Long roleId;
 }

+ 28 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/model/RoleRequest.java

@@ -1,9 +1,37 @@
 package cn.com.ty.lift.system.entity.model;
 
+import lombok.Data;
+
+import java.util.Date;
+
 /**
  * @author huangyuan
  * @date 2019-12-01
  * @description 角色请求类
  */
+@Data
 public class RoleRequest {
+    private Integer id;//角色id
+
+    private String name;
+
+    private String code;
+
+    private String description;
+
+    private Long companyId;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    private Date deleteTime;
+
+    private Date createUserId;
+
+    private Date updateUserId;
+
+    private Date deleteUserId;
+
+    private Integer deleteFlag;
 }

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/model/UserRequest.java

@@ -9,7 +9,7 @@ import lombok.Data;
  */
 @Data
 public class UserRequest {
-    private String userId;//用户id
+    private Long userId;//用户id
     private String mobile;//手机号
     private String password;//密码
     private String name;//用户真实姓名

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/entity/model/UserResponse.java

@@ -9,7 +9,7 @@ import lombok.Data;
  */
 @Data
 public class UserResponse {
-    private String userId;//用户id
+    private int userId;//用户id
     private String mobile;//用户手机号
     private String name;//用户昵称
 }

+ 10 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/mapper/RoleMapper.java

@@ -1,7 +1,9 @@
 package cn.com.ty.lift.system.mapper;
 
 import cn.com.ty.lift.system.entity.Role;
+import cn.com.ty.lift.system.entity.model.RoleRequest;
 import cn.com.xwy.boot.mybatis.MyBatisMapper;
+import cn.com.xwy.boot.web.dto.RestResponse;
 
 /**
  * MyBatis Mapper 接口 - 表:role
@@ -20,4 +22,12 @@ public interface RoleMapper {
 	int updateByPrimaryKeySelective(Role record);
 
 	int updateByPrimaryKey(Role record);
+
+	/**
+	 * @description 获取角色列表
+	 * @date 2019/11/27 10:03 AM
+	 * @param roleRequest 角色请求类
+	 * @return
+	 */
+    RestResponse getByRoleRequest(RoleRequest roleRequest);
 }

+ 19 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/controller/RoleController.java

@@ -1,5 +1,9 @@
 package cn.com.ty.lift.system.user.controller;
 
+import cn.com.ty.lift.system.entity.model.RoleRequest;
+import cn.com.ty.lift.system.user.service.IRoleService;
+import cn.com.xwy.boot.web.dto.RestResponse;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -11,4 +15,19 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/role")
 public class RoleController {
+
+    @Autowired
+    private IRoleService roleService;
+
+    /**
+     * @description 获取角色列表
+     * @date 2019/11/27 10:03 AM
+     * @param roleRequest 角色请求类
+     * @return
+     */
+    @RequestMapping("/list")
+    public RestResponse list(RoleRequest roleRequest){
+        return roleService.list(roleRequest);
+    }
+
 }

+ 9 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/IRoleService.java

@@ -1,4 +1,13 @@
 package cn.com.ty.lift.system.user.service;
 
+import cn.com.ty.lift.system.entity.model.RoleRequest;
+import cn.com.xwy.boot.web.dto.RestResponse;
+
+/**
+ * @author huangyuan
+ * @date 2019-12-01
+ * @description 角色接口
+ */
 public interface IRoleService {
+    RestResponse list(RoleRequest roleRequest);
 }

+ 12 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/RoleService.java

@@ -1,6 +1,10 @@
 package cn.com.ty.lift.system.user.service.impl;
 
+import cn.com.ty.lift.system.entity.model.RoleRequest;
+import cn.com.ty.lift.system.mapper.RoleMapper;
 import cn.com.ty.lift.system.user.service.IRoleService;
+import cn.com.xwy.boot.web.dto.RestResponse;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -10,4 +14,12 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class RoleService implements IRoleService {
+
+    @Autowired
+    private RoleMapper roleMapper;
+
+    @Override
+    public RestResponse list(RoleRequest roleRequest) {
+        return roleMapper.getByRoleRequest(roleRequest);
+    }
 }

+ 3 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/UserService.java

@@ -50,16 +50,19 @@ public class UserService implements IUserService {
     }
 
     @Override
+    @Transactional
     public RestResponse addUser(UserRequest userRequest) {
         return null;
     }
 
     @Override
+    @Transactional
     public RestResponse updateUser(UserRequest userRequest) {
         return null;
     }
 
     @Override
+    @Transactional
     public RestResponse deleteUser(UserRequest userRequest) {
         return null;
     }

+ 13 - 13
lift-system-service/src/main/resources/mapper/MenuMapper.xml

@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ty.lift.system.mapper.MenuMapper" >
 	<resultMap id="BaseResultMap" type="cn.com.ty.lift.system.entity.Menu" >
-		<id column="id" property="id" jdbcType="INTEGER" />
-		<result column="parent_id" property="parentId" jdbcType="INTEGER" />
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="parent_id" property="parentId" jdbcType="BIGINT" />
 		<result column="name" property="name" jdbcType="VARCHAR" />
 		<result column="code" property="code" jdbcType="VARCHAR" />
 		<result column="type" property="type" jdbcType="VARCHAR" />
@@ -14,23 +14,23 @@
 		id, parent_id, name, code, type, description
 	</sql>
 
-	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
 		select 
 		<include refid="Base_Column_List" />
 		from menu
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</select>
 
-	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
 		delete from menu
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</delete>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.system.entity.Menu" >
 		insert into menu (id, parent_id, name, 
 			code, type, description
 			)
-		values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
+		values (#{id,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, 
 			#{code,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}
 			)
 	</insert>
@@ -59,10 +59,10 @@
 		</trim>
 		<trim prefix="values (" suffix=")" suffixOverrides="," >
 			<if test="id != null" >
-				#{id,jdbcType=INTEGER},
+				#{id,jdbcType=BIGINT},
 			</if>
 			<if test="parentId != null" >
-				#{parentId,jdbcType=INTEGER},
+				#{parentId,jdbcType=BIGINT},
 			</if>
 			<if test="name != null" >
 				#{name,jdbcType=VARCHAR},
@@ -83,7 +83,7 @@
 		update menu
 		<set >
 			<if test="parentId != null" >
-				parent_id = #{parentId,jdbcType=INTEGER},
+				parent_id = #{parentId,jdbcType=BIGINT},
 			</if>
 			<if test="name != null" >
 				name = #{name,jdbcType=VARCHAR},
@@ -98,17 +98,17 @@
 				description = #{description,jdbcType=VARCHAR},
 			</if>
 		</set>
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.system.entity.Menu" >
 		update menu
-		set parent_id = #{parentId,jdbcType=INTEGER},
+		set parent_id = #{parentId,jdbcType=BIGINT},
 			name = #{name,jdbcType=VARCHAR},
 			code = #{code,jdbcType=VARCHAR},
 			type = #{type,jdbcType=VARCHAR},
 			description = #{description,jdbcType=VARCHAR}
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 </mapper>

+ 19 - 9
lift-system-service/src/main/resources/mapper/RoleMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ty.lift.system.mapper.RoleMapper" >
 	<resultMap id="BaseResultMap" type="cn.com.ty.lift.system.entity.Role" >
-		<id column="id" property="id" jdbcType="INTEGER" />
+		<id column="id" property="id" jdbcType="BIGINT" />
 		<result column="name" property="name" jdbcType="VARCHAR" />
 		<result column="code" property="code" jdbcType="VARCHAR" />
 		<result column="description" property="description" jdbcType="VARCHAR" />
@@ -21,16 +21,16 @@
 		update_user_id, delete_user_id, delete_flag
 	</sql>
 
-	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
 		select 
 		<include refid="Base_Column_List" />
 		from role
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</select>
 
-	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
 		delete from role
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</delete>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.system.entity.Role" >
@@ -39,7 +39,7 @@
 			update_time, delete_time, create_user_id, 
 			update_user_id, delete_user_id, delete_flag
 			)
-		values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
+		values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
 			#{description,jdbcType=VARCHAR}, #{companyId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
 			#{updateTime,jdbcType=TIMESTAMP}, #{deleteTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=TIMESTAMP}, 
 			#{updateUserId,jdbcType=TIMESTAMP}, #{deleteUserId,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=INTEGER}
@@ -88,7 +88,7 @@
 		</trim>
 		<trim prefix="values (" suffix=")" suffixOverrides="," >
 			<if test="id != null" >
-				#{id,jdbcType=INTEGER},
+				#{id,jdbcType=BIGINT},
 			</if>
 			<if test="name != null" >
 				#{name,jdbcType=VARCHAR},
@@ -163,7 +163,7 @@
 				delete_flag = #{deleteFlag,jdbcType=INTEGER},
 			</if>
 		</set>
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.system.entity.Role" >
@@ -179,7 +179,17 @@
 			update_user_id = #{updateUserId,jdbcType=TIMESTAMP},
 			delete_user_id = #{deleteUserId,jdbcType=TIMESTAMP},
 			delete_flag = #{deleteFlag,jdbcType=INTEGER}
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
+	<!-- 通过角色请求对象获取角色信息 -->
+	<select id="getByRoleRequest" parameterType="cn.com.ty.lift.system.entity.model.RoleRequest" resultType="java.util.ArrayList">
+		select
+		<include refid="Base_Column_List"></include>
+		where 1 = 1
+		<if test="name != null">
+			and name like concat('%',#{name},'%')
+		</if>
+	</select>
+
 </mapper>

+ 17 - 17
lift-system-service/src/main/resources/mapper/RoleMenuMapper.xml

@@ -2,9 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ty.lift.system.mapper.RoleMenuMapper" >
 	<resultMap id="BaseResultMap" type="cn.com.ty.lift.system.entity.RoleMenu" >
-		<id column="id" property="id" jdbcType="INTEGER" />
-		<result column="role_id" property="roleId" jdbcType="INTEGER" />
-		<result column="menu_id" property="menuId" jdbcType="INTEGER" />
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="role_id" property="roleId" jdbcType="BIGINT" />
+		<result column="menu_id" property="menuId" jdbcType="BIGINT" />
 		<result column="operate" property="operate" jdbcType="VARCHAR" />
 		<result column="description" property="description" jdbcType="VARCHAR" />
 	</resultMap>
@@ -13,22 +13,22 @@
 		id, role_id, menu_id, operate, description
 	</sql>
 
-	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
 		select 
 		<include refid="Base_Column_List" />
 		from role_menu
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</select>
 
-	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
 		delete from role_menu
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</delete>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.system.entity.RoleMenu" >
 		insert into role_menu (id, role_id, menu_id, 
 			operate, description)
-		values (#{id,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}, #{menuId,jdbcType=INTEGER}, 
+		values (#{id,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT}, #{menuId,jdbcType=BIGINT}, 
 			#{operate,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR})
 	</insert>
 
@@ -53,13 +53,13 @@
 		</trim>
 		<trim prefix="values (" suffix=")" suffixOverrides="," >
 			<if test="id != null" >
-				#{id,jdbcType=INTEGER},
+				#{id,jdbcType=BIGINT},
 			</if>
 			<if test="roleId != null" >
-				#{roleId,jdbcType=INTEGER},
+				#{roleId,jdbcType=BIGINT},
 			</if>
 			<if test="menuId != null" >
-				#{menuId,jdbcType=INTEGER},
+				#{menuId,jdbcType=BIGINT},
 			</if>
 			<if test="operate != null" >
 				#{operate,jdbcType=VARCHAR},
@@ -74,10 +74,10 @@
 		update role_menu
 		<set >
 			<if test="roleId != null" >
-				role_id = #{roleId,jdbcType=INTEGER},
+				role_id = #{roleId,jdbcType=BIGINT},
 			</if>
 			<if test="menuId != null" >
-				menu_id = #{menuId,jdbcType=INTEGER},
+				menu_id = #{menuId,jdbcType=BIGINT},
 			</if>
 			<if test="operate != null" >
 				operate = #{operate,jdbcType=VARCHAR},
@@ -86,16 +86,16 @@
 				description = #{description,jdbcType=VARCHAR},
 			</if>
 		</set>
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.system.entity.RoleMenu" >
 		update role_menu
-		set role_id = #{roleId,jdbcType=INTEGER},
-			menu_id = #{menuId,jdbcType=INTEGER},
+		set role_id = #{roleId,jdbcType=BIGINT},
+			menu_id = #{menuId,jdbcType=BIGINT},
 			operate = #{operate,jdbcType=VARCHAR},
 			description = #{description,jdbcType=VARCHAR}
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 </mapper>

+ 17 - 17
lift-system-service/src/main/resources/mapper/UserRoleMapper.xml

@@ -2,31 +2,31 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ty.lift.system.mapper.UserRoleMapper" >
 	<resultMap id="BaseResultMap" type="cn.com.ty.lift.system.entity.UserRole" >
-		<id column="id" property="id" jdbcType="INTEGER" />
-		<result column="user_id" property="userId" jdbcType="INTEGER" />
-		<result column="role_id" property="roleId" jdbcType="INTEGER" />
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="user_id" property="userId" jdbcType="BIGINT" />
+		<result column="role_id" property="roleId" jdbcType="BIGINT" />
 	</resultMap>
 
 	<sql id="Base_Column_List" >
 		id, user_id, role_id
 	</sql>
 
-	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
 		select 
 		<include refid="Base_Column_List" />
 		from user_role
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</select>
 
-	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
 		delete from user_role
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</delete>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.system.entity.UserRole" >
 		insert into user_role (id, user_id, role_id
 			)
-		values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
+		values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT}
 			)
 	</insert>
 
@@ -45,13 +45,13 @@
 		</trim>
 		<trim prefix="values (" suffix=")" suffixOverrides="," >
 			<if test="id != null" >
-				#{id,jdbcType=INTEGER},
+				#{id,jdbcType=BIGINT},
 			</if>
 			<if test="userId != null" >
-				#{userId,jdbcType=INTEGER},
+				#{userId,jdbcType=BIGINT},
 			</if>
 			<if test="roleId != null" >
-				#{roleId,jdbcType=INTEGER},
+				#{roleId,jdbcType=BIGINT},
 			</if>
 		</trim>
 	</insert>
@@ -60,20 +60,20 @@
 		update user_role
 		<set >
 			<if test="userId != null" >
-				user_id = #{userId,jdbcType=INTEGER},
+				user_id = #{userId,jdbcType=BIGINT},
 			</if>
 			<if test="roleId != null" >
-				role_id = #{roleId,jdbcType=INTEGER},
+				role_id = #{roleId,jdbcType=BIGINT},
 			</if>
 		</set>
-		where id = #{id,jdbcType=INTEGER}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.system.entity.UserRole" >
 		update user_role
-		set user_id = #{userId,jdbcType=INTEGER},
-			role_id = #{roleId,jdbcType=INTEGER}
-		where id = #{id,jdbcType=INTEGER}
+		set user_id = #{userId,jdbcType=BIGINT},
+			role_id = #{roleId,jdbcType=BIGINT}
+		where id = #{id,jdbcType=BIGINT}
 	</update>
 
 </mapper>