|
|
@ -1,11 +1,14 @@ |
|
|
|
package org.jeecg.modules.alUser.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.xkcoding.http.HttpUtil; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
import org.jeecg.common.constant.CommonConstant; |
|
|
|
import org.jeecg.common.util.RedisUtil; |
|
|
|
import org.jeecg.config.shiro.ShiroRealm; |
|
|
|
import org.jeecg.modules.alUser.service.IndexService; |
|
|
|
import org.jeecg.modules.banner.entity.WebBanner; |
|
|
@ -13,12 +16,16 @@ import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
|
import org.jeecg.modules.postBean.SuggestReq; |
|
|
|
import org.jeecg.modules.tbSuggest.entity.TbSuggest; |
|
|
|
import org.jeecg.modules.tbSuggest.service.ITbSuggestService; |
|
|
|
import org.jeecg.modules.utils.ValidateTool; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author scott |
|
|
@ -35,13 +42,28 @@ public class IndexController { |
|
|
|
private IndexService indexService; |
|
|
|
@Autowired |
|
|
|
private ShiroRealm shiroRealm; |
|
|
|
@Autowired |
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "铝价接口") |
|
|
|
@RequestMapping(value = "/alprice", method = RequestMethod.POST) |
|
|
|
public Result<JSONObject> alprice() { |
|
|
|
String s = HttpUtil.get("https://www.alphavantage.co/query?function=ALUMINUM&interval=monthly&apikey=AH6NDLVPBHJ8K7OM"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
String alprice = null; |
|
|
|
Object o = redisUtil.get(CommonConstant.AL_PRICE); |
|
|
|
if (ValidateTool.isNull(o)) { |
|
|
|
alprice = HttpUtil.get("https://www.alphavantage.co/query?function=ALUMINUM&interval=monthly&apikey=AH6NDLVPBHJ8K7OM"); |
|
|
|
//每天更新一次缓存 |
|
|
|
redisUtil.set(CommonConstant.AL_PRICE, alprice, 86400); |
|
|
|
} else { |
|
|
|
alprice = String.valueOf(o); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(alprice); |
|
|
|
Object data = jsonObject.get("data"); |
|
|
|
List<JSONObject> strings = JSON.parseArray(String.valueOf(data), JSONObject.class); |
|
|
|
//取前12条数据返回 |
|
|
|
List<JSONObject> collect = strings.stream().limit(12).collect(Collectors.toList()); |
|
|
|
jsonObject.put("data",collect); |
|
|
|
return Result.ok(jsonObject); |
|
|
|
} |
|
|
|
|
|
|
@ -55,7 +77,6 @@ public class IndexController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取banner列表") |
|
|
|
@RequestMapping(value = "/bannerList", method = RequestMethod.POST) |
|
|
|
public Result<Map<Integer, List<WebBanner>>> bannerList(@RequestHeader("X-Access-Token") String token) { |
|
|
@ -64,7 +85,7 @@ public class IndexController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value="帮助与反馈", notes="帮助与反馈") |
|
|
|
@ApiOperation(value = "帮助与反馈", notes = "帮助与反馈") |
|
|
|
@PostMapping(value = "/addSuggest") |
|
|
|
public Result<String> addSuggest(@RequestBody SuggestReq tbSuggest, @RequestHeader("X-Access-Token") String token) { |
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
@ -76,6 +97,4 @@ public class IndexController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |