Browse Source

修改短信,修改注册,铝价接口缓存,返回海报

master
cgx 5 months ago
parent
commit
1db3db4c86
7 changed files with 57 additions and 17 deletions
  1. +1
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
  2. +1
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/tbConf/controller/TbConfController.java
  3. +25
    -6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/controller/IndexController.java
  4. +3
    -7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/controller/UserLoginController.java
  5. +8
    -1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/service/impl/IndexServiceImpl.java
  6. +16
    -0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/service/impl/UserServiceImpl.java
  7. +3
    -3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SmsClient.java

+ 1
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java View File

@ -10,6 +10,7 @@ public interface CommonConstant {
public static final String PHONE_CODE="phone_code:";
public static final String PHONE_SMS="phone_sms:";
public static final String AL_PRICE="al_price:";
/**


+ 1
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/tbConf/controller/TbConfController.java View File

@ -53,6 +53,7 @@ public class TbConfController extends JeecgController<TbConf, ITbConfService> {
HttpServletRequest req) {
QueryWrapper<TbConf> queryWrapper = QueryGenerator.initQueryWrapper(tbConf, req.getParameterMap());
Page<TbConf> page = new Page<TbConf>(pageNo, pageSize);
queryWrapper.eq("dict_group","sys_word");
IPage<TbConf> pageList = tbConfService.page(page, queryWrapper);
return Result.OK(pageList);
}


+ 25
- 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/controller/IndexController.java View File

@ -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 {
}
}

+ 3
- 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/controller/UserLoginController.java View File

@ -66,6 +66,9 @@ public class UserLoginController {
if (ValidateTool.isNull(userLoginModel.getPassword())) {
return Result.error("请填写密码");
}
if (ValidateTool.isNull(userLoginModel.getCaptcha())) {
return Result.error("请填写验证码");
}
return userService.reg(userLoginModel);
}
@ -135,13 +138,6 @@ public class UserLoginController {
}
//随机数
String captcha = RandomUtil.randomNumbers(6);
LambdaQueryWrapper<HanHaiMember> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(HanHaiMember::getAccount, mobile);
HanHaiMember one = iHanHaiMemberService.getOne(queryWrapper);
if (ValidateTool.isNull(one)) {
result.error500("请先注册账号");
return result;
}
String send = SmsClient.send(mobile, captcha);
log.info("短信发送结果{}", send);


+ 8
- 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/service/impl/IndexServiceImpl.java View File

@ -47,10 +47,16 @@ public class IndexServiceImpl implements IndexService {
hanHaiMember.setPasswordSalt(null);
JSONObject jsonObject = new JSONObject();
QueryWrapper<TbConf> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("name","sys_phone");
objectQueryWrapper.eq("name", "sys_phone");
TbConf one = tbConfService.getOne(objectQueryWrapper);
//平台客户电话号码
jsonObject.put("phone", ValidateTool.isNull(one) ? "19198239116" : one.getValue());
jsonObject.put("my", hanHaiMember);
//清关背景图
QueryWrapper<TbConf> queryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("name", "sys_pic_qg");
TbConf pic = tbConfService.getOne(queryWrapper);
jsonObject.put("pic", ValidateTool.isNull(pic) ? "https://dianpin-img.xzaiyp.top/temp/组478612x_1730704228537.png" : pic.getValue());
LambdaQueryWrapper<TbUserRole> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
objectLambdaQueryWrapper.eq(TbUserRole::getUserId, hanHaiMember.getId()).
@ -75,6 +81,7 @@ public class IndexServiceImpl implements IndexService {
QueryWrapper<WebBanner> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("is_disable", 0).orderByDesc("sort");
List<WebBanner> bannerList = webBannerService.list(objectQueryWrapper);
//分组排序返回
Map<Integer, List<WebBanner>> collect = bannerList.stream().sorted(Comparator.comparing(WebBanner::getSort).reversed()).collect(Collectors.groupingBy(WebBanner::getType));
return Result.ok(collect);
}


+ 16
- 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/alUser/service/impl/UserServiceImpl.java View File

@ -124,6 +124,20 @@ public class UserServiceImpl implements UserService {
if (ValidateTool.isNotNull(user)) {
return result.error500("用户已注册");
}
String smscode = userLoginModel.getCaptcha();
if (ValidateTool.isNull(smscode)) {
return Result.error("请填写验证码");
}
//手机验证码登陆
Object code = redisUtil.get(CommonConstant.PHONE_CODE + userLoginModel.getUsername());
if (ValidateTool.isNull(code)) {
result.error500("手机验证码错误");
}
if (!smscode.equals(code)) {
result.error500("手机验证码错误");
return result;
}
HanHaiMember newUser = new HanHaiMember();
newUser.setAccount(userLoginModel.getUsername());
newUser.setPhone(userLoginModel.getUsername());
@ -138,6 +152,8 @@ public class UserServiceImpl implements UserService {
// 设置token缓存有效时间
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
//删除短信验证码
redisUtil.del(CommonConstant.PHONE_CODE + userLoginModel.getUsername());
JSONObject obj = new JSONObject();
obj.put("token", token);
obj.put("userInfo", newUser);


+ 3
- 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SmsClient.java View File

@ -20,9 +20,9 @@ public class SmsClient {
public static String send(String phone,String code) {
SmsClient client = new SmsClient();
String response = client.sendSms("tairoudj", Arrays.asList(
new Message(phone, "【泰柔到家】您的验证码为:"+code)
), System.currentTimeMillis(), "evXRctaIoX22");
String response = client.sendSms("zhonggui", Arrays.asList(
new Message(phone, "【中桂活力金属铝锭交易系统】您的验证码为:"+code)
), System.currentTimeMillis(), "NSFUNFYIR5IM");
return response;
}


Loading…
Cancel
Save