mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
refactor: 广告营销代码优化,优化广告横幅列表接口
This commit is contained in:
parent
9a955956fd
commit
b9a9f5392c
@ -18,5 +18,5 @@ public interface SmsAdvertMapper extends BaseMapper<SmsAdvert> {
|
|||||||
* @param queryParams
|
* @param queryParams
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SmsAdvert> listAdvertsPage(Page<SmsAdvert> page, AdvertPageQuery queryParams);
|
Page<SmsAdvert> listAdvertPages(Page<SmsAdvert> page, AdvertPageQuery queryParams);
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,20 @@ public class SmsAdvert extends BaseEntity {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
private String url;
|
/**
|
||||||
|
* 跳转URL
|
||||||
|
*/
|
||||||
|
private String redirectUrl;
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.youlai.mall.sms.pojo.entity.SmsAdvert;
|
import com.youlai.mall.sms.pojo.entity.SmsAdvert;
|
||||||
import com.youlai.mall.sms.pojo.query.AdvertPageQuery;
|
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> {
|
public interface SmsAdvertService extends IService<SmsAdvert> {
|
||||||
|
|
||||||
@ -13,5 +17,7 @@ public interface SmsAdvertService extends IService<SmsAdvert> {
|
|||||||
* @param queryParams
|
* @param queryParams
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Page<SmsAdvert> listAdvertsPage(AdvertPageQuery queryParams);
|
Page<AdvertPageVO> listAdvertPages(AdvertPageQuery queryParams);
|
||||||
|
|
||||||
|
List<AdBannerVO> listAdBanners();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package com.youlai.mall.sms.service.impl;
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.pojo.entity.SmsAdvert;
|
||||||
import com.youlai.mall.sms.mapper.SmsAdvertMapper;
|
import com.youlai.mall.sms.mapper.SmsAdvertMapper;
|
||||||
import com.youlai.mall.sms.pojo.query.AdvertPageQuery;
|
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 com.youlai.mall.sms.service.SmsAdvertService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,8 +23,11 @@ import java.util.List;
|
|||||||
* @date 2022/5/28
|
* @date 2022/5/28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class SmsAdvertServiceImpl extends ServiceImpl<SmsAdvertMapper, SmsAdvert> implements SmsAdvertService {
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<SmsAdvert> listAdvertsPage(AdvertPageQuery queryParams) {
|
public Page<AdvertPageVO> listAdvertPages(AdvertPageQuery queryParams) {
|
||||||
Page<SmsAdvert> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
|
Page<SmsAdvert> entities = this.baseMapper.listAdvertPages(new Page<>(queryParams.getPageNum(),
|
||||||
List<SmsAdvert> list = this.baseMapper.listAdvertsPage(page, queryParams);
|
queryParams.getPageSize()),
|
||||||
page.setRecords(list);
|
queryParams);
|
||||||
return page;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<mapper namespace="com.youlai.mall.sms.mapper.SmsAdvertMapper">
|
<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
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
|
@ -3,7 +3,7 @@ package com.youlai.auth.extension.mobile;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.youlai.auth.userdetails.member.MemberUserDetailsServiceImpl;
|
import com.youlai.auth.userdetails.member.MemberUserDetailsServiceImpl;
|
||||||
import com.youlai.common.constant.SecurityConstants;
|
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 com.youlai.mall.ums.api.MemberFeignClient;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
@ -39,7 +39,7 @@ public class SmsCodeAuthenticationProvider implements AuthenticationProvider {
|
|||||||
String correctCode = redisTemplate.opsForValue().get(codeKey);
|
String correctCode = redisTemplate.opsForValue().get(codeKey);
|
||||||
// 验证码比对
|
// 验证码比对
|
||||||
if (StrUtil.isBlank(correctCode) || !code.equals(correctCode)) {
|
if (StrUtil.isBlank(correctCode) || !code.equals(correctCode)) {
|
||||||
throw new BusinessException("验证码不正确");
|
throw new ApiException("验证码不正确");
|
||||||
}
|
}
|
||||||
// 比对成功删除缓存的验证码
|
// 比对成功删除缓存的验证码
|
||||||
redisTemplate.delete(codeKey);
|
redisTemplate.delete(codeKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user