sunlightcs 7 years ago
parent
commit
c9e7a8eb84

+ 7 - 0
Dockerfile

@ -0,0 +1,7 @@
1
FROM java:8
2
EXPOSE 80
3
4
VOLUME /tmp
5
ADD renren-fast-1.2.0.jar /app.jar
6
RUN bash -c 'touch /app.jar'
7
ENTRYPOINT ["java","-jar","/app.jar"]

+ 6 - 0
docker-compose.yml

@ -0,0 +1,6 @@
1
version: '2'
2
services:
3
  campus:
4
    image: renren/fast
5
    ports:
6
      - "80:80"

+ 24 - 0
pom.xml

@ -200,6 +200,30 @@
200 200
					<displayCommandOutputs>true</displayCommandOutputs>
201 201
				</configuration>
202 202
			</plugin>
203
			<plugin>
204
				<groupId>com.spotify</groupId>
205
				<artifactId>docker-maven-plugin</artifactId>
206
				<version>0.4.14</version>
207
				<!--<executions>-->
208
					<!--<execution>-->
209
						<!--<phase>package</phase>-->
210
						<!--<goals>-->
211
							<!--<goal>build</goal>-->
212
						<!--</goals>-->
213
					<!--</execution>-->
214
				<!--</executions>-->
215
				<configuration>
216
					<imageName>renren/fast</imageName>
217
					<dockerDirectory>${project.basedir}</dockerDirectory>
218
					<!--<resources>-->
219
						<!--<resource>-->
220
							<!--<targetPath>/</targetPath>-->
221
							<!--<directory>${project.build.directory}</directory>-->
222
							<!--<include>${project.build.finalName}.jar</include>-->
223
						<!--</resource>-->
224
					<!--</resources>-->
225
				</configuration>
226
			</plugin>
203 227
		</plugins>
204 228
	</build>
205 229

+ 1 - 1
src/main/java/io/renren/common/aspect/RedisAspect.java

@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
21 21
public class RedisAspect {
22 22
    private Logger logger = LoggerFactory.getLogger(getClass());
23 23
    //是否开启redis缓存  true开启   false关闭
24
    @Value("${spring.redis.open: #{false}}")
24
    @Value("${spring.redis.open: false}")
25 25
    private boolean open;
26 26
27 27
    @Around("execution(* io.renren.common.utils.RedisUtils.*(..))")

+ 0 - 2
src/main/java/io/renren/common/aspect/SysLogAspect.java

@ -92,6 +92,4 @@ public class SysLogAspect {
92 92
		//保存系统日志
93 93
		sysLogService.save(sysLog);
94 94
	}
95
96
	
97 95
}

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

@ -20,7 +20,7 @@ public class RRExceptionHandler {
20 20
	private Logger logger = LoggerFactory.getLogger(getClass());
21 21
22 22
	/**
23
	 * 自定义异常
23
	 * 处理自定义异常
24 24
	 */
25 25
	@ExceptionHandler(RRException.class)
26 26
	public R handleRRException(RRException e){

+ 0 - 14
src/main/java/io/renren/common/utils/ShiroUtils.java

@ -1,6 +1,5 @@
1 1
package io.renren.common.utils;
2 2
3
import io.renren.common.exception.RRException;
4 3
import io.renren.modules.sys.entity.SysUserEntity;
5 4
import org.apache.shiro.SecurityUtils;
6 5
import org.apache.shiro.session.Session;
@ -43,17 +42,4 @@ public class ShiroUtils {
43 42
		return SecurityUtils.getSubject().getPrincipal() != null;
44 43
	}
45 44
46
	public static void logout() {
47
		SecurityUtils.getSubject().logout();
48
	}
49
	
50
	public static String getKaptcha(String key) {
51
		Object kaptcha = getSessionAttribute(key);
52
		if(kaptcha == null){
53
			throw new RRException("验证码已失效");
54
		}
55
		getSession().removeAttribute(key);
56
		return kaptcha.toString();
57
	}
58
59 45
}

+ 1 - 1
src/main/java/io/renren/modules/api/interceptor/AuthorizationInterceptor.java

@ -36,7 +36,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
36 36
            return true;
37 37
        }
