refactor: 广告营销代码优化,优化广告横幅列表接口

This commit is contained in:
haoxr 2022-11-14 00:29:55 +08:00
parent 9a955956fd
commit b9a9f5392c
6 changed files with 54 additions and 11 deletions

View File

@ -18,5 +18,5 @@ public interface SmsAdvertMapper extends BaseMapper<SmsAdvert> {
* @param queryParams
* @return
*/
List<SmsAdvert> listAdvertsPage(Page<SmsAdvert> page, AdvertPageQuery queryParams);
Page<SmsAdvert> listAdvertPages(Page<SmsAdvert> page, AdvertPageQuery queryParams);
}

View File

@ -24,11 +24,20 @@ public class SmsAdvert extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;
/**
* 状态
*/
private Integer status;
/**
* 排序
*/
private Integer sort;
private String url;
/**
* 跳转URL
*/
private String redirectUrl;
private String remark;

View File

@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.mall.sms.pojo.entity.SmsAdvert;
import com.youlai.mall.sms.pojo.query.AdvertPageQuery;
import com.youlai.mall.sms.pojo.vo.AdBannerVO;
import com.youlai.mall.sms.pojo.vo.AdvertPageVO;
import java.util.List;
public interface SmsAdvertService extends IService<SmsAdvert> {
@ -13,5 +17,7 @@ public interface SmsAdvertService extends IService<SmsAdvert> {
* @param queryParams
* @return
*/
Page<SmsAdvert> listAdvertsPage(AdvertPageQuery queryParams);
Page<AdvertPageVO> listAdvertPages(AdvertPageQuery queryParams);
List<AdBannerVO> listAdBanners();
}

View File

@ -1,11 +1,17 @@
package com.youlai.mall.sms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.enums.StatusEnum;
import com.youlai.mall.sms.converter.AdvertConverter;
import com.youlai.mall.sms.pojo.entity.SmsAdvert;
import com.youlai.mall.sms.mapper.SmsAdvertMapper;
import com.youlai.mall.sms.pojo.query.AdvertPageQuery;
import com.youlai.mall.sms.pojo.vo.AdBannerVO;
import com.youlai.mall.sms.pojo.vo.AdvertPageVO;
import com.youlai.mall.sms.service.SmsAdvertService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@ -17,8 +23,11 @@ import java.util.List;
* @date 2022/5/28
*/
@Service
@RequiredArgsConstructor
public class SmsAdvertServiceImpl extends ServiceImpl<SmsAdvertMapper, SmsAdvert> implements SmsAdvertService {
private final AdvertConverter advertConverter;
/**
* 广告分页列表
*
@ -26,10 +35,29 @@ public class SmsAdvertServiceImpl extends ServiceImpl<SmsAdvertMapper, SmsAdvert
* @return
*/
@Override
public Page<SmsAdvert> listAdvertsPage(AdvertPageQuery queryParams) {
Page<SmsAdvert> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
List<SmsAdvert> list = this.baseMapper.listAdvertsPage(page, queryParams);
page.setRecords(list);
return page;
public Page<AdvertPageVO> listAdvertPages(AdvertPageQuery queryParams) {
Page<SmsAdvert> entities = this.baseMapper.listAdvertPages(new Page<>(queryParams.getPageNum(),
queryParams.getPageSize()),
queryParams);
Page<AdvertPageVO> advertVOPage = advertConverter.entity2PageVo(entities);
return advertVOPage;
}
/**
* 广告横幅列表对象
*
* @return
*/
@Override
public List<AdBannerVO> listAdBanners() {
List<SmsAdvert> entities = this.list(new LambdaQueryWrapper<SmsAdvert>().
eq(SmsAdvert::getStatus, StatusEnum.ENABLE.getValue())
.select(SmsAdvert::getTitle)
);
List<AdBannerVO> list = advertConverter.entity2BannerVo(entities);
return list;
}
}

View File

@ -5,7 +5,7 @@
<mapper namespace="com.youlai.mall.sms.mapper.SmsAdvertMapper">
<!-- 广告分页列表 -->
<select id="listAdvertsPage" resultType="com.youlai.mall.sms.pojo.entity.SmsAdvert">
<select id="listAdvertPages" resultType="com.youlai.mall.sms.pojo.entity.SmsAdvert">
SELECT
*
FROM

View File

@ -3,7 +3,7 @@ package com.youlai.auth.extension.mobile;
import cn.hutool.core.util.StrUtil;
import com.youlai.auth.userdetails.member.MemberUserDetailsServiceImpl;
import com.youlai.common.constant.SecurityConstants;
import com.youlai.common.web.exception.BusinessException;
import com.youlai.common.web.exception.ApiException;
import com.youlai.mall.ums.api.MemberFeignClient;
import lombok.Data;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -39,7 +39,7 @@ public class SmsCodeAuthenticationProvider implements AuthenticationProvider {
String correctCode = redisTemplate.opsForValue().get(codeKey);
// 验证码比对
if (StrUtil.isBlank(correctCode) || !code.equals(correctCode)) {
throw new BusinessException("验证码不正确");
throw new ApiException("验证码不正确");
}
// 比对成功删除缓存的验证码
redisTemplate.delete(codeKey);