This commit is contained in:
Ray.Hao 2024-08-01 18:47:05 +08:00
commit 0356f1b60e
16 changed files with 119 additions and 84 deletions

View File

@ -10,9 +10,12 @@ use oauth2_server;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- 2.1 oauth2_authorization 令牌发放记录表
-- ----------------------------
DROP TABLE IF EXISTS oauth2_authorization;
CREATE TABLE oauth2_authorization (
id varchar(100) NOT NULL,
registered_client_id varchar(100) NOT NULL,
@ -22,30 +25,30 @@ CREATE TABLE oauth2_authorization (
attributes blob DEFAULT NULL,
state varchar(500) DEFAULT NULL,
authorization_code_value blob DEFAULT NULL,
authorization_code_issued_at timestamp DEFAULT NULL,
authorization_code_expires_at timestamp DEFAULT NULL,
authorization_code_issued_at datetime DEFAULT NULL,
authorization_code_expires_at datetime DEFAULT NULL,
authorization_code_metadata blob DEFAULT NULL,
access_token_value blob DEFAULT NULL,
access_token_issued_at timestamp DEFAULT NULL,
access_token_expires_at timestamp DEFAULT NULL,
access_token_issued_at datetime DEFAULT NULL,
access_token_expires_at datetime DEFAULT NULL,
access_token_metadata blob DEFAULT NULL,
access_token_type varchar(100) DEFAULT NULL,
access_token_scopes varchar(1000) DEFAULT NULL,
oidc_id_token_value blob DEFAULT NULL,
oidc_id_token_issued_at timestamp DEFAULT NULL,
oidc_id_token_expires_at timestamp DEFAULT NULL,
oidc_id_token_issued_at datetime DEFAULT NULL,
oidc_id_token_expires_at datetime DEFAULT NULL,
oidc_id_token_metadata blob DEFAULT NULL,
refresh_token_value blob DEFAULT NULL,
refresh_token_issued_at timestamp DEFAULT NULL,
refresh_token_expires_at timestamp DEFAULT NULL,
refresh_token_issued_at datetime DEFAULT NULL,
refresh_token_expires_at datetime DEFAULT NULL,
refresh_token_metadata blob DEFAULT NULL,
user_code_value blob DEFAULT NULL,
user_code_issued_at timestamp DEFAULT NULL,
user_code_expires_at timestamp DEFAULT NULL,
user_code_issued_at datetime DEFAULT NULL,
user_code_expires_at datetime DEFAULT NULL,
user_code_metadata blob DEFAULT NULL,
device_code_value blob DEFAULT NULL,
device_code_issued_at timestamp DEFAULT NULL,
device_code_expires_at timestamp DEFAULT NULL,
device_code_issued_at datetime DEFAULT NULL,
device_code_expires_at datetime DEFAULT NULL,
device_code_metadata blob DEFAULT NULL,
PRIMARY KEY (id)
);
@ -53,6 +56,7 @@ CREATE TABLE oauth2_authorization (
-- ----------------------------
-- 2.2 oauth2_authorization_consent 授权记录表
-- ----------------------------
DROP TABLE IF EXISTS oauth2_authorization_consent;
CREATE TABLE oauth2_authorization_consent (
registered_client_id varchar(100) NOT NULL,
principal_name varchar(200) NOT NULL,
@ -63,12 +67,13 @@ CREATE TABLE oauth2_authorization_consent (
-- ----------------------------
-- 2.3 oauth2-registered-client OAuth2 客户端信息表
-- ----------------------------
DROP TABLE IF EXISTS oauth2_registered_client;
CREATE TABLE oauth2_registered_client (
id varchar(100) NOT NULL,
client_id varchar(100) NOT NULL,
client_id_issued_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
client_id_issued_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
client_secret varchar(200) DEFAULT NULL,
client_secret_expires_at timestamp DEFAULT NULL,
client_secret_expires_at datetime DEFAULT NULL,
client_name varchar(200) NOT NULL,
client_authentication_methods varchar(1000) NOT NULL,
authorization_grant_types varchar(1000) NOT NULL,

View File

@ -2,7 +2,7 @@ package com.youlai.mall.oms.controller.app;
import com.youlai.common.result.Result;
import com.youlai.common.security.util.SecurityUtils;
import com.youlai.mall.oms.model.dto.CartItemDTO;
import com.youlai.mall.oms.model.dto.CartItemDto;
import com.youlai.mall.oms.service.app.CartService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
@ -30,7 +30,7 @@ public class CartController {
@Operation(summary = "查询购物车")
@GetMapping
public <T> Result<T> getCart() {
List<CartItemDTO> result = cartService.listCartItems(SecurityUtils.getMemberId());
List<CartItemDto> result = cartService.listCartItems(SecurityUtils.getMemberId());
return Result.success((T) result);
}
@ -52,7 +52,7 @@ public class CartController {
@PutMapping("/skuId/{skuId}")
public <T> Result<T> updateCartItem(
@PathVariable Long skuId,
@RequestBody CartItemDTO cartItem
@RequestBody CartItemDto cartItem
) {
cartItem.setSkuId(skuId);
boolean result = cartService.updateCartItem(cartItem);

View File

@ -1,7 +1,7 @@
package com.youlai.mall.oms.converter;
import com.youlai.mall.oms.model.dto.CartItemDTO;
import com.youlai.mall.oms.model.dto.CartItemDto;
import com.youlai.mall.pms.model.dto.SkuInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -19,6 +19,6 @@ public interface CartConverter {
@Mappings({
@Mapping(target = "skuId", source = "id"),
})
CartItemDTO sku2CartItem(SkuInfoDTO skuInfo);
CartItemDto sku2CartItem(SkuInfoDTO skuInfo);
}

View File

@ -0,0 +1,30 @@
package com.youlai.mall.oms.model.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 购物车商品项
*
* @author Ray Hao
* @since 0.0.1
*/
@Data
public class CartItemDto implements Serializable {
/**
* 商品库存ID
*/
private Long skuId;
/**
* 商品数量
*/
private Integer count;
/**
* 是否选中
*/
private Boolean checked;
}

View File

@ -3,12 +3,16 @@ package com.youlai.mall.oms.model.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Set;
/**
* 购物车商品传输层实体
* 购物车商品项
*
* @author Ray Hao
* @since 0.0.1
*/
@Data
public class CartItemDTO implements Serializable {
public class CartItemVo implements Serializable {
/**
* 商品库存ID
@ -16,48 +20,38 @@ public class CartItemDTO implements Serializable {
private Long skuId;
/**
* 商品库存名称
* 商品名称
*/
private String skuName;
private String spuName;
/**
* 商品编码
* 规格集合
*/
private String skuSn;
private Set<String> specs;
/**
* 商品图片
*/
private String picUrl;
private String imageUrl;
/**
* 商品数量
* 加购数量·
*/
private Integer count;
/**
* 加入购物车时价格因会变动不能作为订单计算因子订单提交时需验价
* 商品价格
*/
private Long price;
/**
* 优惠券金额
*/
private Long coupon;
/**
* 是否选中
*/
private Boolean checked;
/**
* 商品库存数量页面控制能选择最大数量
* 商品库存
*/
private Integer stock;
/**
* 商品名称
*/
private String spuName;
}

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.service.app;
import com.youlai.mall.oms.model.dto.CartItemDTO;
import com.youlai.mall.oms.model.dto.CartItemDto;
import java.util.List;
@ -12,13 +12,13 @@ import java.util.List;
*/
public interface CartService {
List<CartItemDTO> listCartItems(Long memberId);
List<CartItemDto> listCartItems(Long memberId);
boolean deleteCart();
boolean addCartItem(Long skuId);
boolean updateCartItem(CartItemDTO cartItem);
boolean updateCartItem(CartItemDto cartItem);
boolean removeCartItem(Long skuId);

View File

@ -5,7 +5,7 @@ import com.youlai.common.security.util.SecurityUtils;
import com.youlai.common.web.exception.BizException;
import com.youlai.mall.oms.constant.OrderConstants;
import com.youlai.mall.oms.converter.CartConverter;
import com.youlai.mall.oms.model.dto.CartItemDTO;
import com.youlai.mall.oms.model.dto.CartItemDto;
import com.youlai.mall.oms.service.app.CartService;
import com.youlai.mall.pms.api.SkuFeignClient;
import com.youlai.mall.pms.model.dto.SkuInfoDTO;
@ -39,10 +39,10 @@ public class CartServiceImpl implements CartService {
private final CartConverter cartConverter;
@Override
public List<CartItemDTO> listCartItems(Long memberId) {
public List<CartItemDto> listCartItems(Long memberId) {
if (memberId != null) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
List<CartItemDTO> cartItems = cartHashOperations.values();
List<CartItemDto> cartItems = cartHashOperations.values();
return cartItems;
}
return Collections.EMPTY_LIST;
@ -64,10 +64,10 @@ public class CartServiceImpl implements CartService {
@Override
public boolean addCartItem(Long skuId) {
Long memberId = SecurityUtils.getMemberId();
BoundHashOperations<String, String, CartItemDTO> cartHashOperations = getCartHashOperations(memberId);
BoundHashOperations<String, String, CartItemDto> cartHashOperations = getCartHashOperations(memberId);
String hKey = String.valueOf(skuId);
CartItemDTO cartItem = cartHashOperations.get(hKey);
CartItemDto cartItem = cartHashOperations.get(hKey);
if (cartItem != null) {
// 购物车已存在该商品更新商品数量
@ -90,7 +90,7 @@ public class CartServiceImpl implements CartService {
* 更新购物车总商品数量选中状态
*/
@Override
public boolean updateCartItem(CartItemDTO cartItem) {
public boolean updateCartItem(CartItemDto cartItem) {
Long memberId;
try {
memberId = SecurityUtils.getMemberId();
@ -100,7 +100,7 @@ public class CartServiceImpl implements CartService {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
String hKey = cartItem.getSkuId() + "";
if (cartHashOperations.get(hKey) != null) {
CartItemDTO cacheCartItem = (CartItemDTO) cartHashOperations.get(hKey);
CartItemDto cacheCartItem = (CartItemDto) cartHashOperations.get(hKey);
if (cartItem.getChecked() != null) {
cacheCartItem.setChecked(cartItem.getChecked());
}
@ -143,7 +143,7 @@ public class CartServiceImpl implements CartService {
}
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
for (Object value : cartHashOperations.values()) {
CartItemDTO cartItem = (CartItemDTO) value;
CartItemDto cartItem = (CartItemDto) value;
cartItem.setChecked(checked);
String hKey = cartItem.getSkuId() + "";
cartHashOperations.put(hKey, cartItem);
@ -165,7 +165,7 @@ public class CartServiceImpl implements CartService {
}
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
for (Object value : cartHashOperations.values()) {
CartItemDTO cartItem = (CartItemDTO) value;
CartItemDto cartItem = (CartItemDto) value;
if (cartItem.getChecked()) {
cartHashOperations.delete(cartItem.getSkuId() + "");
}

View File

@ -31,7 +31,7 @@ import com.youlai.mall.oms.enums.OrderStatusEnum;
import com.youlai.mall.oms.enums.PaymentMethodEnum;
import com.youlai.mall.oms.mapper.OrderMapper;
import com.youlai.mall.oms.model.bo.OrderBO;
import com.youlai.mall.oms.model.dto.CartItemDTO;
import com.youlai.mall.oms.model.dto.CartItemDto;
import com.youlai.mall.oms.model.dto.OrderItemDTO;
import com.youlai.mall.oms.model.entity.OmsOrder;
import com.youlai.mall.oms.model.entity.OmsOrderItem;
@ -461,9 +461,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
orderItemDTO.setQuantity(1); // 直接购买商品的数量为1
orderItems.add(orderItemDTO);
} else { // 购物车结算
List<CartItemDTO> cartItems = cartService.listCartItems(memberId);
List<CartItemDto> cartItems = cartService.listCartItems(memberId);
orderItems = cartItems.stream()
.filter(CartItemDTO::getChecked)
.filter(CartItemDto::getChecked)
.map(cartItem -> {
OrderItemDTO orderItemDTO = new OrderItemDTO();
BeanUtil.copyProperties(cartItem, orderItemDTO);

View File

@ -1,7 +1,7 @@
package com.youlai.mall.sms.controller.app;
import com.youlai.common.result.Result;
import com.youlai.mall.sms.model.vo.AdBannerVO;
import com.youlai.mall.sms.model.vo.BannerVO;
import com.youlai.mall.sms.service.SmsAdvertService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
@ -21,10 +21,10 @@ import java.util.List;
public class AdvertController {
private SmsAdvertService smsAdvertService;
@Operation(summary= "广告横幅列表")
@Operation(summary= "APP首页广告横幅列表")
@GetMapping("/banners")
public Result<List<AdBannerVO>> listAdBanners() {
List<AdBannerVO> list = smsAdvertService.listAdBanners();
public Result<List<BannerVO>> getBannerList() {
List<BannerVO> list = smsAdvertService.getBannerList();
return Result.success(list);
}
}

View File

@ -3,7 +3,7 @@ package com.youlai.mall.sms.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.mall.sms.model.entity.SmsAdvert;
import com.youlai.mall.sms.model.vo.AdBannerVO;
import com.youlai.mall.sms.model.vo.BannerVO;
import com.youlai.mall.sms.model.vo.AdvertPageVO;
import org.mapstruct.Mapper;
@ -22,7 +22,7 @@ public interface AdvertConverter {
Page<AdvertPageVO> entity2PageVo(Page<SmsAdvert> po);
AdBannerVO entity2BannerVo(SmsAdvert entity);
BannerVO entity2BannerVo(SmsAdvert entity);
List<AdBannerVO> entity2BannerVo(List<SmsAdvert> entities);
List<BannerVO> entity2BannerVo(List<SmsAdvert> entities);
}

View File

@ -16,10 +16,10 @@ public class SmsAdvert extends BaseEntity {
private String title;
private String picUrl;
private String imageUrl;
@JsonFormat( pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date beginTime;
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;

View File

@ -3,15 +3,15 @@ package com.youlai.mall.sms.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "广告横幅对象")
@Schema(description = "横幅视图对象")
@Data
public class AdBannerVO {
public class BannerVO {
@Schema(description="广告标题")
private String title;
@Schema(description="横幅图片URL")
private String picUrl;
private String imageUrl;
@Schema(description="跳转URL")
private String redirectUrl;

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.sms.model.entity.SmsAdvert;
import com.youlai.mall.sms.model.query.AdvertPageQuery;
import com.youlai.mall.sms.model.vo.AdBannerVO;
import com.youlai.mall.sms.model.vo.BannerVO;
import com.youlai.mall.sms.model.vo.AdvertPageVO;
import java.util.List;
@ -19,5 +19,5 @@ public interface SmsAdvertService extends IService<SmsAdvert> {
*/
Page<AdvertPageVO> getAdvertPage(AdvertPageQuery queryParams);
List<AdBannerVO> listAdBanners();
List<BannerVO> getBannerList();
}

View File

@ -8,7 +8,7 @@ import com.youlai.mall.sms.converter.AdvertConverter;
import com.youlai.mall.sms.model.entity.SmsAdvert;
import com.youlai.mall.sms.mapper.SmsAdvertMapper;
import com.youlai.mall.sms.model.query.AdvertPageQuery;
import com.youlai.mall.sms.model.vo.AdBannerVO;
import com.youlai.mall.sms.model.vo.BannerVO;
import com.youlai.mall.sms.model.vo.AdvertPageVO;
import com.youlai.mall.sms.service.SmsAdvertService;
import lombok.RequiredArgsConstructor;
@ -19,7 +19,7 @@ import java.util.List;
/**
* 广告业务实现类
*
* @author haoxr
* @author Ray Hao
* @since 2022/5/28
*/
@Service
@ -31,33 +31,27 @@ public class SmsAdvertServiceImpl extends ServiceImpl<SmsAdvertMapper, SmsAdvert
/**
* 广告分页列表
*
* @param queryParams
* @return
* @param queryParams 查询参数
* @return 广告分页列表
*/
@Override
public Page<AdvertPageVO> getAdvertPage(AdvertPageQuery queryParams) {
Page<SmsAdvert> entities = this.baseMapper.getAdvertPage(new Page<>(queryParams.getPageNum(),
Page<SmsAdvert> page = this.baseMapper.getAdvertPage(new Page<>(queryParams.getPageNum(),
queryParams.getPageSize()),
queryParams);
Page<AdvertPageVO> advertVOPage = advertConverter.entity2PageVo(entities);
return advertVOPage;
return advertConverter.entity2PageVo(page);
}
/**
* 广告横幅列表对象
*
* @return
* 获取广告横幅列表
*/
@Override
public List<AdBannerVO> listAdBanners() {
public List<BannerVO> getBannerList() {
List<SmsAdvert> entities = this.list(new LambdaQueryWrapper<SmsAdvert>().
eq(SmsAdvert::getStatus, StatusEnum.ENABLE.getValue())
.select(SmsAdvert::getTitle, SmsAdvert::getPicUrl, SmsAdvert::getRedirectUrl)
.select(SmsAdvert::getTitle, SmsAdvert::getImageUrl, SmsAdvert::getRedirectUrl)
);
List<AdBannerVO> list = advertConverter.entity2BannerVo(entities);
return list;
return advertConverter.entity2BannerVo(entities);
}
}

View File

@ -12,6 +12,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
@ -38,6 +39,7 @@ import java.util.List;
@ConfigurationProperties(prefix = "security")
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
@RequiredArgsConstructor
@Slf4j
public class ResourceServerConfig {

View File

@ -140,4 +140,14 @@ public class SysDictController {
return Result.judge(result);
}
@Operation(summary = "获取字典类型的数据项")
@GetMapping("/types/{typeCode}/items")
public Result<List<Option>> listDictTypeItems(
@Parameter(description ="字典类型编码") @PathVariable String typeCode
) {
List<Option> list = dictTypeService.listDictItemsByTypeCode(typeCode);
return Result.success(list);
}
}