# v1.2.1 更新内容
## 更新列表
1. 短信后台升级,更新供应商
2. 替换官方swagger文档提升友好和易用[swagger-bootstrap-ui] https://doc.xiaominfo.com/knife4j
3. 添加商品分类必要素材,可在配置好图片服务后自行维护
This commit is contained in:
@@ -3,6 +3,7 @@ package com.zbkj.crmeb.config;
|
||||
import com.constants.Constants;
|
||||
import com.google.common.base.Predicate;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@@ -34,6 +35,7 @@ import static com.google.common.collect.Lists.newArrayList;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@ConfigurationProperties(prefix = "api.doc")
|
||||
public class SwaggerConfig{
|
||||
|
||||
//是否开启swagger,正式环境一般是需要关闭的,可根据springboot的多环境配置进行设置
|
||||
@@ -129,7 +131,7 @@ public class SwaggerConfig{
|
||||
return new ApiInfoBuilder()
|
||||
.title("Crmeb Java")
|
||||
.description("Crmeb")
|
||||
.termsOfServiceUrl("http://host:port/swagger-ui.html#/")
|
||||
.termsOfServiceUrl("http://host:port")
|
||||
.version("1.0.0").build();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,13 +115,13 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
excludePathPatterns("/api/front/seckill/list/*").
|
||||
excludePathPatterns("/api/front/seckill/detail/*").
|
||||
// excludePathPatterns("/api/front/cart/count").
|
||||
excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
|
||||
excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
|
||||
}
|
||||
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/**")
|
||||
.addResourceLocations("classpath:/static/");
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
registry.addResourceHandler("doc.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
@@ -140,7 +140,8 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "swagger.basic.enable", havingValue = "true")
|
||||
public MappedInterceptor getMappedInterceptor() {
|
||||
return new MappedInterceptor(new String[]{"/swagger-ui.html", "/webjars/**"}, new SwaggerInterceptor(username, password, check));
|
||||
|
||||
return new MappedInterceptor(new String[]{"/doc.html", "/webjars/**"}, new SwaggerInterceptor(username, password, check));
|
||||
}
|
||||
// 验证参数是否完全匹配
|
||||
// @Override
|
||||
|
||||
@@ -35,7 +35,6 @@ public class SmsRecordController {
|
||||
@Autowired
|
||||
private SmsService smsService;
|
||||
|
||||
|
||||
/**
|
||||
* 注册账户时发送短信api
|
||||
* @param phone 手机号码
|
||||
@@ -55,7 +54,7 @@ public class SmsRecordController {
|
||||
@ApiOperation(value = " 发送短信")
|
||||
@RequestMapping(value = "/sendCode", method = RequestMethod.POST)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="phone", value="手机号码", required = true)
|
||||
@ApiImplicitParam(name="phone", value="手机号码", required = true)
|
||||
})
|
||||
public CommonResult<Object> sendCode(@RequestParam String phone){
|
||||
ValidateFormUtil.isPhone(phone,"手机号码错误");
|
||||
@@ -198,12 +197,14 @@ public class SmsRecordController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="payType", value="支付类型 weixin:微信支付/alipay:支付宝支付"),
|
||||
@ApiImplicitParam(name="mealId", value="套餐id"),
|
||||
@ApiImplicitParam(name="price", value="价格")
|
||||
@ApiImplicitParam(name="price", value="价格"),
|
||||
@ApiImplicitParam(name="num", value="套餐条数"),
|
||||
})
|
||||
public CommonResult<JSONObject> payQrCode(@RequestParam(name = "payType", defaultValue = SmsConstants.PAY_DEFAULT_PAY_TYPE) String payType,
|
||||
@RequestParam(name = "mealId", required = false, defaultValue = "0") Integer mealId,
|
||||
@RequestParam(name = "price", required = false, defaultValue = "0") BigDecimal price){
|
||||
JSONObject result = smsService.getPayQrCode(payType, mealId, price);
|
||||
@RequestParam(name = "mealId", required = true) Integer mealId,
|
||||
@RequestParam(name = "price", required = true) BigDecimal price,
|
||||
@RequestParam(name = "num", required = false, defaultValue = "0") Integer num){
|
||||
JSONObject result = smsService.getPayQrCode(payType, mealId, price, num);
|
||||
return CommonResult.success(getDataByResult(result));
|
||||
}
|
||||
|
||||
@@ -223,8 +224,8 @@ public class SmsRecordController {
|
||||
@ApiImplicitParam(name="type", value="type (1=验证码 2=通知 3=推广)"),
|
||||
})
|
||||
public CommonResult<JSONObject> applyTempMessage(@RequestParam(name = "title") String title,
|
||||
@RequestParam(name = "content") String content,
|
||||
@RequestParam(name = "type", required = false, defaultValue = "1") Integer type){
|
||||
@RequestParam(name = "content") String content,
|
||||
@RequestParam(name = "type", required = false, defaultValue = "1") Integer type){
|
||||
JSONObject result = smsService.applyTempMessage(title, content, type);
|
||||
return CommonResult.success(getMsgByResult(result));
|
||||
}
|
||||
@@ -274,4 +275,3 @@ public class SmsRecordController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,4 +57,6 @@ public class RegisterRequest implements Serializable {
|
||||
private String code;
|
||||
|
||||
private String verify_code;
|
||||
|
||||
private String url;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mr.Zhang
|
||||
* @Description SmsService 接口
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
* @author Mr.Zhang
|
||||
* @Description SmsService 接口
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
public interface SmsService{
|
||||
|
||||
JSONObject register(RegisterRequest registerRequest);
|
||||
@@ -33,7 +33,7 @@ public interface SmsService{
|
||||
|
||||
JSONObject payTempList(PageParamRequest pageParamRequest);
|
||||
|
||||
JSONObject getPayQrCode(String payType, Integer mealId, BigDecimal price);
|
||||
JSONObject getPayQrCode(String payType, Integer mealId, BigDecimal price, Integer num);
|
||||
|
||||
JSONObject applyTempMessage(String title, String content, Integer type);
|
||||
|
||||
|
||||
@@ -179,15 +179,17 @@ public class SmsServiceImpl implements SmsService {
|
||||
public JSONObject register(RegisterRequest registerRequest) {
|
||||
registerRequest.setPassword(DigestUtils.md5Hex(registerRequest.getPassword()));
|
||||
registerRequest.setVerify_code(registerRequest.getCode());
|
||||
registerRequest.setUrl(registerRequest.getDomain());
|
||||
Map<String, Object> map = CrmebUtil.objectToMap(registerRequest);
|
||||
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
||||
param.setAll(map);
|
||||
// JSONObject post = post(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_REGISTER_URI, map);
|
||||
JSONObject post = postFrom(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_REGISTER_URI, param, null);
|
||||
// token存入Redis
|
||||
String accessToken = SmsConstants.SMS_USER_TOKEN_PREFIX.concat(post.getJSONObject("data").getString("access_token"));
|
||||
Long expiresIn = post.getJSONObject("data").getLong("expires_in");
|
||||
expiresIn = expiresIn - System.currentTimeMillis()/1000;
|
||||
redisUtil.set(StrUtil.format(SmsConstants.SMS_USER_TOKEN_REDIS_PREFIX, getMd5Token()), accessToken, expiresIn, TimeUnit.SECONDS);
|
||||
|
||||
// 开通短信服务
|
||||
HashMap<String, String> header = getCommonHeader(accessToken);
|
||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||
@@ -349,10 +351,11 @@ public class SmsServiceImpl implements SmsService {
|
||||
@Override
|
||||
public JSONObject payTempList(PageParamRequest pageParamRequest) {
|
||||
init();
|
||||
Map<String, Object> map = mergeToken(CrmebUtil.objectToMap(pageParamRequest));
|
||||
map.put("type", "sms");
|
||||
// Map<String, Object> map = mergeToken(CrmebUtil.objectToMap(pageParamRequest));
|
||||
// map.put("type", "sms");
|
||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||
params.setAll(map);
|
||||
params.add("type", "sms");
|
||||
// params.setAll(map);
|
||||
String accessToken = getSmsUserTokenByRedis();
|
||||
HashMap<String, String> header = getCommonHeader(accessToken);
|
||||
// return get(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_PAY_TEMP_LIST_URI, map);
|
||||
@@ -369,19 +372,28 @@ public class SmsServiceImpl implements SmsService {
|
||||
* @return JSONObject
|
||||
*/
|
||||
@Override
|
||||
public JSONObject getPayQrCode(String payType, Integer mealId, BigDecimal price) {
|
||||
public JSONObject getPayQrCode(String payType, Integer mealId, BigDecimal price, Integer num) {
|
||||
init();
|
||||
Map<String, Object> map = getTokenMap();
|
||||
// map.put("payType", payType);
|
||||
map.put("pay_type", payType);
|
||||
// map.put("mealId", mealId);
|
||||
map.put("meal_id", mealId);
|
||||
map.put("price", price);
|
||||
// map.put("uid", getAccount());
|
||||
// map.put("token", getMd5Token());
|
||||
map.put("type", "sms");
|
||||
map.put("notify", getPayNotifyUrl());
|
||||
return post(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_PAY_QR_CODE_URI, map);
|
||||
// Map<String, Object> map = getTokenMap();
|
||||
//// map.put("payType", payType);
|
||||
// map.put("pay_type", payType);
|
||||
//// map.put("mealId", mealId);
|
||||
// map.put("meal_id", mealId);
|
||||
// map.put("price", price);
|
||||
//// map.put("uid", getAccount());
|
||||
//// map.put("token", getMd5Token());
|
||||
// map.put("type", "sms");
|
||||
// map.put("notify", getPayNotifyUrl());
|
||||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||||
params.add("meal_id", mealId);
|
||||
params.add("price", price);
|
||||
params.add("num", num);
|
||||
params.add("type", "sms");
|
||||
params.add("pay_type", payType);
|
||||
String accessToken = getSmsUserTokenByRedis();
|
||||
HashMap<String, String> header = getCommonHeader(accessToken);
|
||||
// return post(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_PAY_QR_CODE_URI, map);
|
||||
return postFrom(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_PAY_QR_CODE_URI, params, header);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -646,7 +658,6 @@ public class SmsServiceImpl implements SmsService {
|
||||
public JSONObject sendCodeForRegister(String phone) {
|
||||
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
map.add("phone", phone);
|
||||
// return getData(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_CAPTCHA_URI+"?phone="+phone);
|
||||
return postFrom(SmsConstants.SMS_API_URL + SmsConstants.SMS_API_CAPTCHA_URI, map, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user