生成短信模板,增加基础类
parent
a6de7d2579
commit
110db65271
@ -0,0 +1,35 @@
|
||||
package me.zhengjie.base;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2021/4/14
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class OperatorBaseEntity {
|
||||
|
||||
@Column(name = "gmt_create")
|
||||
@ApiModelProperty(value = "生成时间")
|
||||
private Timestamp gmtCreate;
|
||||
|
||||
@Column(name = "gmt_modified")
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Timestamp gmtModified;
|
||||
|
||||
@Column(name = "operator")
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private String operator;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package me.zhengjie.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2021/4/14
|
||||
* 短信发送常量
|
||||
*/
|
||||
public class SmsConstant {
|
||||
/**
|
||||
* APP ID
|
||||
*/
|
||||
public static final String APP_ID = "app1";
|
||||
|
||||
public static final String FORMATE_TIMESTAMP = "yyyyMMddHHmmss";
|
||||
|
||||
/**
|
||||
* TOKEN
|
||||
*/
|
||||
public static final String TOKEN = "f625d0a23493cd8aeb8ada97da7a7b65";
|
||||
|
||||
|
||||
/**
|
||||
* 短信url
|
||||
*/
|
||||
public static final String SMS_LINK = "http://api.hzdaba.cn/v2/Accounts/baiyekeji_label/Sms/send";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.zhengjie.utils.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2021/4/14
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum StatusEnum {
|
||||
|
||||
|
||||
/** 成功*/
|
||||
SUCCESS(1,"成功"),
|
||||
|
||||
/** 进行中 */
|
||||
PROCESSING(0,"进行中"),
|
||||
|
||||
/** 审核未通过 */
|
||||
UNSUCCESSFUL(-1,"未成功");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import me.zhengjie.base.OperatorBaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name="tb_template")
|
||||
public class TbTemplate extends OperatorBaseEntity implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@NotNull(groups = BaseEntity.Update.class)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "template_name")
|
||||
@ApiModelProperty(value = "模板名称")
|
||||
private String templateName;
|
||||
|
||||
@Column(name = "template_status")
|
||||
@ApiModelProperty(value = "审核状态 0-申请中 1-申请通过 1-未通过")
|
||||
private Integer templateStatus;
|
||||
|
||||
@Column(name = "send_message")
|
||||
@ApiModelProperty(value = "发送的信息")
|
||||
private String sendMessage;
|
||||
|
||||
@Column(name = "audit_time")
|
||||
@ApiModelProperty(value = "审核时间")
|
||||
private Timestamp auditTime;
|
||||
|
||||
@Column(name = "last_update_time")
|
||||
@ApiModelProperty(value = "生成时间")
|
||||
private Timestamp lastUpdateTime;
|
||||
|
||||
@Column(name = "remark")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "reviewer")
|
||||
@ApiModelProperty(value = "审核人员")
|
||||
private String reviewer;
|
||||
|
||||
@Column(name = "rejected_msg")
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectedMsg;
|
||||
|
||||
|
||||
@Column(name = "link_url")
|
||||
@ApiModelProperty(value = "跳转链接")
|
||||
private String linkUrl;
|
||||
|
||||
public void copy(TbTemplate source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.repository;
|
||||
|
||||
|
||||
import me.zhengjie.modules.sms.domain.TbTemplate;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
public interface TbTemplateRepository extends JpaRepository<TbTemplate, Long>, JpaSpecificationExecutor<TbTemplate> {
|
||||
|
||||
/**
|
||||
* 根据名称查询
|
||||
* @param name 名称
|
||||
* @return /
|
||||
*/
|
||||
TbTemplate findByTemplateName(String name);
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
;
|
||||
import me.zhengjie.modules.sms.domain.TbTemplate;
|
||||
import me.zhengjie.modules.sms.service.TbTemplateService;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "TemplateController管理")
|
||||
@RequestMapping("/api/tbTemplate")
|
||||
public class TbTemplateController {
|
||||
|
||||
private final TbTemplateService tbTemplateService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbTemplate:list')")
|
||||
public void download(HttpServletResponse response, TbTemplateQueryCriteria criteria) throws IOException {
|
||||
tbTemplateService.download(tbTemplateService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询TemplateController")
|
||||
@ApiOperation("查询TemplateController")
|
||||
@PreAuthorize("@el.check('tbTemplate:list')")
|
||||
public ResponseEntity<Object> query(TbTemplateQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbTemplateService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Log("新增TemplateController")
|
||||
@ApiOperation("新增TemplateController")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('tbTemplate:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody TbTemplate resources){
|
||||
tbTemplateService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改TemplateController")
|
||||
@ApiOperation("修改TemplateController")
|
||||
@PreAuthorize("@el.check('tbTemplate:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody TbTemplate resources){
|
||||
tbTemplateService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除TemplateController")
|
||||
@ApiOperation("删除TemplateController")
|
||||
@PreAuthorize("@el.check('tbTemplate:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
tbTemplateService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Log("审核TemplateController")
|
||||
@ApiOperation("审核TemplateController")
|
||||
@PreAuthorize("@el.check('tbTemplate:review')")
|
||||
@PostMapping("/review")
|
||||
public ResponseEntity<Object> review(@Validated @RequestBody TbTemplate resources){
|
||||
tbTemplateService.review(resources);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.service;
|
||||
|
||||
|
||||
import me.zhengjie.modules.sms.domain.TbTemplate;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateDto;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务接口
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
public interface TbTemplateService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbTemplateQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbTemplateDto>
|
||||
*/
|
||||
List<TbTemplateDto> queryAll(TbTemplateQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbTemplateDto
|
||||
*/
|
||||
TbTemplateDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbTemplateDto
|
||||
*/
|
||||
void create(TbTemplate resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbTemplate resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbTemplateDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 平台审核
|
||||
* @param resources
|
||||
*/
|
||||
void review(TbTemplate resources);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@Data
|
||||
public class TbTemplateDto implements Serializable {
|
||||
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/** 模板名称 */
|
||||
private String templateName;
|
||||
|
||||
/** 审核状态 0-申请中 1-申请通过 1-未通过 */
|
||||
private Integer templateStatus;
|
||||
|
||||
/** 发送的信息 */
|
||||
private String sendMessage;
|
||||
|
||||
/** 审核时间 */
|
||||
private Timestamp auditTime;
|
||||
|
||||
/** 生成时间 */
|
||||
private Timestamp lastUpdateTime;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 审核人员 */
|
||||
private String reviewer;
|
||||
|
||||
/** 驳回原因 */
|
||||
private String rejectedMsg;
|
||||
|
||||
/** 生成时间 */
|
||||
private Timestamp gmtCreate;
|
||||
|
||||
/** 修改时间 */
|
||||
private Timestamp gmtModified;
|
||||
|
||||
/** 操作人 */
|
||||
private String operator;
|
||||
|
||||
/** 操作人 */
|
||||
private String linkUrl;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@Data
|
||||
public class TbTemplateQueryCriteria{
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.exception.EntityExistException;
|
||||
import me.zhengjie.modules.sms.domain.TbTemplate;
|
||||
import me.zhengjie.modules.sms.repository.TbTemplateRepository;
|
||||
import me.zhengjie.modules.sms.service.TbTemplateService;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateDto;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateQueryCriteria;
|
||||
import me.zhengjie.modules.sms.service.mapstruct.TbTemplateMapper;
|
||||
import me.zhengjie.utils.*;
|
||||
import me.zhengjie.utils.enums.StatusEnum;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务实现
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbTemplateServiceImpl implements TbTemplateService {
|
||||
|
||||
private final TbTemplateRepository tbTemplateRepository;
|
||||
private final TbTemplateMapper tbTemplateMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbTemplateQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbTemplate> page = tbTemplateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbTemplateMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbTemplateDto> queryAll(TbTemplateQueryCriteria criteria){
|
||||
return tbTemplateMapper.toDto(tbTemplateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbTemplateDto findById(Long id) {
|
||||
TbTemplate tbTemplate = tbTemplateRepository.findById(id).orElseGet(TbTemplate::new);
|
||||
ValidationUtil.isNull(tbTemplate.getId(),"TbTemplate","id",id);
|
||||
return tbTemplateMapper.toDto(tbTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(TbTemplate resources) {
|
||||
TbTemplate template = tbTemplateRepository.findByTemplateName(resources.getTemplateName());
|
||||
if(template != null){
|
||||
throw new EntityExistException(TbTemplate.class,"name",resources.getTemplateName());
|
||||
}
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
resources.setGmtModified(timestamp);
|
||||
resources.setGmtCreate(timestamp);
|
||||
resources.setOperator(SecurityUtils.getCurrentUser().getUsername());
|
||||
resources.setTemplateStatus(StatusEnum.PROCESSING.getValue());
|
||||
|
||||
tbTemplateRepository.save(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbTemplate resources) {
|
||||
TbTemplate tbTemplate = tbTemplateRepository.findById(resources.getId()).orElseGet(TbTemplate::new);
|
||||
ValidationUtil.isNull( tbTemplate.getId(),"TbTemplate","id",resources.getId());
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
tbTemplate.setReviewer(SecurityUtils.getCurrentUser().getUsername());
|
||||
tbTemplate.setAuditTime(timestamp);
|
||||
tbTemplate.setLastUpdateTime(timestamp);
|
||||
tbTemplate.copy(resources);
|
||||
tbTemplateRepository.save(tbTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
tbTemplateRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbTemplateDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbTemplateDto tbTemplate : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("模板名称", tbTemplate.getTemplateName());
|
||||
map.put("审核状态 0-申请中 1-申请通过 1-未通过", tbTemplate.getTemplateStatus());
|
||||
map.put("发送的信息", tbTemplate.getSendMessage());
|
||||
map.put("审核时间", tbTemplate.getAuditTime());
|
||||
map.put("最后修改时间", tbTemplate.getLastUpdateTime());
|
||||
map.put("备注", tbTemplate.getRemark());
|
||||
map.put("审核人员", tbTemplate.getReviewer());
|
||||
map.put("驳回原因", tbTemplate.getRejectedMsg());
|
||||
map.put("生成时间", tbTemplate.getGmtCreate());
|
||||
map.put("修改时间", tbTemplate.getGmtModified());
|
||||
map.put("操作人", tbTemplate.getOperator());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void review(TbTemplate resources) {
|
||||
TbTemplate tbTemplate = tbTemplateRepository.findById(resources.getId()).orElseGet(TbTemplate::new);
|
||||
ValidationUtil.isNull(tbTemplate.getId(),"TbTemplate","id",resources.getId());
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
tbTemplate.copy(resources);
|
||||
tbTemplate.setAuditTime(timestamp);
|
||||
tbTemplate.setLastUpdateTime(timestamp);
|
||||
tbTemplateRepository.save(tbTemplate);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.sms.service.mapstruct;
|
||||
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.sms.domain.TbTemplate;
|
||||
import me.zhengjie.modules.sms.service.dto.TbTemplateDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author Enzo
|
||||
* @date 2021-04-14
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbTemplateMapper extends BaseMapper<TbTemplateDto, TbTemplate> {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package me.zhengjie.modules.sms.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Enzo
|
||||
* @date : 2021/4/14
|
||||
*/
|
||||
@Data
|
||||
public class SendVo {
|
||||
@ApiModelProperty("手机号码集合")
|
||||
private List<String> phoneList;
|
||||
@ApiModelProperty("发送链接")
|
||||
private String linkUrl;
|
||||
@ApiModelProperty("模板id")
|
||||
private String sendMessage;
|
||||
}
|
Loading…
Reference in New Issue