SmsProvider

This commit is contained in:
MaxKey
2022-01-16 11:29:49 +08:00
parent 6a00bf4517
commit d4a8c19c6e
11 changed files with 635 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ poiVersion =5.1.0
tomcatVersion =9.0.56
tomcatembedloggingjuliVersion =8.5.2
#spring
springVersion =5.3.14
springVersion =5.3.15
springBootVersion =2.6.2
springSecurityVersion =5.6.0
springDataVersion =2.6.0

View File

@@ -0,0 +1,256 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* 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 org.maxkey.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseEntity;
@Entity
@Table(name = "MXK_SMS_PROVIDER")
public class SmsProvider extends JpaBaseEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4595539647817265938L;
@Id
@Column
@GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid")
String id;
@Column
String provider;
@Column
String providerName;
@Column
String message;
@Column
String appKey;
@Column
String appSecret;
@Column
String templateId;
@Column
String signName;
@Column
String smsSdkAppId;
@Column
String description;
@Column
String createdBy;
@Column
String createdDate;
@Column
String modifiedBy;
@Column
String modifiedDate;
@Column
int status;
@Column
private String instId;
private String instName;
public SmsProvider() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
public String getProviderName() {
return providerName;
}
public void setProviderName(String providerName) {
this.providerName = providerName;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getSignName() {
return signName;
}
public void setSignName(String signName) {
this.signName = signName;
}
public String getSmsSdkAppId() {
return smsSdkAppId;
}
public void setSmsSdkAppId(String smsSdkAppId) {
this.smsSdkAppId = smsSdkAppId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedDate() {
return createdDate;
}
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public String getModifiedDate() {
return modifiedDate;
}
public void setModifiedDate(String modifiedDate) {
this.modifiedDate = modifiedDate;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getInstId() {
return instId;
}
public void setInstId(String instId) {
this.instId = instId;
}
public String getInstName() {
return instName;
}
public void setInstName(String instName) {
this.instName = instName;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SmsProvider [id=");
builder.append(id);
builder.append(", provider=");
builder.append(provider);
builder.append(", providerName=");
builder.append(providerName);
builder.append(", message=");
builder.append(message);
builder.append(", appKey=");
builder.append(appKey);
builder.append(", appSecret=");
builder.append(appSecret);
builder.append(", templateId=");
builder.append(templateId);
builder.append(", signName=");
builder.append(signName);
builder.append(", smsSdkAppId=");
builder.append(smsSdkAppId);
builder.append(", description=");
builder.append(description);
builder.append(", createdBy=");
builder.append(createdBy);
builder.append(", createdDate=");
builder.append(createdDate);
builder.append(", modifiedBy=");
builder.append(modifiedBy);
builder.append(", modifiedDate=");
builder.append(modifiedDate);
builder.append(", status=");
builder.append(status);
builder.append(", instId=");
builder.append(instId);
builder.append(", instName=");
builder.append(instName);
builder.append("]");
return builder.toString();
}
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* 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 org.maxkey.persistence.mapper;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.SmsProvider;
public interface SmsProviderMapper extends IJpaBaseMapper<SmsProvider> {
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* 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 org.maxkey.persistence.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.SmsProvider;
import org.maxkey.persistence.mapper.SmsProviderMapper;
import org.springframework.stereotype.Repository;
@Repository
public class SmsProviderService extends JpaBaseService<SmsProvider>{
public SmsProviderService() {
super(SmsProviderMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public SmsProviderMapper getMapper() {
return (SmsProviderMapper)super.getMapper();
}
}

View File

@@ -133,6 +133,7 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
.addPathPatterns("/localization/**")
.addPathPatterns("/ldapcontext/**")
.addPathPatterns("/emailsenders/**")
.addPathPatterns("/smsprovider/**")
;

View File

@@ -0,0 +1,87 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* 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 org.maxkey.web.contorller;
import org.apache.commons.lang3.StringUtils;
import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.SmsProvider;
import org.maxkey.persistence.service.SmsProviderService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/smsprovider"})
public class SmsProviderController {
final static Logger _logger = LoggerFactory.getLogger(SmsProviderController.class);
@Autowired
private SmsProviderService smsProviderService;
/**
* 读取
* @return
*/
@RequestMapping(value={"/forward"})
public ModelAndView forward(){
SmsProvider smsProvider = smsProviderService.get(WebContext.getUserInfo().getInstId());
if(smsProvider != null && StringUtils.isNoneBlank(smsProvider.getId())) {
smsProvider.setAppSecret(PasswordReciprocal.getInstance().decoder(smsProvider.getAppSecret()));
}
return new ModelAndView("smsprovider/updateSmsProvider","model",smsProvider);
}
/**
* 更新
* @param sysConfig
* @return
*/
@RequestMapping(value={"/update"})
@ResponseBody
public Message update(@ModelAttribute SmsProvider smsProvider,BindingResult result) {
_logger.debug("update smsProvider : "+smsProvider);
smsProvider.setAppSecret(PasswordReciprocal.getInstance().encode(smsProvider.getAppSecret()));
smsProvider.setInstId(WebContext.getUserInfo().getInstId());
boolean updateResult = false;
if(StringUtils.isBlank(smsProvider.getId())) {
smsProvider.setId(smsProvider.getInstId());
updateResult = smsProviderService.insert(smsProvider);
}else {
updateResult = smsProviderService.update(smsProvider);
}
if(updateResult) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
}
}
}

View File

@@ -533,6 +533,19 @@ emailsenders.sslSwitch=SSL
emailsenders.sender=\u53D1\u9001\u4EBA
emailsenders.encoding=\u9ED8\u8BA4\u7F16\u7801
emailsenders.protocol=\u534F\u8BAE
#smsprovider
smsprovider.provider=\u63D0\u4F9B\u5546
smsprovider.providerName=\u63D0\u4F9B\u5546\u540D\u79F0
smsprovider.providerName.aliyun=\u963F\u91CC\u4E91\u77ED\u4FE1
smsprovider.providerName.neteasesms=\u7F51\u6613\u4E91\u4FE1
smsprovider.providerName.tencentcloud=\u817E\u8BAF\u4E91\u77ED\u4FE1
smsprovider.providerName.email=\u7535\u5B50\u90AE\u7BB1\u914D\u7F6E
smsprovider.message=\u5185\u5BB9
smsprovider.appkey=\u8D26\u53F7
smsprovider.appsecret=\u5BC6\u94A5
smsprovider.templateid=\u6A21\u677F\u7F16\u53F7
smsprovider.signname=\u7B7E\u540D
smsprovider.tencentcloud.smssdkappid=\u817E\u8BAFSDKAPPID
#button
button.text.action=\u8BBF\u95EE
button.text.visit=\u8BBF\u95EE
@@ -659,3 +672,4 @@ navs.socials.provider=\u793E\u4EA4\u670D\u52A1
navs.synchronizers=\u540C\u6B65\u5668\u7BA1\u7406
navs.ldapcontext=LDAP\u914D\u7F6E
navs.emailsenders=\u7535\u5B50\u90AE\u7BB1
navs.smsprovider=\u77ED\u4FE1\u670D\u52A1

View File

@@ -542,6 +542,19 @@ emailsenders.sslSwitch=SSL
emailsenders.sender=Sender
emailsenders.encoding=Encoding
emailsenders.protocol=Protocol
#smsprovider
smsprovider.provider=Provider
smsprovider.providerName=ProviderName
smsprovider.providerName.aliyun=Aliyun SMS
smsprovider.providerName.neteasesms=Netease SMS
smsprovider.providerName.tencentcloud=Tencent Cloud SMS
smsprovider.providerName.email=Email Config
smsprovider.message=Message
smsprovider.appkey=Key
smsprovider.appsecret=Secret
smsprovider.templateid=Template
smsprovider.signname=SignName
smsprovider.tencentcloud.smssdkappid=Tencent SMS SDKAPPID
button.text.action=Action
button.text.visit=Visit
@@ -668,3 +681,4 @@ navs.socials.provider=SocialsProvider
navs.synchronizers=Synchronizers
navs.ldapcontext=LdapContext
navs.emailsenders=Email
navs.smsprovider=SmsProvider

View File

@@ -533,6 +533,19 @@ emailsenders.sslSwitch=SSL
emailsenders.sender=\u53D1\u9001\u4EBA
emailsenders.encoding=\u9ED8\u8BA4\u7F16\u7801
emailsenders.protocol=\u534F\u8BAE
#smsprovider
smsprovider.provider=\u63D0\u4F9B\u5546
smsprovider.providerName=\u63D0\u4F9B\u5546\u540D\u79F0
smsprovider.providerName.aliyun=\u963F\u91CC\u4E91\u77ED\u4FE1
smsprovider.providerName.neteasesms=\u7F51\u6613\u4E91\u4FE1
smsprovider.providerName.tencentcloud=\u817E\u8BAF\u4E91\u77ED\u4FE1
smsprovider.providerName.email=\u7535\u5B50\u90AE\u7BB1\u914D\u7F6E
smsprovider.message=\u5185\u5BB9
smsprovider.appkey=\u8D26\u53F7
smsprovider.appsecret=\u5BC6\u94A5
smsprovider.templateid=\u6A21\u677F\u7F16\u53F7
smsprovider.signname=\u7B7E\u540D
smsprovider.tencentcloud.smssdkappid=\u817E\u8BAFSDKAPPID
#button
button.text.action=\u8BBF\u95EE
button.text.visit=\u8BBF\u95EE
@@ -659,3 +672,4 @@ navs.socials.provider=\u793E\u4EA4\u670D\u52A1
navs.synchronizers=\u540C\u6B65\u5668\u7BA1\u7406
navs.ldapcontext=LDAP\u914D\u7F6E
navs.emailsenders=\u7535\u5B50\u90AE\u7BB1
navs.smsprovider=\u77ED\u4FE1\u670D\u52A1

View File

@@ -36,7 +36,7 @@
<li>
<a class="side-nav-menu has-arrow" href="#">
<@locale code="navs.privileges"/>
<span class="fa fa-fw fa-cubes fa-lg"></span>
<span class="fa fa-fw fa-map fa-lg"></span>
</a>
<ul>
<li>
@@ -68,7 +68,7 @@
<li>
<a class="side-nav-menu has-arrow" href="#">
<@locale code="navs.role.permissions"/>
<span class="fa fa-fw fa-cogs fa-lg"></span>
<span class="fa fa-fw fa-leaf fa-lg"></span>
</a>
<ul>
@@ -138,22 +138,27 @@
<li>
<a class="side-nav-menu" href="<@base />/institutions/forward/">
<@locale code="navs.institutions"/>
<span class="fa fa-fw fa-balance-scale"></span>
<span class="fa fa-fw fa-institution"></span>
</a>
</li>
<li>
<a class="side-nav-menu" href="<@base />/ldapcontext/forward/">
<@locale code="navs.ldapcontext"/>
<span class="fa fa-fw fa-balance-scale"></span>
<span class="fa fa-fw fa-database"></span>
</a>
</li>
<li>
<a class="side-nav-menu" href="<@base />/emailsenders/forward/">
<@locale code="navs.emailsenders"/>
<span class="fa fa-fw fa-balance-scale"></span>
<span class="fa fa-fw fa-envelope"></span>
</a>
</li>
<li>
<a class="side-nav-menu" href="<@base />/smsprovider/forward/">
<@locale code="navs.smsprovider"/>
<span class="fa fa-fw fa-commenting"></span>
</a>
</li>
<li>
<a class="side-nav-menu" href="<@base />/config/passwordpolicy/forward/">
<@locale code="navs.conf.passwordpolicy"/>

View File

@@ -0,0 +1,167 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "../layout/header.ftl"/>
<#include "../layout/common.cssjs.ftl"/>
</head>
<body>
<div class="app header-default side-nav-dark">
<div class="layout">
<div class="header navbar">
<#include "../layout/top.ftl"/>
</div>
<div class="col-md-3 sidebar-nav side-nav" >
<#include "../layout/sidenav.ftl"/>
</div>
<div class="page-container">
<div class="main-content">
<div class="container-fluid">
<div class="breadcrumb-wrapper row">
<div class="col-12 col-lg-3 col-md-6">
<h4 class="page-title"><@locale code="navs.smsprovider"/></h4>
</div>
<div class="col-12 col-lg-9 col-md-6">
<ol class="breadcrumb float-right">
<li><a href="<@base/>/main"><@locale code="navs.home"/></a></li>
<li class="inactive">/ <@locale code="navs.conf"/></li>
<li class="active">/ <@locale code="navs.smsprovider"/></li>
</ol>
</div>
</div>
</div>
<div class="container-fluid">
<div class="content-wrapper row">
<div class="col-12 grid-margin">
<div class="card">
<div class="card-header border-bottom">
<h4 class="card-title"><@locale code="navs.smsprovider"/></h4>
</div>
<div class="card-body">
<form method="post" type="label" validate="true" action="<@base/>/smsprovider/update" id="actionForm" class="needs-validation" novalidate>
<div class="row mb-3">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.providerName" /></label>
<div class="col-sm-9">
<input id="id" name="id" type="hidden" value="${model.id!}"/>
<select id="provider" name="provider" class="form-control form-select">
<option value="aliyun" <#if 'aliyun'==model.provider>selected</#if> ><@locale code="smsprovider.providerName.aliyun" /></option>
<option value="tencentcloud" <#if 'tencentcloud'==model.provider >selected</#if> ><@locale code="smsprovider.providerName.tencentcloud" /></option>
<option value="neteasesms" <#if 'neteasesms'==model.provider >selected</#if> ><@locale code="smsprovider.providerName.neteasesms" /></option>
<option value="email" <#if 'email'==model.provider >selected</#if> ><@locale code="smsprovider.providerName.email" /></option>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="common.text.status" /></label>
<div class="col-sm-9">
<select id="status" name="status" class="form-control form-select">
<option value="0" <#if 0==model.status>selected</#if> ><@locale code="common.text.status.disabled" /></option>
<option value="1" <#if 1==model.status>selected</#if> ><@locale code="common.text.status.enabled" /></option>
</select>
</div>
</div>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label"><@locale code="smsprovider.message" /></label>
<div class="col-sm-10">
<input required="" class="form-control" type="text" id="message" name="message" value="${model.message!}" />
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.appkey" /></label>
<div class="col-sm-9">
<input required="" class="form-control" type="text" id="appKey" name="appKey" value="${model.appKey!}" />
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.appsecret" /></label>
<div class="col-sm-9">
<input required="" class="form-control" type="password" id="appSecret" name="appSecret" value="${model.appSecret!}" />
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.templateid" /></label>
<div class="col-sm-9">
<input required="" class="form-control" type="text" id="templateId" name="templateId" value="${model.templateId!}" />
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.signname" /></label>
<div class="col-sm-9">
<input required="" class="form-control" type="text" id="signName" name="signName" value="${model.signName!}" />
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label"><@locale code="smsprovider.tencentcloud.smssdkappid" /></label>
<div class="col-sm-9">
<input class="form-control" type="text" id="smsSdkAppId" name="smsSdkAppId" value="${model.smsSdkAppId!}"/>
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
<div class="form-group row">
<div class="col-sm-2">
<label class="col-form-label"><@locale code="common.text.description" /></label>
</div>
<div class="col-sm-10">
<input class="form-control" type="text" id="description" name="description" value="${model.description!}" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<input class="form-control" type="hidden" id="status" name="status" value="1" />
<button type="submit" class="button btn-primary btn btn-common btn-block mr-3" id="submitBtn" ><@locale code="button.text.save" /></button>
</div>
<div class="col-md-4"></div>
</div>
</form>
</div>
</div>
</div>
</div>
<footer class="content-footer">
<#include "../layout/footer.ftl"/>
</footer>
</div>
</div>
</div>
<div id="preloader">
<div class="loader" id="loader-1"></div>
</div>
</body>
</html>