Jelajahi Sumber

数据库测试

黄远 5 tahun lalu
induk
melakukan
9bfb4eb03d

+ 4 - 4
lift-portal-service/pom.xml

@@ -18,10 +18,10 @@
         </dependency>
 
         <!--单体开发时注释掉依赖-->
-        <dependency>
-            <groupId>cn.com.xwy</groupId>
-            <artifactId>xwy-cloud-dependencies</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>cn.com.xwy</groupId>-->
+<!--            <artifactId>xwy-cloud-dependencies</artifactId>-->
+<!--        </dependency>-->
 
     </dependencies>
 

+ 5 - 3
lift-portal-service/src/main/resources/application.yml

@@ -1,5 +1,7 @@
 server:
   port: 20225
+  tomcat:
+    basedir: /Users/huangyuan/application/tomcat/data/tomcat_temp
 
 spring:
   application:
@@ -7,9 +9,9 @@ spring:
   profiles:
     active: dev
   datasource:
-    url: jdbc:mysql://127.0.0.1:3306/portal?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
-    username: mysql
-    password: mysql
+    url: jdbc:mysql://132.232.206.88/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
+    username: root
+    password: ms.c88pocY/
 
 #自动添加createTime、isDelete 等字段
 xwy:

+ 2 - 2
lift-portal-service/src/main/resources/mapper/RoleMenuMapper.xml

@@ -1,9 +1,9 @@
 <?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="cn.com.ty.cn.com.ty.portal.dao.mapper.RoleMenuMapper">
+<mapper namespace="cn.com.ty.portal.dao.mapper.RoleMenuMapper">
 
 
-    <select id="queryMenuByRole" resultType="cn.com.ty.cn.com.ty.portal.service.model.RoleMenuModel">
+    <select id="queryMenuByRole" resultType="cn.com.ty.portal.service.model.RoleMenuModel">
         SELECT
             sr.role_code roleCode,
             sr.role_name roleName,

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/SystemApplication.java

@@ -12,7 +12,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
  */
 @Slf4j
 @EnableFeignClients
