- 添加 sign 和 template page 和查询功能

This commit is contained in:
sin 2019-05-19 17:05:40 +08:00
parent cc3c97d316
commit ee5eaccf27
10 changed files with 298 additions and 55 deletions

View File

@ -1,7 +1,11 @@
package cn.iocoder.mall.admin.api;
import cn.iocoder.mall.admin.api.bo.sms.SmsSignBO;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsSignBO;
import cn.iocoder.mall.admin.api.bo.sms.SmsTemplateBO;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsTemplateBO;
import cn.iocoder.mall.admin.api.dto.sms.PageQuerySmsSignDTO;
import cn.iocoder.mall.admin.api.dto.sms.PageQuerySmsTemplateDTO;
import java.util.List;
@ -13,7 +17,21 @@ import java.util.List;
*/
public interface SmsService {
/**
* 短信模板 - 分页
*
* @param queryDTO
* @return
*/
PageSmsSignBO pageSmsSign(PageQuerySmsSignDTO queryDTO);
/**
* 短信模板 - 分页
*
* @param queryDTO
* @return
*/
PageSmsTemplateBO pageSmsTemplate(PageQuerySmsTemplateDTO queryDTO);
/**
* 签名 - 创建

View File

@ -0,0 +1,57 @@
package cn.iocoder.mall.admin.api.bo.sms;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* sms page
*
* @author Sin
* @time 2019/5/19 4:23 PM
*/
@Data
@Accessors(chain = true)
public class PageSmsSignBO {
private Integer count;
private Long current;
private Long size;
private Long total;
private List<Sign> data;
@Data
@Accessors(chain = true)
public class Sign {
/**
* 编号
*/
private Integer id;
/**
* 签名id 这个是第三方的
*/
private String platformId;
/**
* 签名名称
*/
private String sign;
/**
* 审核状态
*
* - 1审核中
* - 2审核成功
* - 3审核失败
*/
private Integer applyStatus;
/**
* 审核信息
*/
private String applyMessage;
}
}

View File

@ -0,0 +1,95 @@
package cn.iocoder.mall.admin.api.bo.sms;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* sms page
*
* @author Sin
* @time 2019/5/19 4:23 PM
*/
@Data
@Accessors(chain = true)
public class PageSmsTemplateBO {
private Long total;
private Long current;
private Long size;
private List<Template> data;
@Data
@Accessors(chain = true)
public class Template {
/**
* 编号
*/
private Integer id;
/**
* 模板编号 (第三方的)
*/
private Integer smsSignId;
/**
* 短信签名 id
*/
private String platformId;
/**
* 短信模板
*/
private String template;
/**
* 审核状态
*
* 1审核中
* 2审核成功
* 3审核失败
*/
private Integer applyStatus;
/**
* 审核信息
*/
private String applyMessage;
///
/// 关联字段
/**
* 签名信息
*/
private Sign sign;
}
@Data
@Accessors(chain = true)
public class Sign {
/**
* 编号
*/
private Integer id;
/**
* 签名id 这个是第三方的
*/
private String platformId;
/**
* 签名名称
*/
private String sign;
/**
* 审核状态
*
* - 1审核中
* - 2审核成功
* - 3审核失败
*/
private Integer applyStatus;
/**
* 审核信息
*/
private String applyMessage;
}
}

View File

@ -1,53 +0,0 @@
package cn.iocoder.mall.admin.api.bo.sms;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
*
*
* @author Sin
* @time 2019/5/19 4:23 PM
*/
public class SmsPage implements IPage {
@Override
public List getRecords() {
return null;
}
@Override
public IPage setRecords(List records) {
return null;
}
@Override
public long getTotal() {
return 0;
}
@Override
public IPage setTotal(long total) {
return null;
}
@Override
public long getSize() {
return 0;
}
@Override
public IPage setSize(long size) {
return null;
}
@Override
public long getCurrent() {
return 0;
}
@Override
public IPage setCurrent(long current) {
return null;
}
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.mall.admin.api.dto.sms;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* page 短信模板 query
*
* @author Sin
* @time 2019/5/19 4:32 PM
*/
@Data
@Accessors(chain = true)
public class PageQuerySmsSignDTO implements Serializable {
private Integer pageSize;
private Integer pageCurrent;
private String sign;
private Integer applyStatus;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.mall.admin.api.dto.sms;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* page 短信模板 query
*
* @author Sin
* @time 2019/5/19 4:32 PM
*/
@Data
@Accessors(chain = true)
public class PageQuerySmsTemplateDTO implements Serializable {
private Long current;
private Long size;
private String id;
private Integer smsSignId;
private String template;
private String applyStatus;
}

View File

@ -1,11 +1,14 @@
package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsSignBO;
import cn.iocoder.mall.admin.api.bo.sms.SmsSignBO;
import cn.iocoder.mall.admin.dataobject.SmsSignDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 短信 签名
*
@ -19,4 +22,7 @@ public interface SmsSignConvert {
@Mappings({})
SmsSignBO convert(SmsSignDO smsSignDO);
@Mappings({})
List<PageSmsSignBO.Sign> convert(List<SmsSignDO> smsSignDOList);
}

View File

@ -1,11 +1,14 @@
package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsTemplateBO;
import cn.iocoder.mall.admin.api.bo.sms.SmsTemplateBO;
import cn.iocoder.mall.admin.dataobject.SmsTemplateDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 短信 template
*
@ -19,4 +22,7 @@ public interface SmsTemplateConvert {
@Mappings({})
SmsTemplateBO convert(SmsTemplateDO smsTemplateDO);
@Mappings({})
List<PageSmsTemplateBO.Template> convert(List<SmsTemplateDO> smsTemplateDO);
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.mall.admin.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
@ -22,7 +21,6 @@ public class SmsSignDO extends DeletableDO {
/**
* 编号
*/
@TableId("id")
private Integer id;
/**
* 签名id 这个是第三方的

View File

@ -5,8 +5,12 @@ import cn.iocoder.common.framework.exception.ServiceException;
import cn.iocoder.mall.admin.api.SmsPlatform;
import cn.iocoder.mall.admin.api.SmsService;
import cn.iocoder.mall.admin.api.bo.sms.SmsSignBO;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsSignBO;
import cn.iocoder.mall.admin.api.bo.sms.SmsTemplateBO;
import cn.iocoder.mall.admin.api.bo.sms.PageSmsTemplateBO;
import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum;
import cn.iocoder.mall.admin.api.dto.sms.PageQuerySmsSignDTO;
import cn.iocoder.mall.admin.api.dto.sms.PageQuerySmsTemplateDTO;
import cn.iocoder.mall.admin.convert.SmsSignConvert;
import cn.iocoder.mall.admin.convert.SmsTemplateConvert;
import cn.iocoder.mall.admin.dao.SmsSignMapper;
@ -15,10 +19,13 @@ import cn.iocoder.mall.admin.dataobject.SmsSignDO;
import cn.iocoder.mall.admin.dataobject.SmsTemplateDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
@ -44,6 +51,60 @@ public class SmsServiceImpl implements SmsService {
@Qualifier("smsYunPianPlatform")
private SmsPlatform smsPlatform;
@Override
public PageSmsSignBO pageSmsSign(PageQuerySmsSignDTO queryDTO) {
QueryWrapper<SmsSignDO> queryWrapper = new QueryWrapper<>();
if (queryDTO.getApplyStatus() != null) {
queryWrapper.eq("apply_status", queryDTO.getApplyStatus());
}
if (!StringUtils.isEmpty(queryDTO.getSign())) {
queryWrapper.like("sign", queryDTO.getSign());
}
Page<SmsSignDO> page = new Page<SmsSignDO>()
.setSize(queryDTO.getPageSize())
.setCurrent(queryDTO.getPageCurrent())
.setDesc("create_time");
IPage<SmsSignDO> signPage = smsSignMapper.selectPage(page, queryWrapper);
List<PageSmsSignBO.Sign> signList = SmsSignConvert.INSTANCE.convert(signPage.getRecords());
return new PageSmsSignBO()
.setData(signList)
.setCurrent(signPage.getCurrent())
.setSize(signPage.getSize())
.setTotal(signPage.getTotal());
}
@Override
public PageSmsTemplateBO pageSmsTemplate(PageQuerySmsTemplateDTO queryDTO) {
QueryWrapper<SmsTemplateDO> queryWrapper = new QueryWrapper<>();
if (queryDTO.getApplyStatus() != null) {
queryWrapper.eq("apply_status", queryDTO.getApplyStatus());
}
if (queryDTO.getSmsSignId() != null) {
queryWrapper.eq("sms_sign_id", queryDTO.getSmsSignId());
}
if (!StringUtils.isEmpty(queryDTO.getTemplate())) {
queryWrapper.like("template", queryDTO.getTemplate());
}
Page<SmsTemplateDO> page = new Page<SmsTemplateDO>()
.setSize(queryDTO.getSize())
.setCurrent(queryDTO.getCurrent())
.setDesc("create_time");
IPage<SmsTemplateDO> signPage = smsTemplateMapper.selectPage(page, queryWrapper);
List<PageSmsTemplateBO.Template> templateList
= SmsTemplateConvert.INSTANCE.convert(signPage.getRecords());
return new PageSmsTemplateBO()
.setData(templateList)
.setCurrent(signPage.getCurrent())
.setSize(signPage.getSize())
.setTotal(signPage.getTotal());
}
@Override
@Transactional
public void createSign(String sign) {