Mark 7 rokov pred
rodič
commit
5021492e57

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 **项目说明** 
 - renren-fast是一个轻量级的,前后端分离的Java快速开发平台,能快速开发项目并交付【接私活利器】
+- 支持MySQL、Oracle、SQL Server、PostgreSQL等主流数据库
 - 前端地址:https://github.com/daxiongYang/renren-fast-vue
 <br> 
 <br>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 195 - 2
db/mssql.sql


+ 4 - 0
db/oracle.sql

@@ -1,8 +1,11 @@
 
 
 
 
+
+
+
+--  quartz自带表结构
 delete from qrtz_fired_triggers;
 delete from qrtz_simple_triggers;
 delete from qrtz_simprop_triggers;

+ 4 - 0
db/postgresql.sql

@@ -1,7 +1,10 @@
 
 
 
+
+
+
+--  quartz自带表结构
 drop table qrtz_fired_triggers;
 DROP TABLE QRTZ_PAUSED_TRIGGER_GRPS;
 DROP TABLE QRTZ_SCHEDULER_STATE;

+ 20 - 1
pom.xml

@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>io.renren</groupId>
 	<artifactId>renren-fast</artifactId>
-	<version>2.0.0</version>
+	<version>2.1.0</version>
 	<packaging>jar</packaging>
 	<description>renren-fast</description>
 
@@ -21,6 +21,8 @@
 		<mybatisplus.spring.boot.version>1.0.5</mybatisplus.spring.boot.version>
 		<mybatisplus.version>2.1.9</mybatisplus.version>
 		<mysql.version>5.1.38</mysql.version>
+		<mssql.version>4.0</mssql.version>
+		<oracle.version>11.2.0.3</oracle.version>
 		<druid.version>1.1.9</druid.version>
 		<quartz.version>2.3.0</quartz.version>
 		<commons.lang.version>2.6</commons.lang.version>
@@ -98,6 +100,23 @@
 			<artifactId>mysql-connector-java</artifactId>
 			<version>${mysql.version}</version>
 		</dependency>
+		 <!--oracle驱动-->
+		<dependency>
+		<groupId>com.oracle</groupId>
+		<artifactId>ojdbc6</artifactId>
+		<version>${oracle.version}</version>
+		</dependency>
+		 <!--mssql驱动-->
+		<dependency>
+		<groupId>com.microsoft.sqlserver</groupId>
+		<artifactId>sqljdbc4</artifactId>
+		<version>${mssql.version}</version>
+		</dependency>
+		 <!--postgresql驱动-->
+		<dependency>
+		<groupId>org.postgresql</groupId>
+		<artifactId>postgresql</artifactId>
+		</dependency>
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>druid-spring-boot-starter</artifactId>

+ 7 - 0
src/main/java/io/renren/common/exception/RRExceptionHandler.java

@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.NoHandlerFoundException;
 
 /**
  * 异常处理器
@@ -31,6 +32,12 @@ public class RRExceptionHandler {
 		return r;
 	}
 
+	@ExceptionHandler(NoHandlerFoundException.class)
+	public R handlerNoFoundException(Exception e) {
+		logger.error(e.getMessage(), e);
+		return R.error(404, "路径不存在,请检查路径是否正确");
+	}
+
 	@ExceptionHandler(DuplicateKeyException.class)
 	public R handleDuplicateKeyException(DuplicateKeyException e){
 		logger.error(e.getMessage(), e);

+ 2 - 2
src/main/java/io/renren/modules/app/config/WebMvcConfig.java

@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 import java.util.List;
 
@@ -18,7 +18,7 @@ import java.util.List;
  * @date 2017-04-20 22:30
  */
 @Configuration