38 38
39
        //如果有@IgnoreAuth注解,则不验证token
39
        //如果有@AuthIgnore注解,则不验证token
40 40
        if(annotation != null){
41 41
            return true;
42 42
        }

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

@ -33,9 +33,9 @@ public class ScheduleConfig {
33 33
        //JobStore配置
34 34
        prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
35 35
        //集群配置
36
//        prop.put("org.quartz.jobStore.isClustered", "true");
37
//        prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
38
//        prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
36
        prop.put("org.quartz.jobStore.isClustered", "true");
37
        prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
38
        prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
39 39
40 40
        prop.put("org.quartz.jobStore.misfireThreshold", "12000");
41 41
        prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");

+ 2 - 1
src/main/java/io/renren/modules/job/task/TestTask.java

@ -24,7 +24,8 @@ public class TestTask {
24 24
	
25 25
	@Autowired
26 26
	private SysUserService sysUserService;
27
	
27
28
	//定时任务只能接受一个参数;如果有多个参数,使用json数据即可
28 29
	public void test(String params){
29 30
		logger.info("我是带参数的test方法,正在被执行,参数为:" + params);
30 31
		

+ 1 - 1
src/main/java/io/renren/modules/job/utils/ScheduleJob.java

@ -34,7 +34,7 @@ public class ScheduleJob extends QuartzJobBean {
34 34
		String jsonJob = context.getMergedJobDataMap().getString(ScheduleJobEntity.JOB_PARAM_KEY);
35 35
		ScheduleJobEntity scheduleJob = new Gson().fromJson(jsonJob, ScheduleJobEntity.class);
36 36
37
		//获取spring bean
37
		//获取scheduleJobLogService
38 38
        ScheduleJobLogService scheduleJobLogService = (ScheduleJobLogService) SpringContextUtils.getBean("scheduleJobLogService");
39 39
        
40 40
        //数据库保存执行记录

+ 8 - 7
src/main/java/io/renren/modules/job/utils/ScheduleUtils.java

@ -19,14 +19,14 @@ public class ScheduleUtils {
19 19
    /**
20 20
     * 获取触发器key
21 21
     */
22
    public static TriggerKey getTriggerKey(Long jobId) {
22
    private static TriggerKey getTriggerKey(Long jobId) {
23 23
        return TriggerKey.triggerKey(JOB_NAME + jobId);
24 24
    }
25 25
    
26 26
    /**
27 27
     * 获取jobKey
28 28
     */
29
    public static JobKey getJobKey(Long jobId) {
29
    private static JobKey getJobKey(Long jobId) {
30 30
        return JobKey.jobKey(JOB_NAME + jobId);
31 31
    }
32 32
@ -37,7 +37,7 @@ public class ScheduleUtils {
37 37
        try {
38 38
            return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId));
39 39
        } catch (SchedulerException e) {
40
            throw new RRException("获取定时任务CronTrigger出现异常", e);
40
            throw new RRException("getCronTrigger异常,请检查qrtz开头的表,是否有脏数据", e);
41 41
        }
42 42
    }
43 43
@ -46,15 +46,16 @@ public class ScheduleUtils {
46 46
     */
47 47
    public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
48 48
        try {
49
        	//构建job信息
49
        	//构建job
50 50
            JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getJobId())).build();
51 51
52
            //表达式调度构建
52
            //构建cron
53 53
            CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
54 54
            		.withMisfireHandlingInstructionDoNothing();
55 55
56
            //按新的cronExpression表达式构建一个新的trigger
57
            CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId())).withSchedule(scheduleBuilder).build();
56
            //根据cron,构建一个CronTrigger
57
            CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId())).
58
                    withSchedule(scheduleBuilder).build();
58 59
59 60
            //放入参数,运行时的方法可以获取
60 61
            jobDetail.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, new Gson().toJson(scheduleJob));

