Merge branch 'test6.8.2' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.2
Showing
1 changed file
with
45 additions
and
0 deletions
1 | +package com.yohoufo.promotion.controller; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.yohoufo.common.annotation.IgnoreSession; | ||
5 | +import com.yohoufo.common.annotation.IgnoreSignature; | ||
6 | +import com.yohoufo.common.cache.CacheClient; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Controller; | ||
9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
10 | +import org.springframework.web.bind.annotation.RequestParam; | ||
11 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by jiexiang.wu on 2018/11/21. | ||
15 | + */ | ||
16 | +@Controller | ||
17 | +@RequestMapping(value = "/redis") | ||
18 | +public class RedisTestController { | ||
19 | + | ||
20 | + @Autowired | ||
21 | + private CacheClient cacheClient; | ||
22 | + | ||
23 | + @RequestMapping("/redis_get") | ||
24 | + @ResponseBody | ||
25 | + @IgnoreSession | ||
26 | + @IgnoreSignature | ||
27 | + public String get(@RequestParam String key, @RequestParam String className) { | ||
28 | + try { | ||
29 | + Class clazz = Class.forName(className); | ||
30 | + Object result = cacheClient.get(key, clazz); | ||
31 | + return JSON.toJSONString(result); | ||
32 | + } catch (Exception ex) { | ||
33 | + return "happen exception"; | ||
34 | + } | ||
35 | + } | ||
36 | + | ||
37 | + @RequestMapping("/redis_delete") | ||
38 | + @ResponseBody | ||
39 | + @IgnoreSession | ||
40 | + @IgnoreSignature | ||
41 | + public String delete(@RequestParam String key) { | ||
42 | + cacheClient.delete(key); | ||
43 | + return "ok"; | ||
44 | + } | ||
45 | +} |
-
Please register or login to post a comment