删除不必要的东西,详情增加异常处理

This commit is contained in:
hupeng committed 2019-09-30 12:25:35 +08:00
1 parent 14fe1f5a51
commit 6883730ea5
11 files changed
+105 -32

No files matched your search

+21 -1
View File
@@ -27,7 +27,7 @@
<kaptcha.version>2.3.2</kaptcha.version>
<ehcache.version>3.3.1</ehcache.version>
<zxing.version>3.2.1</zxing.version>
<druid.version>1.1.14</druid.version>
<druid.version>1.1.20</druid.version>
<beetl.version>2.8.5</beetl.version>
<swagger.version>2.9.2</swagger.version>
<commons-lang3.version>3.7</commons-lang3.version>
@@ -200,6 +200,26 @@
</build>
<repositories>
<!--阿里云仓库-->
<repository>
<id>aliyun</id>
<name>aliyun-maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://maven.aliyun.com/repository/spring</url>
</repository>
<repository>
<id>central</id>
<name>maven-central</name>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
@@ -0,0 +1,27 @@
/**
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ruoyi.app.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author geekidea
* @date 2018-11-08
*/
public interface BaseService<T> extends IService<T> {
}
@@ -0,0 +1,38 @@
/**
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ruoyi.app.common.service.impl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.app.common.service.BaseService;
import org.apache.commons.collections.CollectionUtils;
import java.util.Arrays;
import java.util.List;
/**
* @author geekidea
* @date 2018-11-08
*/
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
}
@@ -5,15 +5,11 @@ package com.ruoyi.app.modular.auth.controller;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.itmuch.lightsecurity.annotation.PreAuthorize;
import com.itmuch.lightsecurity.jwt.JwtOperator;
import com.itmuch.lightsecurity.jwt.User;
import com.itmuch.lightsecurity.jwt.UserOperator;
import com.ruoyi.app.common.R;
import com.ruoyi.app.common.persistence.model.StoreMember;
import com.ruoyi.app.common.utils.JsonUtils;
import com.ruoyi.app.modular.member.service.IMemberService;
import com.ruoyi.app.modular.member.service.vo.LoginVO;
@@ -26,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
@@ -86,7 +81,6 @@ public class AuthController {
}
StoreMember member = memberService.login(openid);
//System.out.println(member);
User user = null;
if(member == null){
//新用户插入数据
@@ -114,7 +108,6 @@ public class AuthController {
map.put("access_token",token);
return R.success(map);
} catch (WxErrorException e) {
//System.out.println(e.getMessage());
log.error(e.getMessage());
return R.error(4000,e.getMessage());
}
@@ -2,7 +2,6 @@ package com.ruoyi.app.modular.member.controller;
import com.alibaba.fastjson.JSON;
import com.itmuch.lightsecurity.annotation.PreAuthorize;
import com.itmuch.lightsecurity.jwt.User;
import com.itmuch.lightsecurity.jwt.UserOperator;
import com.ruoyi.app.common.R;
@@ -11,8 +10,6 @@ import com.ruoyi.app.modular.member.service.IMemberService;
import com.ruoyi.app.modular.member.service.dto.MemberDTO;
import com.ruoyi.app.modular.member.service.impl.AddressServiceImpl;
import com.ruoyi.app.modular.member.service.mapper.MemberMapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import com.ruoyi.app.modular.member.service.vo.AddressVO;
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.OrderServiceImpl;
@@ -25,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
//import wiki.xsx.core.handler.StringHandler;
//import wiki.xsx.core.util.RedisUtil;
@@ -3,21 +3,17 @@ package com.ruoyi.app.modular.shop.controller;
import com.itmuch.lightsecurity.jwt.UserOperator;
import com.ruoyi.app.common.R;
import com.ruoyi.app.common.persistence.model.WechatNewsArticle;
import com.ruoyi.app.modular.member.service.IMemberService;
import com.ruoyi.app.modular.shop.service.dto.AdsDTO;
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
import com.ruoyi.app.modular.shop.service.dto.NewsDTO;
import com.ruoyi.app.modular.shop.service.impl.AdServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.NewsServiceImpl;
import com.ruoyi.app.modular.shop.service.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -46,7 +42,6 @@ public class IndexController {
@ApiOperation(value = "首页信息",notes = "首页信息")
public R index(){
int userId = userOperator.getUser().getId();
List<GoodsDTO> recommedGoods = goodsService.getList(0,1,3,userId,"",1);
List<GoodsDTO> newGoods = goodsService.getList(0,1,6,userId,"",2);
List<NewsDTO> newsList = newsService.getList(1,3);
@@ -85,6 +85,7 @@ public class MallController {
Map<String, StoreSpecGoodsPrice> specPrice = goodsService.goodsSpecPrice(goodsId);
GoodsDTO goodsDetail = goodsMapper.toDto(goodsService.getById(goodsId));
Map<String, List<SpecItemDTO>> specs = goodsService.goodsSpec(goodsId);
boolean isCollect = goodsService.isCollect(goodsId,userId);
Map<String,Object> map = new HashMap<>();
@@ -1,7 +1,6 @@
package com.ruoyi.app.modular.shop.controller;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -9,20 +8,17 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.itmuch.lightsecurity.jwt.UserOperator;
import com.ruoyi.app.common.R;
import com.ruoyi.app.common.persistence.dao.StoreGoodsMapper;
import com.ruoyi.app.common.persistence.dao.StoreOrderGoodsMapper;
import com.ruoyi.app.common.persistence.model.StoreMember;
import com.ruoyi.app.common.persistence.model.StoreOrder;
import com.ruoyi.app.common.persistence.model.StoreOrderGoods;
import com.ruoyi.app.modular.member.service.IMemberService;
import com.ruoyi.app.modular.shop.service.dto.OrderDTO;
import com.ruoyi.app.modular.shop.service.impl.OrderServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -30,12 +26,10 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.sound.midi.SoundbankResource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
@@ -121,7 +115,7 @@ public class PayController {
return R.error(4000,"库存不足");
}
}
//System.out.println("11111");
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
StoreMember member = memberService.getById(userId);
orderRequest.setBody("商品购买");
@@ -134,11 +128,9 @@ public class PayController {
orderRequest.setTradeType("JSAPI");
try {
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
System.out.println(orderResult);
return R.success(orderResult);
} catch (WxPayException e) {
return R.error(4000,e.getMessage());
//e.printStackTrace();
}
}
@@ -162,7 +154,6 @@ public class PayController {
orderService.notifyHandle(storeOrder);
return WxPayNotifyResponse.success("处理成功!");
} catch (WxPayException e) {
//System.out.println(e.getMessage());
log.error(e.getMessage());
return WxPayNotifyResponse.fail(e.getMessage());
}
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmuch.lightsecurity.exception.LightSecurityException;
import com.ruoyi.app.common.exception.BadRequestException;
import com.ruoyi.app.common.exception.EntityExistException;
import com.ruoyi.app.common.persistence.dao.StoreCartMapper;
import com.ruoyi.app.common.persistence.dao.StoreGoodsCollectMapper;
import com.ruoyi.app.common.persistence.dao.StoreGoodsMapper;
@@ -116,7 +117,6 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
public List<StoreGoods> collectGoods(int page,int limit,int userId) {
Page<StoreGoods> pageModel = new Page<>(page, limit);
List<StoreGoods> list = baseMapper.collectGoods(pageModel,userId);
//System.out.println(list);
return list;
}
@@ -127,6 +127,10 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
wrapper.eq("goods_id",goodsId);
List<StoreSpecGoodsPrice> specGoodsPriceList = storeSpecGoodsPriceMapper
.selectList(wrapper);
if(ObjectUtil.isNull(specGoodsPriceList)){
System.out.println("2222");
throw new EntityExistException(specGoodsPriceList.getClass());
}
Map<String, StoreSpecGoodsPrice> listMap = specGoodsPriceList.stream().collect(
Collectors.toMap(StoreSpecGoodsPrice::getKey,o->o));
@@ -136,6 +140,9 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
public Map<String, List<SpecItemDTO>> goodsSpec(int goodsId){
String keys = storeSpecGoodsPriceMapper.goodsSpecKey(goodsId);
if(StrUtil.isEmpty(keys)){
throw new LightSecurityException("商品规格未添加");
}
String[] strArr = keys.split("_");
Map<String,List<SpecItemDTO>> itemMap = new HashMap<>();
List<ItemDTO> items = storeSpecGoodsPriceMapper
@@ -154,7 +161,6 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
itemMap.put(itemDTO.getName(),listItem);
}
System.out.println(itemMap);
return itemMap;
}
@@ -75,7 +75,6 @@ public class OrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOrder>
QueryWrapper<StoreCart> cartQueryWrapper = new QueryWrapper<>();
cartQueryWrapper.eq("user_id",userId).in("goods_id", Arrays.asList(goddsArr));
List<StoreCart> storeCarts = storeCartMapper.selectList(cartQueryWrapper);
System.out.println("storeCarts:"+storeCarts);
if(storeCarts.isEmpty()){
throw new LightSecurityException("购物车空空如也");
}
+8 -2
View File
@@ -9,6 +9,12 @@ light-security:
- http-method: ANY
path: /shop/notify
expression: "anon()"
# - http-method: ANY
# path: /shop/index-list
# expression: "anon()"
# - http-method: ANY
# path: /shop/mall-lists
# expression: "anon()"
- http-method: get
path: /doc.html
expression: "anon()"
@@ -146,14 +152,14 @@ logging:
wx:
pay:
appId:
appId: wxa82b5b7fcb0ec161
mchId:
mchKey:
subAppId:
subMchId:
keyPath:
miniapp:
appid:
appid: wxa82b5b7fcb0ec161
secret:
token:
aesKey: