zq-erp/src/main/java/com/matrix/core/enums/EnumsManager.java
@@ -1,6 +1,7 @@ package com.matrix.core.enums; import com.matrix.system.hive.hievEnum.SmsPlatformEnum; import com.matrix.system.hive.hievEnum.SmsTypeEnum; import java.util.HashMap; import java.util.List; @@ -15,6 +16,7 @@ static { showAbleMap.put(SmsPlatformEnum.values()[0].getEnumCode(),SmsPlatformEnum.values()[0].getEnumsShowVos()); showAbleMap.put(SmsTypeEnum.values()[0].getEnumCode(),SmsTypeEnum.values()[0].getEnumsShowVos()); } public static List<EnumsShowVo> getShowEnum(String emumCode){ zq-erp/src/main/java/com/matrix/core/tools/SmsUtils.java
@@ -7,7 +7,6 @@ import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.http.MethodType; import com.google.gson.JsonObject; import com.matrix.config.properties.AliSmsProperties; import com.matrix.core.exception.GlobleException; import com.matrix.system.hive.bean.SysSmsTemplate; @@ -15,7 +14,6 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; /** @@ -105,7 +103,7 @@ * @param content 短信模板内容 * @param remark 短信模板申请说明 */ public String addSmsTemplate(String type, String name, String content, String remark) { public String addAliyunSmsTemplate(String type, String name, String content, String remark) { CommonRequest request = commonRequest(SysSmsTemplate.SMS_ACTION_ADD); request.putQueryParameter("TemplateType", type); request.putQueryParameter("TemplateName", name); zq-erp/src/main/java/com/matrix/system/common/actions/CommonDataAction.java
@@ -2,7 +2,6 @@ import com.matrix.core.enums.EnumsManager; import com.matrix.core.pojo.AjaxResult; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -18,7 +17,7 @@ public class CommonDataAction { @GetMapping("/getEnums/{enumCode}") @RequestMapping("/getEnums/{enumCode}") public AjaxResult getEnums(@PathVariable String enumCode) throws ClassNotFoundException { return AjaxResult.buildSuccessInstance(EnumsManager.getShowEnum(enumCode)); } zq-erp/src/main/java/com/matrix/system/hive/bean/SysSmsTemplate.java
@@ -1,14 +1,14 @@ package com.matrix.system.hive.bean; import com.matrix.core.pojo.EntityDTO; import com.matrix.core.anotations.Extend; import com.matrix.system.hive.hievEnum.SmsPlatformEnum; import lombok.Data; /** * @description 短信模板表 * @author wzy * @date 2020-03-15 18:42 */ @Data public class SysSmsTemplate{ @Extend private static final long serialVersionUID = 1L; @@ -29,20 +29,6 @@ */ public static final Integer SMS_STATUS_N = 2; /** * 短信类型 验证码 */ public static final String SMS_TYPE_VERIFY_CODE = "0"; /** * 短信类型 短信通知 */ public static final String SMS_TYPE_SMS_NOTICE = "1"; /** * 短信类型 推广短信 */ public static final String SMS_TYPE_PROMOTE = "2"; /** * api接口action 添加模板 @@ -75,6 +61,10 @@ * 模板名称 */ private String stName; /** * 模板类型 */ private String smsType; /** * 短信平台 @@ -109,81 +99,5 @@ private Long companyId; public Long getCompanyId() { return companyId; } public void setCompanyId(Long companyId) { this.companyId = companyId; } public String getStRemark() { return stRemark; } public void setStRemark(String stRemark) { this.stRemark = stRemark; } public Long getId() { return id; } public void setId(Long id) { this.id=id; } public String getStName() { return stName; } public void setStName(String stName) { this.stName=stName; } public String getStTemplate() { return stTemplate; } public void setStTemplate(String stTemplate) { this.stTemplate=stTemplate; } public String getStCode() { return stCode; } public void setStCode(String stCode) { this.stCode=stCode; } public Integer getStStatus() { return stStatus; } public void setStStatus(Integer stStatus) { this.stStatus=stStatus; } public String getStReason() { return stReason; } public void setStReason(String stReason) { this.stReason=stReason; } public String getSmsPlatform() { return smsPlatform; } public void setSmsPlatform(String smsPlatform) { this.smsPlatform = smsPlatform; } } zq-erp/src/main/java/com/matrix/system/hive/hievEnum/SmsTypeEnum.java
New file @@ -0,0 +1,53 @@ package com.matrix.system.hive.hievEnum; import com.google.common.collect.Lists; import com.matrix.core.enums.ApiShowAble; import com.matrix.core.enums.EnumsShowVo; import java.util.List; import java.util.stream.Collectors; /** * 短信类型 */ public enum SmsTypeEnum implements ApiShowAble { VERIFY_CODE("0", "验证码"), SMS_NOTICE("1", "短信通知"), PROMOTE("2", "推广短信"); private String value; private String displayName; SmsTypeEnum(String value, String displayName) { this.value = value; this.displayName = displayName; } @Override public String getEnumCode() { return "smsType"; } @Override public List<EnumsShowVo> getEnumsShowVos() { return Lists.newArrayList(values()).stream().map(item -> EnumsShowVo.builder() .displayName(item.getDisplayName()) .value(item.value) .build() ).collect(Collectors.toList()); } public String getValue() { return value; } public String getDisplayName() { return displayName; } } zq-erp/src/main/java/com/matrix/system/hiveErp/action/SysSmsTemplateAction.java
@@ -1,28 +1,29 @@ package com.matrix.system.hiveErp.action; import com.alibaba.fastjson.JSONObject; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.constance.SystemMessageCode; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.anotations.RemoveRequestToken; import com.matrix.core.tools.*; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.hive.dao.SysSmsTemplateDao; import com.matrix.system.hive.plugin.message.StringUtil; import com.matrix.system.hive.plugin.util.CollectionUtils; import org.springframework.stereotype.Controller; import com.matrix.core.anotations.SaveRequestToken; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.constance.SystemMessageCode; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.tools.ModelUtils; import com.matrix.core.tools.SmsUtils; import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.hive.bean.SysSmsTemplate; import com.matrix.system.hive.dao.SysSmsTemplateDao; import com.matrix.system.hive.hievEnum.SmsPlatformEnum; import com.matrix.system.hive.plugin.util.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.matrix.core.anotations.SaveRequestToken; import com.matrix.core.pojo.AjaxResult; import org.springframework.beans.factory.annotation.Autowired; import com.matrix.system.hive.bean.SysSmsTemplate; import org.springframework.web.servlet.ModelAndView; import java.util.Collection; import java.util.List; import java.util.Map; @@ -94,12 +95,16 @@ SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); sysSmsTemplate.setCompanyId(users.getCompanyId()); sysSmsTemplate.setStTemplate(sysSmsTemplate.getStTemplate() + "回T退订"); String code = smsUtils.addSmsTemplate(SysSmsTemplate.SMS_TYPE_PROMOTE, sysSmsTemplate.getStName(), sysSmsTemplate.getStTemplate(), sysSmsTemplate.getStRemark()); String code=""; //调用阿里云接口添加阿里云短信模板,todo 如果有其他短信供应商在继续加 if(SmsPlatformEnum.ALIBABA.getValue().equals(sysSmsTemplate.getSmsType())){ code=smsUtils.addAliyunSmsTemplate(sysSmsTemplate.getSmsType(), sysSmsTemplate.getStName(), sysSmsTemplate.getStTemplate(), sysSmsTemplate.getStRemark()); } sysSmsTemplate.setStCode(code); sysSmsTemplate.setStStatus(SysSmsTemplate.SMS_STATUS_DOING); int i = sysSmsTemplateDao.insert(sysSmsTemplate); if (i > 0) { return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "短信模板表"); return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "短信模板"); } else { throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL); } zq-erp/src/main/resources/mybatis/mapper/common/SysSmsTemplateDao.xml
@@ -49,7 +49,7 @@ #{item.stStatus}, #{item.stReason}, #{item.stRemark}, #{companyId} #{item.companyId} </sql> <!-- where sql --> zq-erp/src/main/resources/templates/views/admin/hive-erp/sms/sysSmsTemplate-form.html
@@ -20,6 +20,32 @@ <input autocomplete="off" type="hidden" name="id" th:value="${obj?.id}"> <div class="form-group"> <label class="col-sm-2 control-label">短信平台<span class="text-danger">*</span></label> <div class="col-sm-4"> <select class="form-control autoFull select2" dataType="*" nullmsg="短信平台不能为空" id="smsPlatform" th:data-def="${obj?.smsPlatform}" th:data-url="@{/commondata/getEnums/smsPlatform}" data-value="value" data-filed="displayName" name="smsPlatform"> </select> </div> <label class="col-sm-2 control-label">短信类型<span class="text-danger">*</span></label> <div class="col-sm-4"> <select class="form-control autoFull select2" dataType="*" nullmsg="短信平台不能为空" id="smsType" th:data-def="${obj?.smsType}" th:data-url="@{/commondata/getEnums/smsType}" data-value="value" data-filed="displayName" name="smsType"> </select> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">模板名称<span class="text-danger">*</span></label> <div class="col-sm-4"> <input autocomplete="off" type="text" dataType="*1-20" class="form-control" zq-erp/src/main/resources/templates/views/admin/hive-erp/sms/sysSmsTemplate-list.html
@@ -107,7 +107,7 @@ layer.open({ type : 2, title : "添加短信模板表", area : [ MUI.SIZE_L, '400px' ], area : MUI.SIZE_M, maxmin : true, content : [ basePath+'/admin/sysSmsTemplate/editForm'] }); @@ -118,7 +118,7 @@ layer.open({ type : 2, title : "编辑短信模板表", area : [ MUI.SIZE_L, '400px' ], area : MUI.SIZE_M, maxmin : true, content : [ basePath+'/admin/sysSmsTemplate/editForm?id=' + id] });