feat(mall): 代码优化

master
waynaqua 1 year ago
parent 8dba83e2de
commit 5cfe58d100

@ -15,9 +15,9 @@ waynboot-mall是一套全部开源的微商城项目包含一个运营后台
技术上基于最新得Springboot3.0、jdk17整合了Redis、RabbitMQ、ElasticSearch等常用中间件
贴近生产环境实际经验开发而来不断完善、优化、改进中。
- [h5商城项目](https://gitee.com/wayn111/waynboot-mobile)
- [运营后台项目](https://gitee.com/wayn111/waynboot-admin)
- [后台接口项目](https://gitee.com/wayn111/waynboot-mall)
- [h5商城项目](https://github.com/wayn111/waynboot-mobile)
- [运营后台项目](https://github.com/wayn111/waynboot-admin)
- [后台接口项目](https://github.com/wayn111/waynboot-mall)
> 如果有任何使用问题欢迎提交Issue或加wx告知方便互相交流反馈 💘。最后喜欢的话麻烦给我个star

@ -1,82 +0,0 @@
package com.wayn.admin.framework.config;
import com.wayn.common.constant.Constants;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Parameters;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
/**
* ssh使
*/
@Slf4j
@Component
public class SSHProxyConfig {
public static final String localHost = "localhost";
private SSHClient client;
private final SSHProxyProperties sshProxyProperties;
public SSHProxyConfig(SSHProxyProperties sshProxyProperties) {
this.sshProxyProperties = sshProxyProperties;
}
@PostConstruct
public void connect() {
if (!sshProxyProperties.isEnabled()) {
return;
}
new Thread(() -> {
try {
log.info(Constants.LOG_PREFIX + "ssh connect");
client = new SSHClient();
client.addHostKeyVerifier(new PromiscuousVerifier());
client.connect(sshProxyProperties.getHost(), sshProxyProperties.getPost());
client.loadKnownHosts();
client.authPassword(sshProxyProperties.getUserName(), sshProxyProperties.getPassword());
final Parameters params
= new Parameters(localHost, sshProxyProperties.getLocalPort(),
sshProxyProperties.getRemoteHost(),
sshProxyProperties.getRemotePort());
final ServerSocket ss = new ServerSocket();
try (ss) {
ss.setReuseAddress(true);
ss.bind(new InetSocketAddress(params.getLocalHost(), params.getLocalPort()));
client.newLocalPortForwarder(params, ss).listen();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
client.disconnect();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}, "ssh-connect").start();
}
@PreDestroy
public void close() {
try {
if (client != null) {
log.info(Constants.LOG_PREFIX + "ssh disconnect");
client.disconnect();
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}

@ -1,24 +0,0 @@
package com.wayn.admin.framework.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "wayn.ssh-proxy")
public class SSHProxyProperties {
private boolean enabled;
private String host;
private Integer post;
private String userName;
private String password;
private Integer localPort;
private String remoteHost;
private Integer remotePort;
}

@ -1,18 +0,0 @@
package com.wayn.admin.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* websocket
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

@ -1,17 +0,0 @@
package com.wayn.common.annotation;
import com.wayn.common.enums.DataSourceEnum;
import java.lang.annotation.*;
/**
*
*/
@Inherited
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataSource {
DataSourceEnum value() default DataSourceEnum.MASTER;
}

@ -1,14 +0,0 @@
package com.wayn.common.annotation;
import java.lang.annotation.*;
/**
*
*/
@Inherited
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RepeatSubmit {
}

@ -1,8 +1,11 @@
package com.wayn.common.config;
import com.alipay.api.domain.BidDetailVO;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
@ConfigurationProperties(prefix = "wayn")
public class WaynConfig {
@ -33,6 +36,15 @@ public class WaynConfig {
*/
private static String mobileUrl;
/**
*
*/
private static BigDecimal freightLimit;
/**
*
*/
private static BigDecimal freightPrice;
public static String getUploadDir() {
return uploadDir;
}
@ -88,4 +100,20 @@ public class WaynConfig {
public void setMobileUrl(String mobileUrl) {
WaynConfig.mobileUrl = mobileUrl;
}
public static BigDecimal getFreightLimit() {
return freightLimit;
}
public void setFreightLimit(BigDecimal freightLimit) {
WaynConfig.freightLimit = freightLimit;
}
public static BigDecimal getFreightPrice() {
return freightPrice;
}
public void setFreightPrice(BigDecimal freightPrice) {
WaynConfig.freightPrice = freightPrice;
}
}

@ -82,15 +82,6 @@ public class Order extends ShopBaseEntity implements Serializable {
*/
private BigDecimal couponPrice;
/**
*
*/
private BigDecimal integralPrice;
/**
*
*/
private BigDecimal grouponPrice;
/**
* = goods_price + freight_price - coupon_price

@ -42,6 +42,7 @@ public enum ReturnCodeEnum {
ORDER_HAS_CREATED_ERROR(5011, "订单已经创建过了 "),
ORDER_USER_NOT_SAME_ERROR(5012, "订单用户和当前登陆用户不一致"),
// 用户错误
USER_NOT_EXISTS_ERROR(5101, "用户不存在"),
USER_TWO_PASSWORD_NOT_SAME_ERROR(5102, "两次密码输入不相符"),
USER_EMAIL_CODE_ERROR(5102, "邮箱验证码不正确"),
@ -51,18 +52,23 @@ public enum ReturnCodeEnum {
USER_OLD_PASSWORD_ERROR(5104, "旧密码错误"),
USER_NEW_OLD_PASSWORD_NOT_SAME_ERROR(5105, "新密码不能与旧密码相同"),
// 上传错误
UPLOAD_ERROR(5201, "上传图片失败"),
// 商品错误
GOODS_SPEC_ONLY_START_ONE_DEFAULT_SELECTED_ERROR(5301, "商品规格只能选择一个启用默认选中"),
GOODS_HAS_OFFSHELF_ERROR(5302, "商品已经下架"),
GOODS_STOCK_NOT_ENOUGH_ERROR(5303, "商品库存不足"),
// 部门错误
DEPT_HAS_SUB_DEPT_ERROR(5401, "存在下级部门,不允许删除"),
DEPT_HAS_USER_ERROR(5402, "部门存在用户,不允许删除"),
// 菜单错误
MENU_HAS_SUB_MENU_ERROR(5501, "存在子菜单,不允许删除"),
MENU_HAS_DISTRIBUTE_ERROR(5502, "菜单已分配,不允许删除"),
// 工具错误
TOOL_EMAIL_ERROR(5601, "邮件信息未配置完全,请先填写配置信息"),
TOOL_QINIU_NOT_EXISTS_ERROR(5602, "七牛云配置不存在"),
TOOL_QINIU_CONFIG_ERROR(5603, "七牛云配置错误"),

@ -1,5 +1,6 @@
package com.wayn.common.exception;
import com.wayn.common.enums.ReturnCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -23,6 +24,11 @@ public class BusinessException extends RuntimeException {
this.msg = msg;
}
public BusinessException(ReturnCodeEnum returnCodeEnum) {
this.code = returnCodeEnum.getCode();
this.msg = returnCodeEnum.getMsg();
}
public BusinessException(String message, Throwable cause) {
super(message, cause);
}

@ -4,6 +4,7 @@ package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.config.WaynConfig;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.Cart;
import com.wayn.mobile.api.service.ICartService;
@ -29,6 +30,8 @@ public class CartController extends BaseController {
private ICartService iCartService;
private WaynConfig waynConfig;
@GetMapping("list")
public R list() {
Long userId = MobileSecurityUtils.getUserId();
@ -73,11 +76,24 @@ public class CartController extends BaseController {
Long userId = MobileSecurityUtils.getUserId();
List<Cart> cartList = iCartService.list(new QueryWrapper<Cart>()
.eq("user_id", userId).eq("checked", true));
BigDecimal amount = new BigDecimal("0.00");
BigDecimal goodsAmount = BigDecimal.ZERO;
BigDecimal orderTotalAmount = BigDecimal.ZERO;
// 计算总价
for (Cart cart : cartList) {
amount = amount.add(cart.getPrice().multiply(new BigDecimal(cart.getNumber())));
goodsAmount = goodsAmount.add(cart.getPrice().multiply(new BigDecimal(cart.getNumber())));
}
// 根据订单商品总价计算运费满足条件例如88元则免运费否则需要支付运费例如8元
BigDecimal freightPrice = BigDecimal.ZERO;
if (goodsAmount.compareTo(WaynConfig.getFreightLimit()) < 0) {
freightPrice = WaynConfig.getFreightPrice();
}
return R.success().add("data", cartList).add("amount", amount);
orderTotalAmount = goodsAmount.add(freightPrice);
return R.success()
.add("data", cartList)
.add("freightPrice", freightPrice)
.add("goodsAmount", goodsAmount)
.add("orderTotalAmount", orderTotalAmount);
}
}

@ -18,11 +18,31 @@ public class HomeController extends BaseController {
private IHomeService IHomeService;
@PostMapping("index")
/**
*
*
* @return R
*/
@GetMapping("index")
public R index() {
return IHomeService.getHomeIndexDataCompletableFuture();
}
/**
*
*
* @return R
*/
@GetMapping("mallConfig")
public R mallConfig() {
return IHomeService.mallConfig();
}
/**
*
*
* @return R
*/
@GetMapping("goodsList")
public R getGoodsList() {
Page<Goods> page = getPage();

@ -1,39 +0,0 @@
package com.wayn.mobile.api.controller;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.util.R;
import com.wayn.mobile.api.service.ISeckillService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*
* @author wayn
* @since 2020-08-04
*/
@RestController
@AllArgsConstructor
@RequestMapping("seckill")
public class SeckillController extends BaseController {
private ISeckillService iSeckillService;
@GetMapping("update")
public R update(Long id) {
return iSeckillService.updateSec(id);
}
@GetMapping("update1")
public R update1(Long id) {
return iSeckillService.updateSec1(id);
}
@GetMapping("update2")
public R update2(Long id) {
return iSeckillService.updateSec2(id);
}
}

@ -1,57 +0,0 @@
package com.wayn.mobile.api.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
*
*
* @author wayn
* @since 2020-08-04
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Seckill implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "seckill_id", type = IdType.AUTO)
private Long seckillId;
/**
*
*/
private String name;
/**
*
*/
private Integer number;
/**
*
*/
private LocalDateTime startTime;
/**
*
*/
private LocalDateTime endTime;
/**
*
*/
private LocalDateTime createTime;
private Integer version;
}

@ -1,20 +0,0 @@
package com.wayn.mobile.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wayn.mobile.api.domain.Seckill;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
* @author wayn
* @since 2020-08-04
*/
public interface SeckillMapper extends BaseMapper<Seckill> {
boolean updateSec(@Param("id") Long id, @Param("newVersion") Integer newVersion, @Param("oldVersion") Integer oldVersion, @Param("newNum") Integer newNum);
boolean updateSec1(@Param("id") Long id, @Param("newNum") Integer newNum, @Param("oldNum") Integer oldNum);
boolean updateSec2(@Param("id") Long id);
}

@ -17,9 +17,16 @@ public interface IHomeService {
/**
*
*
* @param page
* @return r
*/
R listGoodsPage(Page<Goods> page);
/**
*
*
* @return r
*/
R mallConfig();
}

@ -1,35 +0,0 @@
package com.wayn.mobile.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.Seckill;
/**
*
*
* @author wayn
* @since 2020-08-04
*/
public interface ISeckillService extends IService<Seckill> {
/**
* 使
* @param id ID
* @return R
*/
R updateSec(Long id);
/**
* 使
* @param id ID
* @return R
*/
R updateSec1(Long id);
/**
* 使number - 1 > 0number1
* @param id ID
* @return R
*/
R updateSec2(Long id);
}

@ -3,6 +3,7 @@ package com.wayn.mobile.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.config.WaynConfig;
import com.wayn.common.constant.Constants;
import com.wayn.common.core.domain.shop.Banner;
import com.wayn.common.core.domain.shop.Diamond;
@ -106,4 +107,9 @@ public class IHomeServiceImpl implements IHomeService {
return R.success().add("data", goodsIPage.getRecords());
}
@Override
public R mallConfig() {
return R.success().add("freightLimit", WaynConfig.getFreightLimit());
}
}

@ -174,6 +174,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
LambdaQueryWrapper<Order> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Order::getOrderSn, orderSn);
Order order = getOne(queryWrapper);
if (order == null) {
throw new BusinessException(ReturnCodeEnum.ORDER_NOT_EXISTS_ERROR);
}
OrderDetailVO orderDetailVO = new OrderDetailVO();
MyBeanUtil.copyProperties(order, orderDetailVO);
orderDetailVO.setOrderStatusText(OrderUtil.orderStatusText(order));
@ -187,7 +190,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
}
@Override
public R asyncSubmit(OrderVO orderVO) throws Exception {
public R asyncSubmit(OrderVO orderVO) {
OrderDTO orderDTO = new OrderDTO();
MyBeanUtil.copyProperties(orderVO, orderDTO);
Long userId = orderDTO.getUserId();
@ -201,33 +204,31 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
checkedGoodsList = iCartService.listByIds(cartIdArr);
}
if (CollectionUtils.isEmpty(checkedGoodsList)) {
throw new BusinessException(ReturnCodeEnum.ORDER_SUBMIT_ERROR);
}
// 商品费用
BigDecimal checkedGoodsPrice = new BigDecimal("0.00");
BigDecimal checkedGoodsPrice = BigDecimal.ZERO;
for (Cart checkGoods : checkedGoodsList) {
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().multiply(new BigDecimal(checkGoods.getNumber())));
}
// 根据订单商品总价计算运费满足条件例如88元则免运费否则需要支付运费例如8元
BigDecimal freightPrice = new BigDecimal("0.00");
/*if (checkedGoodsPrice.compareTo(SystemConfig.getFreightLimit()) < 0) {
freightPrice = SystemConfig.getFreight();
}*/
// 可以使用的其他钱,例如用户积分
BigDecimal integralPrice = new BigDecimal("0.00");
BigDecimal freightPrice = BigDecimal.ZERO;
if (checkedGoodsPrice.compareTo(WaynConfig.getFreightLimit()) < 0) {
freightPrice = WaynConfig.getFreightPrice();
}
// 优惠卷抵扣费用
BigDecimal couponPrice = new BigDecimal("0.00");
// 团购抵扣费用
BigDecimal grouponPrice = new BigDecimal("0.00");
BigDecimal couponPrice = BigDecimal.ZERO;
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(BigDecimal.ZERO);
// 最终支付费用
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
String orderSn = orderSnGenUtil.generateOrderSn(userId);
BigDecimal actualPrice = orderTotalPrice;
String orderSn = orderSnGenUtil.generateOrderSn();
orderDTO.setOrderSn(orderSn);
// 异步下单
@ -300,24 +301,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
// 根据订单商品总价计算运费满足条件例如88元则免运费否则需要支付运费例如8元
BigDecimal freightPrice = new BigDecimal("0.00");
/*if (checkedGoodsPrice.compareTo(SystemConfig.getFreightLimit()) < 0) {
freightPrice = SystemConfig.getFreight();
}*/
// 可以使用的其他钱,例如用户积分
BigDecimal integralPrice = new BigDecimal("0.00");
if (checkedGoodsPrice.compareTo(WaynConfig.getFreightLimit()) < 0) {
freightPrice = WaynConfig.getFreightPrice();
}
// 优惠卷抵扣费用
BigDecimal couponPrice = new BigDecimal("0.00");
// 团购抵扣费用
BigDecimal grouponPrice = new BigDecimal("0.00");
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal("0.00"));
// 最终支付费用
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
BigDecimal actualPrice = orderTotalPrice;
// 组装订单数据
Order order = new Order();
@ -331,8 +326,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
order.setAddress(detailedAddress);
order.setFreightPrice(freightPrice);
order.setCouponPrice(couponPrice);
order.setGrouponPrice(grouponPrice);
order.setIntegralPrice(integralPrice);
order.setGoodsPrice(checkedGoodsPrice);
order.setOrderPrice(orderTotalPrice);
order.setActualPrice(actualPrice);
@ -651,7 +644,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
if (order == null) {
return R.error(ReturnCodeEnum.ORDER_NOT_EXISTS_ERROR);
}
// 检查这个订单是否已经处理过
if (!OrderUtil.isCreateStatus(order)) {
return R.error(ReturnCodeEnum.ORDER_HAS_CREATED_ERROR);

@ -1,75 +0,0 @@
package com.wayn.mobile.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.Seckill;
import com.wayn.mobile.api.mapper.SeckillMapper;
import com.wayn.mobile.api.service.ISeckillService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*
* @author wayn
* @since 2020-08-04
*/
@Service
@AllArgsConstructor
public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> implements ISeckillService {
private final AtomicInteger atomicInteger = new AtomicInteger(0);
private SeckillMapper seckillMapper;
/**
* 使
*
* @param id
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public R updateSec(Long id) {
Seckill seckill = getById(id);
if (seckill.getNumber() <= 0) {
return R.error();
}
Integer newNum = seckill.getNumber() - 1;
Integer oldVersion = seckill.getVersion();
Integer newVersion = seckill.getVersion() + 1;
System.out.println(Thread.currentThread().getName() + ":剩余库存:" + newNum);
boolean b = seckillMapper.updateSec(id, newVersion, oldVersion, newNum);
System.out.println("result:" + b);
int i = atomicInteger.incrementAndGet();
System.out.println("update count:" + i);
return R.result(b);
}
@Transactional(rollbackFor = Exception.class)
@Override
public R updateSec1(Long id) {
Seckill seckill = getById(id);
if (seckill.getNumber() <= 0) {
return R.error();
}
Integer oldNum = seckill.getNumber();
Integer newNum = seckill.getNumber() - 1;
System.out.println(Thread.currentThread().getName() + ":剩余库存:" + newNum);
boolean b = seckillMapper.updateSec1(id, newNum, oldNum);
System.out.println("result:" + b);
int i = atomicInteger.incrementAndGet();
System.out.println("update count:" + i);
return R.result(b);
}
@Transactional(rollbackFor = Exception.class)
@Override
public R updateSec2(Long id) {
boolean b = seckillMapper.updateSec2(id);
System.out.println("result:" + b);
return R.result(b);
}
}

@ -23,10 +23,9 @@ public class OrderSnGenUtil {
/**
* + ID +
*
* @param userId ID
* @return
*/
public String generateOrderSn(Long userId) {
public String generateOrderSn() {
long now = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
Integer orderSnIncrLimit = Constants.ORDER_SN_INCR_LIMIT;
Long incrKey = redisCache.luaIncrKey(CacheConstants.ORDER_SN_INCR_KEY, orderSnIncrLimit);

@ -14,14 +14,4 @@ public class MvcConfig implements WebMvcConfigurer {
registry.addResourceHandler("/upload/**").addResourceLocations("file:" + WaynConfig.getUploadDir() + "/");
}
//
// @Bean
// public ServletRegistrationBean dispatcherRegistration() {
// return new ServletRegistrationBean(dispatcherServlet());
// }
//
// @Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
// public DispatcherServlet dispatcherServlet() {
// return new WaynDispatcherServlet();
// }
}

@ -40,8 +40,7 @@ public class SecurityConfig {
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// cors启用
.cors(httpSecurityCorsConfigurer -> {
})
.cors(httpSecurityCorsConfigurer -> {})
// CSRF(跨站请求伪造)禁用因为不使用session
.csrf(AbstractHttpConfigurer::disable)
// 认证失败处理类
@ -50,22 +49,20 @@ public class SecurityConfig {
.sessionManagement(configurer -> configurer.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
// 过滤请求
.authorizeHttpRequests(
registry -> {
registry
.requestMatchers("favicon.ico", "/actuator/**", "/login", "/registry", "/sendEmailCode", "/test/**", "/seckill/**", "/captcha").anonymous()
.requestMatchers("/home/**", "/category/**", "/comment/**", "/goods/detail/**", "/cart/goodsCount", "/diamond/**").permitAll()
.requestMatchers("/upload/**").anonymous()
.requestMatchers("/common/download**").anonymous()
.requestMatchers("/doc.html").anonymous()
.requestMatchers("/swagger-ui/**").anonymous()
.requestMatchers("/swagger-resources/**").anonymous()
.requestMatchers("/webjars/**").anonymous()
.requestMatchers("/*/api-docs").anonymous()
.requestMatchers("/druid/**").anonymous()
.requestMatchers("/message/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();
}
registry -> registry
.requestMatchers("favicon.ico", "/actuator/**", "/login", "/registry", "/sendEmailCode", "/test/**", "/seckill/**", "/captcha").anonymous()
.requestMatchers("/home/**", "/category/**", "/comment/**", "/goods/detail/**", "/cart/goodsCount", "/diamond/**").permitAll()
.requestMatchers("/upload/**").anonymous()
.requestMatchers("/common/download**").anonymous()
.requestMatchers("/doc.html").anonymous()
.requestMatchers("/swagger-ui/**").anonymous()
.requestMatchers("/swagger-resources/**").anonymous()
.requestMatchers("/webjars/**").anonymous()
.requestMatchers("/*/api-docs").anonymous()
.requestMatchers("/druid/**").anonymous()
.requestMatchers("/message/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
)
.logout(configurer -> configurer.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
.headers(configurer -> configurer.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))

@ -20,10 +20,10 @@ import java.util.concurrent.ThreadPoolExecutor;
@Configuration
public class ThreadPoolConfig {
// 核心线程池大小
private final int corePoolSize = 20;
private final int corePoolSize = 5;
// 最大可创建的线程数
private final int maxPoolSize = 50;
private final int maxPoolSize = 10;
// 队列最大长度
private final int queueCapacity = 2000;

@ -28,7 +28,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
private TokenService tokenService;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {

@ -22,7 +22,7 @@ spring:
boot:
admin:
client:
url: http://127.0.0.1:89/boot-admin
url: http://localhost:89/boot-admin
# token配置
token:
@ -60,9 +60,11 @@ wayn:
name: wayn
version: 1.2.0
email: 166738430@qq.com
uploadDir: ${UPLOAD_DIR:D:/wayn/upload}
uploadDir: ${UPLOAD_DIR:D:/waynshop/upload}
adminUrl: http://localhost:81
mobileUrl: http://localhost:82
freightLimit: "88"
freightPrice: "10"
# wx支付配置
shop:

@ -16,8 +16,6 @@
<result column="goods_price" property="goodsPrice" />
<result column="freight_price" property="freightPrice" />
<result column="coupon_price" property="couponPrice" />
<result column="integral_price" property="integralPrice" />
<result column="groupon_price" property="grouponPrice" />
<result column="order_price" property="orderPrice" />
<result column="actual_price" property="actualPrice" />
<result column="pay_id" property="payId" />
@ -42,7 +40,7 @@
<sql id="selectOrderVo">
select id,
user_id, order_sn, order_status, aftersale_status, consignee, mobile, address, message,
goods_price, freight_price, coupon_price, integral_price, groupon_price, order_price,
goods_price, freight_price, coupon_price, order_price,
actual_price, pay_id, pay_time, ship_sn, ship_channel, ship_time, refund_amount, refund_type, pay_type,
refund_content, refund_time, confirm_time, comments, order_end_time, create_time, update_time, del_flag
from shop_order

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wayn.mobile.api.mapper.SeckillMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.wayn.mobile.api.domain.Seckill">
<id column="seckill_id" property="seckillId" />
<result column="name" property="name" />
<result column="number" property="number" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="create_time" property="createTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
seckill_id, name, number, start_time, end_time, create_time
</sql>
<update id="updateSec">
update seckill set number = #{newNum} , version = #{newVersion} where seckill_id = #{id} and version = #{oldVersion}
</update>
<update id="updateSec1">
update seckill set number = #{newNum} where seckill_id = #{id} and number = #{oldNum}
</update>
<update id="updateSec2">
update seckill set number = number - 1 where seckill_id = #{id} and number - 1 >= 0
</update>
</mapper>
Loading…
Cancel
Save