短信-后台-page
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.accompany.admin.service.sms;
|
||||
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.common.model.PageReq;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.sms.mapper.SmsRecordMapper;
|
||||
import com.accompany.sms.model.SmsRecord;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SmsRecordAdminService extends BaseService {
|
||||
|
||||
@Autowired
|
||||
private SmsRecordMapper smsRecordMapper;
|
||||
|
||||
public Page<SmsRecord> page(PageReq pageReq, String phone){
|
||||
Page<SmsRecord> page = new Page<>(pageReq.getPage(), pageReq.getPageSize());
|
||||
LambdaQueryWrapper<SmsRecord> queryWrapper = Wrappers.lambdaQuery(SmsRecord.class)
|
||||
.likeLeft(StringUtils.isNotBlank(phone), SmsRecord::getPhone, phone);
|
||||
smsRecordMapper.selectPage(page, queryWrapper);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -2,19 +2,21 @@ package com.accompany.admin.controller.sms;
|
||||
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.sms.OperationSmsAdminService;
|
||||
import com.accompany.admin.service.sms.SmsRecordAdminService;
|
||||
import com.accompany.admin.vo.OperationSmsRecordVo;
|
||||
import com.accompany.common.model.PageReq;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.sms.model.SmsRecord;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -22,104 +24,16 @@ import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/sms")
|
||||
@RequestMapping("/admin/smsRecord")
|
||||
public class SmsRecordAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private OperationSmsAdminService operationSmsAdminService;
|
||||
private SmsRecordAdminService smsRecordAdminService;
|
||||
|
||||
|
||||
/**
|
||||
* 上传Excel并插入到数据库
|
||||
* @param templateId
|
||||
* @param uploadFile
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
|
||||
public BusiResult uploadFile(Integer templateId,MultipartFile uploadFile) throws Exception{
|
||||
|
||||
Integer adminId = getAdminId();
|
||||
String fileName = uploadFile.getOriginalFilename();
|
||||
|
||||
if(!fileName.contains(".xls")&&fileName.contains(".xlsx")){
|
||||
return new BusiResult(BusiStatus.FILE_FORMAT_ERROR);
|
||||
}
|
||||
InputStream fileInputStream = uploadFile.getInputStream();
|
||||
Workbook workbook = WorkbookFactory.create(fileInputStream);
|
||||
//获取第一个sheet页
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
return operationSmsAdminService.insertFileDate(templateId,sheet,adminId);
|
||||
@GetMapping("/page")
|
||||
public BusiResult<PageResult<SmsRecord>> page(PageReq pageReq, String phone) {
|
||||
Page<SmsRecord> pageInfo = smsRecordAdminService.page(pageReq, phone);
|
||||
return BusiResult.success(new PageResult<>(pageInfo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取短信模板列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getSmsTemp",method = RequestMethod.GET)
|
||||
public BusiResult getSmsTemplate(){
|
||||
return new BusiResult(BusiStatus.SUCCESS,operationSmsAdminService.getSmsTemplate());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list",method = RequestMethod.GET)
|
||||
public void getList(Long erbanNo,Integer templateId,Integer sendStatus,String createTime,String updateTime,
|
||||
@RequestParam(defaultValue = "1")Integer page,
|
||||
@RequestParam(defaultValue = "20")Integer pageSize){
|
||||
PageInfo<OperationSmsRecordVo> pageInfo = operationSmsAdminService.getList(erbanNo,templateId,sendStatus,
|
||||
createTime, updateTime,page,pageSize);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("total", pageInfo.getTotal());
|
||||
jsonObject.put("rows", pageInfo.getList());
|
||||
writeJson(jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询条件批量发送短信
|
||||
* @param erbanNo
|
||||
* @param templateId
|
||||
* @param sendStatus
|
||||
* @param createTime
|
||||
* @param updateTime
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/query/send",method = RequestMethod.POST)
|
||||
public BusiResult batchSendByQuery(Long erbanNo,Integer templateId,Integer sendStatus,String createTime,
|
||||
String updateTime) throws Exception{
|
||||
operationSmsAdminService.batchSendByQuery(erbanNo,templateId,sendStatus,createTime,updateTime);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据选中的数据批量发送短信
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/page/send",method = RequestMethod.POST)
|
||||
public BusiResult batchSendByPage(HttpServletRequest request) throws Exception{
|
||||
List<Long> ids = getRequestArray(request, "ids", Long.class);
|
||||
operationSmsAdminService.batchSendByPage(ids);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条记录发送短信
|
||||
* @param recordId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/send",method = RequestMethod.POST)
|
||||
public BusiResult sendForOne(Long recordId) throws Exception{
|
||||
operationSmsAdminService.sendForOne(recordId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
/**单条记录删除**/
|
||||
@RequestMapping(value = "/del",method = RequestMethod.POST)
|
||||
public BusiResult delForOne(Long recordId) throws Exception{
|
||||
operationSmsAdminService.delForOne(recordId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ public class SmsRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long smsRecordId;
|
||||
|
||||
private String phone;
|
||||
|
@@ -1,135 +0,0 @@
|
||||
package com.accompany.business.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class SmsRecord {
|
||||
private Long smsRecordId;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private String imei;
|
||||
|
||||
private String os;
|
||||
|
||||
private String osversion;
|
||||
|
||||
private String channel;
|
||||
|
||||
private String appVersion;
|
||||
|
||||
private String model;
|
||||
|
||||
private String smsCode;
|
||||
|
||||
private Byte smsType;
|
||||
|
||||
private String ip;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
public Long getSmsRecordId() {
|
||||
return smsRecordId;
|
||||
}
|
||||
|
||||
public void setSmsRecordId(Long smsRecordId) {
|
||||
this.smsRecordId = smsRecordId;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone == null ? null : phone.trim();
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId == null ? null : deviceId.trim();
|
||||
}
|
||||
|
||||
public String getImei() {
|
||||
return imei;
|
||||
}
|
||||
|
||||
public void setImei(String imei) {
|
||||
this.imei = imei == null ? null : imei.trim();
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(String os) {
|
||||
this.os = os == null ? null : os.trim();
|
||||
}
|
||||
|
||||
public String getOsversion() {
|
||||
return osversion;
|
||||
}
|
||||
|
||||
public void setOsversion(String osversion) {
|
||||
this.osversion = osversion == null ? null : osversion.trim();
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel == null ? null : channel.trim();
|
||||
}
|
||||
|
||||
public String getAppVersion() {
|
||||
return appVersion;
|
||||
}
|
||||
|
||||
public void setAppVersion(String appVersion) {
|
||||
this.appVersion = appVersion == null ? null : appVersion.trim();
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model == null ? null : model.trim();
|
||||
}
|
||||
|
||||
public String getSmsCode() {
|
||||
return smsCode;
|
||||
}
|
||||
|
||||
public void setSmsCode(String smsCode) {
|
||||
this.smsCode = smsCode == null ? null : smsCode.trim();
|
||||
}
|
||||
|
||||
public Byte getSmsType() {
|
||||
return smsType;
|
||||
}
|
||||
|
||||
public void setSmsType(Byte smsType) {
|
||||
this.smsType = smsType;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip == null ? null : ip.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user