-public class WebMvcConfig extends WebMvcConfigurerAdapter {
+public class WebMvcConfig implements WebMvcConfigurer {
     @Autowired
     private AuthorizationInterceptor authorizationInterceptor;
     @Autowired

+ 4 - 0
src/main/java/io/renren/modules/job/config/ScheduleConfig.java

@@ -55,6 +55,10 @@ public class ScheduleConfig {
         prop.put("org.quartz.jobStore.misfireThreshold", "12000");
         prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
         prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
+
+        //PostgreSQL数据库,需要打开此注释
+        //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
+
         factory.setQuartzProperties(prop);
 
         factory.setSchedulerName("RenrenScheduler");

+ 1 - 1
src/main/java/io/renren/modules/sys/dao/SysConfigDao.java

@@ -40,6 +40,6 @@ public interface SysConfigDao extends BaseMapper<SysConfigEntity> {
 	/**
 	 * 根据key,更新value
 	 */
-	int updateValueByKey(@Param("key") String key, @Param("value") String value);
+	int updateValueByKey(@Param("paramKey") String paramKey, @Param("paramValue") String paramValue);
 	
 }

+ 18 - 12
src/main/java/io/renren/modules/sys/entity/SysConfigEntity.java

@@ -18,7 +18,8 @@ package io.renren.modules.sys.entity;
 
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
-import org.hibernate.validator.constraints.NotBlank;
+
+import javax.validation.constraints.NotBlank;
 
 /**
  * 系统配置信息
@@ -32,29 +33,34 @@ public class SysConfigEntity {
 	@TableId
 	private Long id;
 	@NotBlank(message="参数名不能为空")
-	private String key;
+	private String paramKey;
 	@NotBlank(message="参数值不能为空")
-	private String value; 
+	private String paramValue;
 	private String remark;
-	
+
 	public Long getId() {
 		return id;
 	}
 	public void setId(Long id) {
 		this.id = id;
 	}
-	public String getKey() {
-		return key;
+
+	public String getParamKey() {
+		return paramKey;
 	}
-	public void setKey(String key) {
-		this.key = key;
+
+	public void setParamKey(String paramKey) {
+		this.paramKey = paramKey;
 	}
-	public String getValue() {
-		return value;
+
+	public String getParamValue() {
+		return paramValue;
 	}
-	public void setValue(String value) {
-		this.value = value;
+
+	public void setParamValue(String paramValue) {
+		this.paramValue = paramValue;
 	}
+
 	public String getRemark() {
 		return remark;
 	}

+ 18 - 1
src/main/java/io/renren/modules/sys/redis/SysConfigRedis.java

@@ -1,5 +1,22 @@
+/**
+ * Copyright 2018 人人开源 http://www.renren.io
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
 package io.renren.modules.sys.redis;
 
+
 import io.renren.common.utils.RedisKeys;
 import io.renren.common.utils.RedisUtils;
 import io.renren.modules.sys.entity.SysConfigEntity;
@@ -22,7 +39,7 @@ public class SysConfigRedis {
         if(config == null){
             return ;
         }
-        String key = RedisKeys.getSysConfigKey(config.getKey());
+        String key = RedisKeys.getSysConfigKey(config.getParamKey());
         redisUtils.set(key, config);
     }
 

+ 5 - 5
src/main/java/io/renren/modules/sys/service/impl/SysConfigServiceImpl.java

@@ -42,12 +42,12 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigDao, SysConfigEnt
 
 	@Override
 	public PageUtils queryPage(Map<String, Object> params) {
-		String key = (String)params.get("key");
+		String paramKey = (String)params.get("paramKey");
 
 		Page<SysConfigEntity> page = this.selectPage(
 				new Query<SysConfigEntity>(params).getPage(),
 				new EntityWrapper<SysConfigEntity>()
-					.like(StringUtils.isNotBlank(key),"key", key)
+					.like(StringUtils.isNotBlank(paramKey),"param_key", paramKey)
 					.eq("status", 1)
 		);
 
@@ -63,7 +63,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigDao, SysConfigEnt
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void update(SysConfigEntity config) {
-		this.updateById(config);
+		this.updateAllColumnById(config);
 		sysConfigRedis.saveOrUpdate(config);
 	}
 
@@ -79,7 +79,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigDao, SysConfigEnt
 	public void deleteBatch(Long[] ids) {
 		for(Long id : ids){
 			SysConfigEntity config = this.selectById(id);
-			sysConfigRedis.delete(config.getKey());
+			sysConfigRedis.delete(config.getParamKey());
 		}
 
 		this.deleteBatchIds(Arrays.asList(ids));
@@ -93,7 +93,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigDao, SysConfigEnt
 			sysConfigRedis.saveOrUpdate(config);
 		}
 
-		return config == null ? null : config.getValue();
+		return config == null ? null : config.getParamValue();
 	}
 	
 	@Override

+ 1 - 1
src/main/java/io/renren/modules/sys/service/impl/SysRoleServiceImpl.java

@@ -70,7 +70,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> i
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void update(SysRoleEntity role) {
-        this.updateById(role);
+        this.updateAllColumnById(role);
 
         //检查权限是否越权
         checkPrems(role);

+ 8 - 5
src/main/resources/application.yml

@@ -4,8 +4,8 @@ server:
         uri-encoding: UTF-8
         max-threads: 1000
         min-spare-threads: 30
-    port: 8082
-    connection-timeout: 5000
+    port: 8080
+    connection-timeout: 5000ms
     servlet:
       context-path: /renren-fast
 
@@ -29,14 +29,17 @@ spring:
         host: localhost
         port: 6379
         password:   Nannan2017JK    # 密码(默认为空)
-        timeout: 6000  # 连接超时时长(毫秒)
+        timeout: 6000ms  # 连接超时时长(毫秒)
         jedis:
           pool:
               max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
-              max-wait: -1      # 连接池最大阻塞等待时间(使用负值表示没有限制)
+              max-wait: -1ms      # 连接池最大阻塞等待时间(使用负值表示没有限制)
               max-idle: 10      # 连接池中的最大空闲连接
               min-idle: 5       # 连接池中的最小空闲连接
-
+    mvc:
+        throw-exception-if-no-handler-found: true
+    resources:
+        add-mappings: false
 
 #mybatis
 mybatis-plus:

+ 5 - 5
src/main/resources/mapper/sys/SysConfigDao.xml

@@ -1,15 +1,15 @@
-<?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">
+<?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="io.renren.modules.sys.dao.SysConfigDao">
 
 	<!-- 根据key,更新value -->
 	<update id="updateValueByKey" parameterType="map">
-		update sys_config set `value` = #{value} where `key` = #{key}
+		update sys_config set param_value = #{paramValue} where param_key = #{paramKey}
 	</update>
 
 	<!-- 根据key,查询value -->
 	<select id="queryByKey" parameterType="string" resultType="io.renren.modules.sys.entity.SysConfigEntity">
-		select * from sys_config where `key` = #{key}
+		select * from sys_config where param_key = #{paramKey}
 	</select>
-
+	
 </mapper>