+ 15 - 15
src/main/java/io/renren/modules/oss/cloud/QcloudCloudStorageService.java

@ -2,15 +2,15 @@ package io.renren.modules.oss.cloud;
2 2
3 3
4 4
import com.qcloud.cos.COSClient;
5
import com.qcloud.cos.ClientConfig;
6
import com.qcloud.cos.request.UploadFileRequest;
7
import com.qcloud.cos.sign.Credentials;
8
import io.renren.common.exception.RRException;
9
import net.sf.json.JSONObject;
10
import org.apache.commons.io.IOUtils;
5
        import com.qcloud.cos.ClientConfig;
6
        import com.qcloud.cos.request.UploadFileRequest;
7
        import com.qcloud.cos.sign.Credentials;
8
        import io.renren.common.exception.RRException;
9
        import net.sf.json.JSONObject;
10
        import org.apache.commons.io.IOUtils;
11 11
12
import java.io.IOException;
13
import java.io.InputStream;
12
        import java.io.IOException;
13
        import java.io.InputStream;
14 14
15 15
/**
16 16
 * 腾讯云存储
@ -29,15 +29,15 @@ public class QcloudCloudStorageService extends CloudStorageService{
29 29
    }
30 30
31 31
    private void init(){
32
    	Credentials credentials = new Credentials(config.getQcloudAppId(), config.getQcloudSecretId(),
32
        Credentials credentials = new Credentials(config.getQcloudAppId(), config.getQcloudSecretId(),
33 33
                config.getQcloudSecretKey());
34
    	
35
    	//初始化客户端配置
34
35
        //初始化客户端配置
36 36
        ClientConfig clientConfig = new ClientConfig();
37 37
        //设置bucket所在的区域,华南:gz 华北:tj 华东:sh
38 38
        clientConfig.setRegion(config.getQcloudRegion());
39
        
40
    	client = new COSClient(clientConfig, credentials);
39
40
        client = new COSClient(clientConfig, credentials);
41 41
    }
42 42
43 43
    @Override
@ -46,7 +46,7 @@ public class QcloudCloudStorageService extends CloudStorageService{
46 46
        if(!path.startsWith("/")) {
47 47
            path = "/" + path;
48 48
        }
49
        
49
50 50
        //上传到腾讯云
51 51
        UploadFileRequest request = new UploadFileRequest(config.getQcloudBucketName(), path, data);
52 52
        String response = client.uploadFile(request);
@ -61,7 +61,7 @@ public class QcloudCloudStorageService extends CloudStorageService{
61 61
62 62
    @Override
63 63
    public String upload(InputStream inputStream, String path) {
64
    	try {
64
        try {
65 65
            byte[] data = IOUtils.toByteArray(inputStream);
66 66
            return this.upload(data, path);
67 67
        } catch (IOException e) {

+ 1 - 2
src/main/resources/application.yml

@ -5,8 +5,7 @@ server:
5 5
        max-threads: 1000
6 6
        min-spare-threads: 30
7 7
    port: 80
8
    #打开注释,则通过【http://localhost/renren-fast】访问
9
    #context-path: /renren-fast
8
    context-path: /renren-fast
10 9
11 10
spring:
12 11
    # 环境 dev|test|pro

+ 1 - 3
src/main/resources/static/js/common.js

@ -18,9 +18,7 @@ var url = function(name) {
18 18
T.p = url;
19 19
20 20
//请求前缀
21
//var baseURL = "http://www.juziku.com/";
22
//var baseURL = "/renren-fast/";
23
var baseURL = "/";
21
var baseURL = "/renren-fast/";
24 22
25 23
//登录token
26 24
var token = localStorage.getItem("token");