-@MapperScan("cn.com.ty.**.dao.mapper")
+@MapperScan("cn.com.ty.**.mapper")
 @SpringBootApplication(scanBasePackages = {"cn.com.ty.lift", "cn.com.xwy.boot"})
 public class SystemApplication {
 

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

@@ -1,6 +1,6 @@
 package cn.com.ty.lift.system.entity;
 
-import org.apache.ibatis.type.Alias;
+import lombok.Data;
 
 import java.math.BigDecimal;
 
@@ -8,7 +8,7 @@ import java.math.BigDecimal;
  * 实体类 - 表:user_info
  * @since 2019-11-25 18:01:00
  */
-@Alias("UserInfo")
+@Data
 public class UserInfo {
 	private Long userId;
 
@@ -42,131 +42,4 @@ public class UserInfo {
 
 	private String avatarUrl;
 
-	public Long getUserId() {
-		return userId;
-	}
-
-	public void setUserId(Long userId) {
-		this.userId = userId;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getMobile() {
-		return mobile;
-	}
-
-	public void setMobile(String mobile) {
-		this.mobile = mobile;
-	}
-
-	public Byte getGender() {
-		return gender;
-	}
-
-	public void setGender(Byte gender) {
-		this.gender = gender;
-	}
-
-	public Byte getAge() {
-		return age;
-	}
-
-	public void setAge(Byte age) {
-		this.age = age;
-	}
-
-	public String getRemarks() {
-		return remarks;
-	}
-
-	public void setRemarks(String remarks) {
-		this.remarks = remarks;
-	}
-
-	public String getSignature() {
-		return signature;
-	}
-
-	public void setSignature(String signature) {
-		this.signature = signature;
-	}
-
-	public Integer getServiceTotal() {
-		return serviceTotal;
-	}
-
-	public void setServiceTotal(Integer serviceTotal) {
-		this.serviceTotal = serviceTotal;
-	}
-
-	public Integer getSatisfactionTotal() {
-		return satisfactionTotal;
-	}
-
-	public void setSatisfactionTotal(Integer satisfactionTotal) {
-		this.satisfactionTotal = satisfactionTotal;
-	}
-
-	public Integer getLevel() {
-		return level;
-	}
-
-	public void setLevel(Integer level) {
-		this.level = level;
-	}
-
-	public Integer getMaintenanceTotal() {
-		return maintenanceTotal;
-	}
-
-	public void setMaintenanceTotal(Integer maintenanceTotal) {
-		this.maintenanceTotal = maintenanceTotal;
-	}
-
-	public Integer getEmergencyTotal() {
-		return emergencyTotal;
-	}
-
-	public void setEmergencyTotal(Integer emergencyTotal) {
-		this.emergencyTotal = emergencyTotal;
-	}
-
-	public Integer getLiftTotal() {
-		return liftTotal;
-	}
-
-	public void setLiftTotal(Integer liftTotal) {
-		this.liftTotal = liftTotal;
-	}
-
-	public BigDecimal getBalance() {
-		return balance;
-	}
-
-	public void setBalance(BigDecimal balance) {
-		this.balance = balance;
-	}
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	public String getAvatarUrl() {
-		return avatarUrl;
-	}
-
-	public void setAvatarUrl(String avatarUrl) {
-		this.avatarUrl = avatarUrl;
-	}
 }

+ 2 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/mapper/UserInfoMapper.java

@@ -1,11 +1,13 @@
 package cn.com.ty.lift.system.mapper;
 
 import cn.com.ty.lift.system.entity.UserInfo;
+import cn.com.xwy.boot.mybatis.MyBatisMapper;
 
 /**
  * MyBatis Mapper 接口 - 表:user_info
  * @since 2019-11-25 18:01:00
  */
+@MyBatisMapper
 public interface UserInfoMapper {
 	int deleteByPrimaryKey(Long userId);
 

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

@@ -1,11 +1,15 @@
 package cn.com.ty.lift.system.user.controller;
 
 import cn.com.ty.lift.system.entity.User;
+import cn.com.ty.lift.system.entity.UserInfo;
 import cn.com.ty.lift.system.user.service.impl.UserService;
+import cn.com.xwy.boot.web.dto.RestResponse;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
+
 @RestController
 @RequestMapping("/user")
 public class UserController {
@@ -27,4 +31,11 @@ public class UserController {
         return user;
     }
 
+    @PostMapping("/addUser")
+    @ResponseBody
+    public Object addUserInfo(UserInfo userInfo){
+        userService.saveUserInfo(userInfo);
+        return RestResponse.ok(UserInfo.class, "success");
+    }
+
 }

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

@@ -1,6 +1,7 @@
 package cn.com.ty.lift.system.user.service;
 
 import cn.com.ty.lift.system.entity.User;
+import cn.com.ty.lift.system.entity.UserInfo;
 
 /**
  * <h1>.</h1><BR>
@@ -16,4 +17,6 @@ public interface IUserService{
      *@return cn.com.ty.lift.system.entity.User
      **/
     User getUserById(String userId);
+
+    void saveUserInfo(UserInfo userInfo);
 }

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

@@ -1,7 +1,10 @@
 package cn.com.ty.lift.system.user.service.impl;
 
 import cn.com.ty.lift.system.entity.User;
+import cn.com.ty.lift.system.entity.UserInfo;
+import cn.com.ty.lift.system.mapper.UserInfoMapper;
 import cn.com.ty.lift.system.user.service.IUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -13,6 +16,9 @@ import org.springframework.transaction.annotation.Transactional;
 @Transactional
 public class UserService implements IUserService {
 
+    @Autowired
+    private UserInfoMapper userInfoMapper;
+
     public User getUserById(String userId) {
         User user = new User();
         user.setId(1L);
@@ -21,4 +27,9 @@ public class UserService implements IUserService {
         user.setPassword("123456");
         return user;
     }
+
+    @Override
+    public void saveUserInfo(UserInfo userInfo) {
+        userInfoMapper.insert(userInfo);
+    }
 }

+ 14 - 4
lift-system-service/src/main/resources/application.yml

@@ -1,5 +1,13 @@
 server:
   port: 20230
+  tomcat:
+    basedir: /Users/huangyuan/application/tomcat/data/tomcat_temp
+
+
+
+# mybatis-plus配置
+mybatis-plus:
+  mapper-locations: classpath*:/mapper/**Mapper.xml
 
 spring:
   application:
@@ -7,12 +15,14 @@ spring:
   profiles:
     active: dev
   datasource:
-    url: jdbc:mysql://127.0.0.1:3306/portal?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
-    username: mysql
-    password: mysql
+    url: jdbc:mysql://132.232.206.88/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
+    username: root
+    password: ms.c88pocY/
+
 
 #自动添加createTime、isDelete 等字段
 xwy:
   mybatis:
     audit:
-      enabled: true
+      enabled: true
+

+ 259 - 0
lift-system-service/src/main/resources/mapper/UserInfoMapper.xml

@@ -0,0 +1,259 @@
+<?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="cn.com.ty.lift.system.mapper.UserInfoMapper" >
+	<resultMap id="BaseResultMap" type="cn.com.ty.lift.system.entity.UserInfo" >
+		<id column="user_id" property="userId" jdbcType="BIGINT" />
+		<result column="name" property="name" jdbcType="VARCHAR" />
+		<result column="mobile" property="mobile" jdbcType="CHAR" />
+		<result column="gender" property="gender" jdbcType="TINYINT" />
+		<result column="age" property="age" jdbcType="TINYINT" />
+		<result column="remarks" property="remarks" jdbcType="VARCHAR" />
+		<result column="signature" property="signature" jdbcType="VARCHAR" />
+		<result column="service_total" property="serviceTotal" jdbcType="INTEGER" />
+		<result column="satisfaction_total" property="satisfactionTotal" jdbcType="INTEGER" />
+		<result column="level" property="level" jdbcType="INTEGER" />
+		<result column="maintenance_total" property="maintenanceTotal" jdbcType="INTEGER" />
+		<result column="emergency_total" property="emergencyTotal" jdbcType="INTEGER" />
+		<result column="lift_total" property="liftTotal" jdbcType="INTEGER" />
+		<result column="balance" property="balance" jdbcType="DECIMAL" />
+		<result column="type" property="type" jdbcType="VARCHAR" />
+	</resultMap>
+
+	<resultMap id="ResultMapWithBLOBs" type="cn.com.ty.lift.system.entity.UserInfo" extends="BaseResultMap" >
+		<result column="avatar_url" property="avatarUrl" jdbcType="LONGVARCHAR" />
+	</resultMap>
+
+	<sql id="Base_Column_List" >
+		user_id, name, mobile, gender, age, remarks, signature, service_total, satisfaction_total, 
+		level, maintenance_total, emergency_total, lift_total, balance, type
+	</sql>
+
+	<sql id="Blob_Column_List" >
+		avatar_url
+	</sql>
+
+	<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
+		select 
+		<include refid="Base_Column_List" />
+		,
+		<include refid="Blob_Column_List" />
+		from user_info
+		where user_id = #{userId,jdbcType=BIGINT}
+	</select>
+
+	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+		delete from user_info
+		where user_id = #{userId,jdbcType=BIGINT}
+	</delete>
+
+	<insert id="insert" parameterType="cn.com.ty.lift.system.entity.UserInfo" >
+		insert into user_info (user_id, name, mobile, 
+			gender, age, remarks, 
+			signature, service_total, satisfaction_total, 
+			level, maintenance_total, emergency_total, 
+			lift_total, balance, type, 
+			avatar_url)
+		values (#{userId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{mobile,jdbcType=CHAR}, 
+			#{gender,jdbcType=TINYINT}, #{age,jdbcType=TINYINT}, #{remarks,jdbcType=VARCHAR}, 
+			#{signature,jdbcType=VARCHAR}, #{serviceTotal,jdbcType=INTEGER}, #{satisfactionTotal,jdbcType=INTEGER}, 
+			#{level,jdbcType=INTEGER}, #{maintenanceTotal,jdbcType=INTEGER}, #{emergencyTotal,jdbcType=INTEGER}, 
+			#{liftTotal,jdbcType=INTEGER}, #{balance,jdbcType=DECIMAL}, #{type,jdbcType=VARCHAR}, 
+			#{avatarUrl,jdbcType=LONGVARCHAR})
+	</insert>
+
+	<insert id="insertSelective" parameterType="cn.com.ty.lift.system.entity.UserInfo" >
+		insert into user_info
+		<trim prefix="(" suffix=")" suffixOverrides="," >
+			<if test="userId != null" >
+				user_id,
+			</if>
+			<if test="name != null" >
+				name,
+			</if>
+			<if test="mobile != null" >
+				mobile,
+			</if>
+			<if test="gender != null" >
+				gender,
+			</if>
+			<if test="age != null" >
+				age,
+			</if>
+			<if test="remarks != null" >
+				remarks,
+			</if>
+			<if test="signature != null" >
+				signature,
+			</if>
+			<if test="serviceTotal != null" >
+				service_total,
+			</if>
+			<if test="satisfactionTotal != null" >
+				satisfaction_total,
+			</if>
+			<if test="level != null" >
+				level,
+			</if>
+			<if test="maintenanceTotal != null" >
+				maintenance_total,
+			</if>
+			<if test="emergencyTotal != null" >
+				emergency_total,
+			</if>
+			<if test="liftTotal != null" >
+				lift_total,
+			</if>
+			<if test="balance != null" >
+				balance,
+			</if>
+			<if test="type != null" >
+				type,
+			</if>
+			<if test="avatarUrl != null" >
+				avatar_url,
+			</if>
+		</trim>
+		<trim prefix="values (" suffix=")" suffixOverrides="," >
+			<if test="userId != null" >
+				#{userId,jdbcType=BIGINT},
+			</if>
+			<if test="name != null" >
+				#{name,jdbcType=VARCHAR},
+			</if>
+			<if test="mobile != null" >
+				#{mobile,jdbcType=CHAR},
+			</if>
+			<if test="gender != null" >
+				#{gender,jdbcType=TINYINT},
+			</if>
+			<if test="age != null" >
+				#{age,jdbcType=TINYINT},
+			</if>
+			<if test="remarks != null" >
+				#{remarks,jdbcType=VARCHAR},
+			</if>
+			<if test="signature != null" >
+				#{signature,jdbcType=VARCHAR},
+			</if>
+			<if test="serviceTotal != null" >
+				#{serviceTotal,jdbcType=INTEGER},
+			</if>
+			<if test="satisfactionTotal != null" >
+				#{satisfactionTotal,jdbcType=INTEGER},
+			</if>
+			<if test="level != null" >
+				#{level,jdbcType=INTEGER},
+			</if>
+			<if test="maintenanceTotal != null" >
+				#{maintenanceTotal,jdbcType=INTEGER},
+			</if>
+			<if test="emergencyTotal != null" >
+				#{emergencyTotal,jdbcType=INTEGER},
+			</if>
+			<if test="liftTotal != null" >
+				#{liftTotal,jdbcType=INTEGER},
+			</if>
+			<if test="balance != null" >
+				#{balance,jdbcType=DECIMAL},
+			</if>
+			<if test="type != null" >
+				#{type,jdbcType=VARCHAR},
+			</if>
+			<if test="avatarUrl != null" >
+				#{avatarUrl,jdbcType=LONGVARCHAR},
+			</if>
+		</trim>
+	</insert>
+
+	<update id="updateByPrimaryKeySelective" parameterType="cn.com.ty.lift.system.entity.UserInfo" >
+		update user_info
+		<set >
+			<if test="name != null" >
+				name = #{name,jdbcType=VARCHAR},
+			</if>
+			<if test="mobile != null" >
+				mobile = #{mobile,jdbcType=CHAR},
+			</if>
+			<if test="gender != null" >
+				gender = #{gender,jdbcType=TINYINT},
+			</if>
+			<if test="age != null" >
+				age = #{age,jdbcType=TINYINT},
+			</if>
+			<if test="remarks != null" >
+				remarks = #{remarks,jdbcType=VARCHAR},
+			</if>
+			<if test="signature != null" >
+				signature = #{signature,jdbcType=VARCHAR},
+			</if>
+			<if test="serviceTotal != null" >
+				service_total = #{serviceTotal,jdbcType=INTEGER},
+			</if>
+			<if test="satisfactionTotal != null" >
+				satisfaction_total = #{satisfactionTotal,jdbcType=INTEGER},
+			</if>
+			<if test="level != null" >
+				level = #{level,jdbcType=INTEGER},
+			</if>
+			<if test="maintenanceTotal != null" >
+				maintenance_total = #{maintenanceTotal,jdbcType=INTEGER},
+			</if>
+			<if test="emergencyTotal != null" >
+				emergency_total = #{emergencyTotal,jdbcType=INTEGER},
+			</if>
+			<if test="liftTotal != null" >
+				lift_total = #{liftTotal,jdbcType=INTEGER},
+			</if>
+			<if test="balance != null" >
+				balance = #{balance,jdbcType=DECIMAL},
+			</if>
+			<if test="type != null" >
+				type = #{type,jdbcType=VARCHAR},
+			</if>
+			<if test="avatarUrl != null" >
+				avatar_url = #{avatarUrl,jdbcType=LONGVARCHAR},
+			</if>
+		</set>
+		where user_id = #{userId,jdbcType=BIGINT}
+	</update>
+
+	<update id="updateByPrimaryKeyWithBLOBs" parameterType="cn.com.ty.lift.system.entity.UserInfo" >
+		update user_info
+		set name = #{name,jdbcType=VARCHAR},
+			mobile = #{mobile,jdbcType=CHAR},
+			gender = #{gender,jdbcType=TINYINT},
+			age = #{age,jdbcType=TINYINT},
+			remarks = #{remarks,jdbcType=VARCHAR},
+			signature = #{signature,jdbcType=VARCHAR},
+			service_total = #{serviceTotal,jdbcType=INTEGER},
+			satisfaction_total = #{satisfactionTotal,jdbcType=INTEGER},
+			level = #{level,jdbcType=INTEGER},
+			maintenance_total = #{maintenanceTotal,jdbcType=INTEGER},
+			emergency_total = #{emergencyTotal,jdbcType=INTEGER},
+			lift_total = #{liftTotal,jdbcType=INTEGER},
+			balance = #{balance,jdbcType=DECIMAL},
+			type = #{type,jdbcType=VARCHAR},
+			avatar_url = #{avatarUrl,jdbcType=LONGVARCHAR}
+		where user_id = #{userId,jdbcType=BIGINT}
+	</update>
+
+	<update id="updateByPrimaryKey" parameterType="cn.com.ty.lift.system.entity.UserInfo" >
+		update user_info
+		set name = #{name,jdbcType=VARCHAR},
+			mobile = #{mobile,jdbcType=CHAR},
+			gender = #{gender,jdbcType=TINYINT},
+			age = #{age,jdbcType=TINYINT},
+			remarks = #{remarks,jdbcType=VARCHAR},
+			signature = #{signature,jdbcType=VARCHAR},
+			service_total = #{serviceTotal,jdbcType=INTEGER},
+			satisfaction_total = #{satisfactionTotal,jdbcType=INTEGER},
+			level = #{level,jdbcType=INTEGER},
+			maintenance_total = #{maintenanceTotal,jdbcType=INTEGER},
+			emergency_total = #{emergencyTotal,jdbcType=INTEGER},
+			lift_total = #{liftTotal,jdbcType=INTEGER},
+			balance = #{balance,jdbcType=DECIMAL},
+			type = #{type,jdbcType=VARCHAR}
+		where user_id = #{userId,jdbcType=BIGINT}
+	</update>
+
+</mapper>