Commit 73a2f4d84ce3b3538f400131ac2ec86275f215b0
1 parent
9f794ecb
1. 编写短信模板的前端
Showing
21 changed files
with
180 additions
and
57 deletions
ruoyi-ui/.env.demo1024
0 → 100644
ruoyi-ui/package.json
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | "dev": "vue-cli-service serve", | 8 | "dev": "vue-cli-service serve", |
| 9 | "build:prod": "vue-cli-service build", | 9 | "build:prod": "vue-cli-service build", |
| 10 | "build:stage": "vue-cli-service build --mode staging", | 10 | "build:stage": "vue-cli-service build --mode staging", |
| 11 | + "build:demo1024": "vue-cli-service build --mode demo1024", | ||
| 11 | "preview": "node build/index.js --preview", | 12 | "preview": "node build/index.js --preview", |
| 12 | "lint": "eslint --ext .js,.vue src" | 13 | "lint": "eslint --ext .js,.vue src" |
| 13 | }, | 14 | }, |
ruoyi-ui/src/api/system/sms/smsChannel.js
| @@ -42,3 +42,11 @@ export function getSmsChannelPage(query) { | @@ -42,3 +42,11 @@ export function getSmsChannelPage(query) { | ||
| 42 | params: query | 42 | params: query |
| 43 | }) | 43 | }) |
| 44 | } | 44 | } |
| 45 | + | ||
| 46 | +// 获得短信渠道精简列表 | ||
| 47 | +export function getSimpleSmsChannels() { | ||
| 48 | + return request({ | ||
| 49 | + url: '/system/sms-channel/list-all-simple', | ||
| 50 | + method: 'get', | ||
| 51 | + }) | ||
| 52 | +} |
ruoyi-ui/src/views/system/sms/smsChannel.vue
| @@ -108,7 +108,8 @@ | @@ -108,7 +108,8 @@ | ||
| 108 | </template> | 108 | </template> |
| 109 | 109 | ||
| 110 | <script> | 110 | <script> |
| 111 | -import { createSmsChannel, updateSmsChannel, deleteSmsChannel, getSmsChannel, getSmsChannelPage } from "@/api/system/sms/smsChannel"; | 111 | +import { createSmsChannel, updateSmsChannel, deleteSmsChannel, getSmsChannel, getSmsChannelPage, |
| 112 | + getSimpleSmsChannels } from "@/api/system/sms/smsChannel"; | ||
| 112 | 113 | ||
| 113 | export default { | 114 | export default { |
| 114 | name: "SmsChannel", | 115 | name: "SmsChannel", |
| @@ -144,7 +145,7 @@ export default { | @@ -144,7 +145,7 @@ export default { | ||
| 144 | code: [{ required: true, message: "渠道编码不能为空", trigger: "blur" }], | 145 | code: [{ required: true, message: "渠道编码不能为空", trigger: "blur" }], |
| 145 | status: [{ required: true, message: "启用状态不能为空", trigger: "blur" }], | 146 | status: [{ required: true, message: "启用状态不能为空", trigger: "blur" }], |
| 146 | apiKey: [{ required: true, message: "短信 API 的账号不能为空", trigger: "blur" }], | 147 | apiKey: [{ required: true, message: "短信 API 的账号不能为空", trigger: "blur" }], |
| 147 | - } | 148 | + }, |
| 148 | }; | 149 | }; |
| 149 | }, | 150 | }, |
| 150 | created() { | 151 | created() { |
ruoyi-ui/src/views/system/sms/smsTemplate.vue
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | <!-- 搜索工作栏 --> | 4 | <!-- 搜索工作栏 --> |
| 5 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="150px"> | 5 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="150px"> |
| 6 | <el-form-item label="短信类型" prop="type"> | 6 | <el-form-item label="短信类型" prop="type"> |
| 7 | - <el-select v-model="queryParams.type" placeholder="请选择短信签名" clearable size="small"> | 7 | + <el-select v-model="queryParams.type" placeholder="请选择短信类型" clearable size="small"> |
| 8 | <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)" | 8 | <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)" |
| 9 | :key="dict.value" :label="dict.label" :value="dict.value"/> | 9 | :key="dict.value" :label="dict.label" :value="dict.value"/> |
| 10 | </el-select> | 10 | </el-select> |
| @@ -23,7 +23,9 @@ | @@ -23,7 +23,9 @@ | ||
| 23 | </el-form-item> | 23 | </el-form-item> |
| 24 | <el-form-item label="短信渠道编号" prop="channelId"> | 24 | <el-form-item label="短信渠道编号" prop="channelId"> |
| 25 | <el-select v-model="queryParams.channelId" placeholder="请选择短信渠道编号" clearable size="small"> | 25 | <el-select v-model="queryParams.channelId" placeholder="请选择短信渠道编号" clearable size="small"> |
| 26 | - <el-option label="请选择字典生成" value="" /> | 26 | + <el-option v-for="channel in channelOptions" |
| 27 | + :key="channel.id" :value="channel.id" | ||
| 28 | + :label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, channel.code) + '】'" /> | ||
| 27 | </el-select> | 29 | </el-select> |
| 28 | </el-form-item> | 30 | </el-form-item> |
| 29 | <el-form-item label="创建时间"> | 31 | <el-form-item label="创建时间"> |
| @@ -66,9 +68,10 @@ | @@ -66,9 +68,10 @@ | ||
| 66 | </el-table-column>> | 68 | </el-table-column>> |
| 67 | <el-table-column label="备注" align="center" prop="remark" /> | 69 | <el-table-column label="备注" align="center" prop="remark" /> |
| 68 | <el-table-column label="短信 API 的模板编号" align="center" prop="apiTemplateId" width="180" /> | 70 | <el-table-column label="短信 API 的模板编号" align="center" prop="apiTemplateId" width="180" /> |
| 69 | - <el-table-column label="短信签名" align="center"> | 71 | + <el-table-column label="短信渠道" align="center"> |
| 70 | <template slot-scope="scope"> | 72 | <template slot-scope="scope"> |
| 71 | - <span>{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.channelCode) }}</span> | 73 | + <div>{{ formatChannelSignature(scope.row.channelId) }}</div> |
| 74 | + <div>【{{ getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, scope.row.channelCode) }}】</div> | ||
| 72 | </template> | 75 | </template> |
| 73 | </el-table-column> | 76 | </el-table-column> |
| 74 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 77 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| @@ -76,8 +79,10 @@ | @@ -76,8 +79,10 @@ | ||
| 76 | <span>{{ parseTime(scope.row.createTime) }}</span> | 79 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| 77 | </template> | 80 | </template> |
| 78 | </el-table-column> | 81 | </el-table-column> |
| 79 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 82 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150"> |
| 80 | <template slot-scope="scope"> | 83 | <template slot-scope="scope"> |
| 84 | + <el-button size="mini" type="text" icon="el-icon-share" @click="handleUpdate(scope.row)" | ||
| 85 | + v-hasPermi="['system:sms-template:update']">测试</el-button> | ||
| 81 | <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | 86 | <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
| 82 | v-hasPermi="['system:sms-template:update']">修改</el-button> | 87 | v-hasPermi="['system:sms-template:update']">修改</el-button> |
| 83 | <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | 88 | <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
| @@ -91,38 +96,40 @@ | @@ -91,38 +96,40 @@ | ||
| 91 | 96 | ||
| 92 | <!-- 对话框(添加 / 修改) --> | 97 | <!-- 对话框(添加 / 修改) --> |
| 93 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | 98 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| 94 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 95 | - <el-form-item label="短信签名" prop="type"> | ||
| 96 | - <el-select v-model="form.type" placeholder="请选择短信签名"> | 99 | + <el-form ref="form" :model="form" :rules="rules" label-width="140px"> |
| 100 | + <el-form-item label="短信渠道编号" prop="channelId"> | ||
| 101 | + <el-select v-model="form.channelId" placeholder="请选择短信渠道编号"> | ||
| 102 | + <el-option v-for="channel in channelOptions" | ||
| 103 | + :key="channel.id" :value="channel.id" | ||
| 104 | + :label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYS_SMS_CHANNEL_CODE, channel.code) + '】'" /> | ||
| 105 | + </el-select> | ||
| 106 | + </el-form-item> | ||
| 107 | + <el-form-item label="短信类型" prop="type"> | ||
| 108 | + <el-select v-model="form.type" placeholder="请选择短信类型"> | ||
| 97 | <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)" | 109 | <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYS_SMS_TEMPLATE_TYPE)" |
| 98 | :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" /> | 110 | :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" /> |
| 99 | </el-select> | 111 | </el-select> |
| 100 | </el-form-item> | 112 | </el-form-item> |
| 101 | - <el-form-item label="开启状态"> | ||
| 102 | - <el-radio-group v-model="form.status"> | ||
| 103 | - <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)" | ||
| 104 | - :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | ||
| 105 | - </el-radio-group> | ||
| 106 | - </el-form-item> | ||
| 107 | - <el-form-item label="模板编码" prop="code"> | ||
| 108 | - <el-input v-model="form.code" placeholder="请输入模板编码" /> | 113 | + <el-form-item label="模板编号" prop="code"> |
| 114 | + <el-input v-model="form.code" placeholder="请输入模板编号" /> | ||
| 109 | </el-form-item> | 115 | </el-form-item> |
| 110 | <el-form-item label="模板名称" prop="name"> | 116 | <el-form-item label="模板名称" prop="name"> |
| 111 | <el-input v-model="form.name" placeholder="请输入模板名称" /> | 117 | <el-input v-model="form.name" placeholder="请输入模板名称" /> |
| 112 | </el-form-item> | 118 | </el-form-item> |
| 113 | - <el-form-item label="模板内容"> | 119 | + <el-form-item label="模板内容" prop="content"> |
| 114 | <el-input type="textarea" v-model="form.content" placeholder="请输入模板内容" /> | 120 | <el-input type="textarea" v-model="form.content" placeholder="请输入模板内容" /> |
| 115 | </el-form-item> | 121 | </el-form-item> |
| 116 | - <el-form-item label="备注" prop="remark"> | ||
| 117 | - <el-input v-model="form.remark" placeholder="请输入备注" /> | 122 | + <el-form-item label="开启状态" prop="status"> |
| 123 | + <el-radio-group v-model="form.status"> | ||
| 124 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)" | ||
| 125 | + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | ||
| 126 | + </el-radio-group> | ||
| 118 | </el-form-item> | 127 | </el-form-item> |
| 119 | - <el-form-item label="短信 API 的模板编号" prop="apiTemplateId"> | 128 | + <el-form-item label="短信 API 模板编号" prop="apiTemplateId"> |
| 120 | <el-input v-model="form.apiTemplateId" placeholder="请输入短信 API 的模板编号" /> | 129 | <el-input v-model="form.apiTemplateId" placeholder="请输入短信 API 的模板编号" /> |
| 121 | </el-form-item> | 130 | </el-form-item> |
| 122 | - <el-form-item label="短信渠道编号" prop="channelId"> | ||
| 123 | - <el-select v-model="form.channelId" placeholder="请选择短信渠道编号"> | ||
| 124 | - <el-option label="请选择字典生成" value="" /> | ||
| 125 | - </el-select> | 131 | + <el-form-item label="备注" prop="remark"> |
| 132 | + <el-input v-model="form.remark" placeholder="请输入备注" /> | ||
| 126 | </el-form-item> | 133 | </el-form-item> |
| 127 | </el-form> | 134 | </el-form> |
| 128 | <div slot="footer" class="dialog-footer"> | 135 | <div slot="footer" class="dialog-footer"> |
| @@ -135,13 +142,10 @@ | @@ -135,13 +142,10 @@ | ||
| 135 | 142 | ||
| 136 | <script> | 143 | <script> |
| 137 | import { createSmsTemplate, updateSmsTemplate, deleteSmsTemplate, getSmsTemplate, getSmsTemplatePage, exportSmsTemplateExcel } from "@/api/system/sms/smsTemplate"; | 144 | import { createSmsTemplate, updateSmsTemplate, deleteSmsTemplate, getSmsTemplate, getSmsTemplatePage, exportSmsTemplateExcel } from "@/api/system/sms/smsTemplate"; |
| 138 | -import Editor from '@/components/Editor'; | 145 | +import { getSimpleSmsChannels } from "@/api/system/sms/smsChannel"; |
| 139 | 146 | ||
| 140 | export default { | 147 | export default { |
| 141 | name: "SmsTemplate", | 148 | name: "SmsTemplate", |
| 142 | - components: { | ||
| 143 | - Editor, | ||
| 144 | - }, | ||
| 145 | data() { | 149 | data() { |
| 146 | return { | 150 | return { |
| 147 | // 遮罩层 | 151 | // 遮罩层 |
| @@ -172,18 +176,24 @@ export default { | @@ -172,18 +176,24 @@ export default { | ||
| 172 | form: {}, | 176 | form: {}, |
| 173 | // 表单校验 | 177 | // 表单校验 |
| 174 | rules: { | 178 | rules: { |
| 175 | - type: [{ required: true, message: "短信签名不能为空", trigger: "change" }], | 179 | + type: [{ required: true, message: "短信类型不能为空", trigger: "change" }], |
| 176 | status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }], | 180 | status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }], |
| 177 | code: [{ required: true, message: "模板编码不能为空", trigger: "blur" }], | 181 | code: [{ required: true, message: "模板编码不能为空", trigger: "blur" }], |
| 178 | name: [{ required: true, message: "模板名称不能为空", trigger: "blur" }], | 182 | name: [{ required: true, message: "模板名称不能为空", trigger: "blur" }], |
| 179 | content: [{ required: true, message: "模板内容不能为空", trigger: "blur" }], | 183 | content: [{ required: true, message: "模板内容不能为空", trigger: "blur" }], |
| 180 | apiTemplateId: [{ required: true, message: "短信 API 的模板编号不能为空", trigger: "blur" }], | 184 | apiTemplateId: [{ required: true, message: "短信 API 的模板编号不能为空", trigger: "blur" }], |
| 181 | channelId: [{ required: true, message: "短信渠道编号不能为空", trigger: "change" }], | 185 | channelId: [{ required: true, message: "短信渠道编号不能为空", trigger: "change" }], |
| 182 | - } | 186 | + }, |
| 187 | + // 短信渠道 | ||
| 188 | + channelOptions: [], | ||
| 183 | }; | 189 | }; |
| 184 | }, | 190 | }, |
| 185 | created() { | 191 | created() { |
| 186 | this.getList(); | 192 | this.getList(); |
| 193 | + // 获得短信渠道 | ||
| 194 | + getSimpleSmsChannels().then(response => { | ||
| 195 | + this.channelOptions = response.data; | ||
| 196 | + }) | ||
| 187 | }, | 197 | }, |
| 188 | methods: { | 198 | methods: { |
| 189 | /** 查询列表 */ | 199 | /** 查询列表 */ |
| @@ -300,6 +310,15 @@ export default { | @@ -300,6 +310,15 @@ export default { | ||
| 300 | }).then(response => { | 310 | }).then(response => { |
| 301 | this.downloadExcel(response, '短信模板.xls'); | 311 | this.downloadExcel(response, '短信模板.xls'); |
| 302 | }) | 312 | }) |
| 313 | + }, | ||
| 314 | + /** 格式化短信渠道 */ | ||
| 315 | + formatChannelSignature(channelId) { | ||
| 316 | + for (const channel of this.channelOptions) { | ||
| 317 | + if (channel.id === channelId) { | ||
| 318 | + return channel.signature; | ||
| 319 | + } | ||
| 320 | + } | ||
| 321 | + return '找不到签名:' + channelId; | ||
| 303 | } | 322 | } |
| 304 | } | 323 | } |
| 305 | }; | 324 | }; |
src/main/java/cn/iocoder/dashboard/common/pojo/CommonResult.java
| @@ -74,7 +74,7 @@ public class CommonResult<T> implements Serializable { | @@ -74,7 +74,7 @@ public class CommonResult<T> implements Serializable { | ||
| 74 | 74 | ||
| 75 | @JsonIgnore // 避免 jackson 序列化 | 75 | @JsonIgnore // 避免 jackson 序列化 |
| 76 | public boolean isSuccess() { | 76 | public boolean isSuccess() { |
| 77 | - return isSuccess(GlobalErrorCodeConstants.SUCCESS.getCode()); | 77 | + return isSuccess(code); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | @JsonIgnore // 避免 jackson 序列化 | 80 | @JsonIgnore // 避免 jackson 序列化 |
src/main/java/cn/iocoder/dashboard/framework/sms/core/enums/SmsFrameworkErrorCodeConstants.java
| @@ -15,17 +15,17 @@ public interface SmsFrameworkErrorCodeConstants { | @@ -15,17 +15,17 @@ public interface SmsFrameworkErrorCodeConstants { | ||
| 15 | ErrorCode SMS_CHANNEL_API_KEY_MISSING = new ErrorCode(2001000101, "API Key 不存在"); | 15 | ErrorCode SMS_CHANNEL_API_KEY_MISSING = new ErrorCode(2001000101, "API Key 不存在"); |
| 16 | ErrorCode SMS_CHANNEL_PERMISSION_DENY = new ErrorCode(2001000102, "没有发送短信的权限"); | 16 | ErrorCode SMS_CHANNEL_PERMISSION_DENY = new ErrorCode(2001000102, "没有发送短信的权限"); |
| 17 | 17 | ||
| 18 | - // ========== 模板相关(200 开头) ========== | ||
| 19 | - ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(200, "短信模板不存在"); | ||
| 20 | - ErrorCode SMS_TEMPLATE_DISABLE = new ErrorCode(201, "短信模板被禁用"); // 例如说,我们在管理后台禁用了 | ||
| 21 | - ErrorCode SMS_TEMPLATE_INVALID = new ErrorCode(202, "短信模板不可用"); // 例如说,短信模板正在审核中 | ||
| 22 | - ErrorCode SMS_TEMPLATE_PARAM_ERROR = new ErrorCode(203, "模板参数不正确"); | 18 | + // ========== 模板相关(2001000200 开头) ========== |
| 19 | + ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(2001000200, "短信模板不存在"); | ||
| 20 | + ErrorCode SMS_TEMPLATE_DISABLE = new ErrorCode(2001000201, "短信模板被禁用"); // 例如说,我们在管理后台禁用了 | ||
| 21 | + ErrorCode SMS_TEMPLATE_INVALID = new ErrorCode(2001000202, "短信模板不可用"); // 例如说,短信模板正在审核中 | ||
| 22 | + ErrorCode SMS_TEMPLATE_PARAM_ERROR = new ErrorCode(2001000203, "模板参数不正确"); | ||
| 23 | 23 | ||
| 24 | - // ========== 其它相关(900 开头) ========== | ||
| 25 | - ErrorCode SMS_API_PARAM_ERROR = new ErrorCode(900, "请求参数缺失"); | 24 | + // ========== 其它相关(2001000900 开头) ========== |
| 25 | + ErrorCode SMS_API_PARAM_ERROR = new ErrorCode(2001000900, "请求参数缺失"); | ||
| 26 | 26 | ||
| 27 | - ErrorCode SMS_SEND_LIMIT_CONTROL = new ErrorCode(997, "业务限流"); // 将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。 | ||
| 28 | - ErrorCode EXCEPTION = new ErrorCode(998, "调用异常"); | ||
| 29 | - ErrorCode SMS_UNKNOWN = new ErrorCode(999, "未知错误,需要解析"); | 27 | + ErrorCode SMS_SEND_LIMIT_CONTROL = new ErrorCode(2001000997, "业务限流"); // 将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。 |
| 28 | + ErrorCode EXCEPTION = new ErrorCode(2001000998, "调用异常"); | ||
| 29 | + ErrorCode SMS_UNKNOWN = new ErrorCode(2001000999, "未知错误,需要解析"); | ||
| 30 | 30 | ||
| 31 | } | 31 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictDataController.java
| @@ -61,7 +61,7 @@ public class SysDictDataController { | @@ -61,7 +61,7 @@ public class SysDictDataController { | ||
| 61 | @GetMapping("/list-all-simple") | 61 | @GetMapping("/list-all-simple") |
| 62 | @ApiOperation(value = "获得全部字典数据列表", notes = "一般用于管理后台缓存字典数据在本地") | 62 | @ApiOperation(value = "获得全部字典数据列表", notes = "一般用于管理后台缓存字典数据在本地") |
| 63 | // 无需添加权限认证,因为前端全局都需要 | 63 | // 无需添加权限认证,因为前端全局都需要 |
| 64 | - public CommonResult<List<SysDictDataSimpleVO>> getSimpleDictDatas() { | 64 | + public CommonResult<List<SysDictDataSimpleRespVO>> getSimpleDictDatas() { |
| 65 | List<SysDictDataDO> list = dictDataService.getDictDatas(); | 65 | List<SysDictDataDO> list = dictDataService.getDictDatas(); |
| 66 | return success(SysDictDataConvert.INSTANCE.convertList(list)); | 66 | return success(SysDictDataConvert.INSTANCE.convertList(list)); |
| 67 | } | 67 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataSimpleVO.java renamed to src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/data/SysDictDataSimpleRespVO.java
| @@ -4,9 +4,9 @@ import io.swagger.annotations.ApiModel; | @@ -4,9 +4,9 @@ import io.swagger.annotations.ApiModel; | ||
| 4 | import io.swagger.annotations.ApiModelProperty; | 4 | import io.swagger.annotations.ApiModelProperty; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| 7 | -@ApiModel("数据字典精简 VO") | 7 | +@ApiModel("数据字典精简 Response VO") |
| 8 | @Data | 8 | @Data |
| 9 | -public class SysDictDataSimpleVO { | 9 | +public class SysDictDataSimpleRespVO { |
| 10 | 10 | ||
| 11 | @ApiModelProperty(value = "字典类型", required = true, example = "gender") | 11 | @ApiModelProperty(value = "字典类型", required = true, example = "gender") |
| 12 | private String dictType; | 12 | private String dictType; |
src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SysSmsChannelController.java
| @@ -2,10 +2,7 @@ package cn.iocoder.dashboard.modules.system.controller.sms; | @@ -2,10 +2,7 @@ package cn.iocoder.dashboard.modules.system.controller.sms; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.dashboard.common.pojo.CommonResult; | 3 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 4 | import cn.iocoder.dashboard.common.pojo.PageResult; | 4 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 5 | -import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | ||
| 6 | -import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelPageReqVO; | ||
| 7 | -import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelRespVO; | ||
| 8 | -import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 5 | +import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.*; |
| 9 | import cn.iocoder.dashboard.modules.system.convert.sms.SysSmsChannelConvert; | 6 | import cn.iocoder.dashboard.modules.system.convert.sms.SysSmsChannelConvert; |
| 10 | import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsChannelDO; | 7 | import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsChannelDO; |
| 11 | import cn.iocoder.dashboard.modules.system.service.sms.SysSmsChannelService; | 8 | import cn.iocoder.dashboard.modules.system.service.sms.SysSmsChannelService; |
| @@ -17,6 +14,8 @@ import org.springframework.web.bind.annotation.*; | @@ -17,6 +14,8 @@ import org.springframework.web.bind.annotation.*; | ||
| 17 | 14 | ||
| 18 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 19 | import javax.validation.Valid; | 16 | import javax.validation.Valid; |
| 17 | +import java.util.Comparator; | ||
| 18 | +import java.util.List; | ||
| 20 | 19 | ||
| 21 | import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | 20 | import static cn.iocoder.dashboard.common.pojo.CommonResult.success; |
| 22 | 21 | ||
| @@ -69,4 +68,13 @@ public class SysSmsChannelController { | @@ -69,4 +68,13 @@ public class SysSmsChannelController { | ||
| 69 | return success(SysSmsChannelConvert.INSTANCE.convertPage(pageResult)); | 68 | return success(SysSmsChannelConvert.INSTANCE.convertPage(pageResult)); |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 71 | + @GetMapping("/list-all-simple") | ||
| 72 | + @ApiOperation(value = "获得短信渠道精简列表", notes = "包含被禁用的短信渠道") | ||
| 73 | + public CommonResult<List<SysSmsChannelSimpleRespVO>> getSimpleSmsChannels() { | ||
| 74 | + List<SysSmsChannelDO> list = smsChannelService.getSmsChannelList(); | ||
| 75 | + // 排序后,返回给前端 | ||
| 76 | + list.sort(Comparator.comparing(SysSmsChannelDO::getId)); | ||
| 77 | + return success(SysSmsChannelConvert.INSTANCE.convertList03(list)); | ||
| 78 | + } | ||
| 79 | + | ||
| 72 | } | 80 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SysSmsTemplateController.http
0 → 100644
src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SysSmsTemplateController.java
| @@ -84,4 +84,11 @@ public class SysSmsTemplateController { | @@ -84,4 +84,11 @@ public class SysSmsTemplateController { | ||
| 84 | ExcelUtils.write(response, "短信模板.xls", "数据", SysSmsTemplateExcelVO.class, datas); | 84 | ExcelUtils.write(response, "短信模板.xls", "数据", SysSmsTemplateExcelVO.class, datas); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | + @PostMapping("/send-sms") | ||
| 88 | + @ApiOperation("导出短信模板 Excel") | ||
| 89 | + @PreAuthorize("@ss.hasPermission('system:sms-template:send-sms')") | ||
| 90 | + public CommonResult<Boolean> sendSms(@Valid @RequestBody SysSmsTemplateSendReqVO sendReqVO) { | ||
| 91 | + return success(true); | ||
| 92 | + } | ||
| 93 | + | ||
| 87 | } | 94 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/channel/SysSmsChannelSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.sms.vo.channel; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | + | ||
| 9 | +@ApiModel("短信渠道精简 Response VO") | ||
| 10 | +@Data | ||
| 11 | +public class SysSmsChannelSimpleRespVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "编号", required = true, example = "1024") | ||
| 14 | + @NotNull(message = "编号不能为空") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "短信签名", required = true, example = "芋道源码") | ||
| 18 | + @NotNull(message = "短信签名不能为空") | ||
| 19 | + private String signature; | ||
| 20 | + | ||
| 21 | + @ApiModelProperty(value = "渠道编码", required = true, example = "YUN_PIAN", notes = "参见 SmsChannelEnum 枚举类") | ||
| 22 | + private String code; | ||
| 23 | + | ||
| 24 | +} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/template/SysSmsTemplateSendReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.sms.vo.template; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +@ApiModel("短信模板的发送 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class SysSmsTemplateSendReqVO { | ||
| 13 | + | ||
| 14 | + @ApiModelProperty(value = "模板编码", required = true, example = "test_01") | ||
| 15 | + @NotNull(message = "模板编码不能为空") | ||
| 16 | + private String code; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "模板参数") | ||
| 19 | + private Map<String, Object> params; | ||
| 20 | + | ||
| 21 | +} |
src/main/java/cn/iocoder/dashboard/modules/system/convert/dict/SysDictDataConvert.java
| @@ -13,7 +13,7 @@ public interface SysDictDataConvert { | @@ -13,7 +13,7 @@ public interface SysDictDataConvert { | ||
| 13 | 13 | ||
| 14 | SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class); | 14 | SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class); |
| 15 | 15 | ||
| 16 | - List<SysDictDataSimpleVO> convertList(List<SysDictDataDO> list); | 16 | + List<SysDictDataSimpleRespVO> convertList(List<SysDictDataDO> list); |
| 17 | 17 | ||
| 18 | SysDictDataRespVO convert(SysDictDataDO bean); | 18 | SysDictDataRespVO convert(SysDictDataDO bean); |
| 19 | 19 |
src/main/java/cn/iocoder/dashboard/modules/system/convert/sms/SysSmsChannelConvert.java
| @@ -4,6 +4,7 @@ import cn.iocoder.dashboard.common.pojo.PageResult; | @@ -4,6 +4,7 @@ import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | 4 | import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; |
| 5 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; | 5 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelCreateReqVO; |
| 6 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelRespVO; | 6 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelRespVO; |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelSimpleRespVO; | ||
| 7 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; | 8 | import cn.iocoder.dashboard.modules.system.controller.sms.vo.channel.SysSmsChannelUpdateReqVO; |
| 8 | import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsChannelDO; | 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.sms.SysSmsChannelDO; |
| 9 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| @@ -33,4 +34,6 @@ public interface SysSmsChannelConvert { | @@ -33,4 +34,6 @@ public interface SysSmsChannelConvert { | ||
| 33 | 34 | ||
| 34 | List<SmsChannelProperties> convertList02(List<SysSmsChannelDO> list); | 35 | List<SmsChannelProperties> convertList02(List<SysSmsChannelDO> list); |
| 35 | 36 | ||
| 37 | + List<SysSmsChannelSimpleRespVO> convertList03(List<SysSmsChannelDO> list); | ||
| 38 | + | ||
| 36 | } | 39 | } |
src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
| @@ -31,7 +31,7 @@ public interface SysErrorCodeConstants { | @@ -31,7 +31,7 @@ public interface SysErrorCodeConstants { | ||
| 31 | // ========== 角色模块 1002003000 ========== | 31 | // ========== 角色模块 1002003000 ========== |
| 32 | ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1002003000, "角色不存在"); | 32 | ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1002003000, "角色不存在"); |
| 33 | ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002003001, "已经存在名为【{}}】的角色"); | 33 | ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002003001, "已经存在名为【{}}】的角色"); |
| 34 | - ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002003002, "已经存在编码为【{}}】的角色"); | 34 | + ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002003002, "已经存在编码为【{}】的角色"); |
| 35 | ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002003004, "不能操作类型为系统内置的角色"); | 35 | ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002003004, "不能操作类型为系统内置的角色"); |
| 36 | 36 | ||
| 37 | // ========== 用户模块 1002004000 ========== | 37 | // ========== 用户模块 1002004000 ========== |
| @@ -84,7 +84,7 @@ public interface SysErrorCodeConstants { | @@ -84,7 +84,7 @@ public interface SysErrorCodeConstants { | ||
| 84 | 84 | ||
| 85 | // ========== 短信模板 1002011000 ========== | 85 | // ========== 短信模板 1002011000 ========== |
| 86 | ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1002011000, "短信模板不存在"); | 86 | ErrorCode SMS_TEMPLATE_NOT_EXISTS = new ErrorCode(1002011000, "短信模板不存在"); |
| 87 | - ErrorCode SMS_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002011001, "已经存在编码为【{}}】的短信模板"); | 87 | + ErrorCode SMS_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002011001, "已经存在编码为【{}】的短信模板"); |
| 88 | 88 | ||
| 89 | // ========== 短信发送 1002012000 ========== | 89 | // ========== 短信发送 1002012000 ========== |
| 90 | ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002012000, "手机号不存在"); | 90 | ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002012000, "手机号不存在"); |
src/main/java/cn/iocoder/dashboard/modules/system/service/sms/SysSmsChannelService.java
| @@ -62,6 +62,13 @@ public interface SysSmsChannelService { | @@ -62,6 +62,13 @@ public interface SysSmsChannelService { | ||
| 62 | List<SysSmsChannelDO> getSmsChannelList(Collection<Long> ids); | 62 | List<SysSmsChannelDO> getSmsChannelList(Collection<Long> ids); |
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | + * 获得所有短信渠道列表 | ||
| 66 | + * | ||
| 67 | + * @return 短信渠道列表 | ||
| 68 | + */ | ||
| 69 | + List<SysSmsChannelDO> getSmsChannelList(); | ||
| 70 | + | ||
| 71 | + /** | ||
| 65 | * 获得短信渠道分页 | 72 | * 获得短信渠道分页 |
| 66 | * | 73 | * |
| 67 | * @param pageReqVO 分页查询 | 74 | * @param pageReqVO 分页查询 |
src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsChannelServiceImpl.java
| @@ -91,6 +91,11 @@ public class SysSmsChannelServiceImpl implements SysSmsChannelService { | @@ -91,6 +91,11 @@ public class SysSmsChannelServiceImpl implements SysSmsChannelService { | ||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | @Override | 93 | @Override |
| 94 | + public List<SysSmsChannelDO> getSmsChannelList() { | ||
| 95 | + return smsChannelMapper.selectList(); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @Override | ||
| 94 | public PageResult<SysSmsChannelDO> getSmsChannelPage(SysSmsChannelPageReqVO pageReqVO) { | 99 | public PageResult<SysSmsChannelDO> getSmsChannelPage(SysSmsChannelPageReqVO pageReqVO) { |
| 95 | return smsChannelMapper.selectPage(pageReqVO); | 100 | return smsChannelMapper.selectPage(pageReqVO); |
| 96 | } | 101 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/sms/impl/SysSmsTemplateServiceImpl.java
| @@ -162,10 +162,10 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | @@ -162,10 +162,10 @@ public class SysSmsTemplateServiceImpl implements SysSmsTemplateService { | ||
| 162 | } | 162 | } |
| 163 | // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 | 163 | // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 |
| 164 | if (id == null) { | 164 | if (id == null) { |
| 165 | - throw exception(SMS_TEMPLATE_CODE_DUPLICATE); | 165 | + throw exception(SMS_TEMPLATE_CODE_DUPLICATE, code); |
| 166 | } | 166 | } |
| 167 | if (!template.getId().equals(id)) { | 167 | if (!template.getId().equals(id)) { |
| 168 | - throw exception(SMS_TEMPLATE_CODE_DUPLICATE); | 168 | + throw exception(SMS_TEMPLATE_CODE_DUPLICATE, code); |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 |
src/main/resources/codegen/vue/views/index.vue.vm
| @@ -137,7 +137,7 @@ | @@ -137,7 +137,7 @@ | ||
| 137 | </el-select> | 137 | </el-select> |
| 138 | </el-form-item> | 138 | </el-form-item> |
| 139 | #elseif($column.htmlType == "checkbox")## 多选框 | 139 | #elseif($column.htmlType == "checkbox")## 多选框 |
| 140 | - <el-form-item label="${comment}"> | 140 | + <el-form-item label="${comment}" prop="${javaField}"> |
| 141 | <el-checkbox-group v-model="form.${javaField}"> | 141 | <el-checkbox-group v-model="form.${javaField}"> |
| 142 | #if ("" != $dictType)## 有数据字典 | 142 | #if ("" != $dictType)## 有数据字典 |
| 143 | <el-checkbox v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())" | 143 | <el-checkbox v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())" |
| @@ -148,7 +148,7 @@ | @@ -148,7 +148,7 @@ | ||
| 148 | </el-checkbox-group> | 148 | </el-checkbox-group> |
| 149 | </el-form-item> | 149 | </el-form-item> |
| 150 | #elseif($column.htmlType == "radio")## 单选框 | 150 | #elseif($column.htmlType == "radio")## 单选框 |
| 151 | - <el-form-item label="${comment}"> | 151 | + <el-form-item label="${comment}" prop="${javaField}"> |
| 152 | <el-radio-group v-model="form.${javaField}"> | 152 | <el-radio-group v-model="form.${javaField}"> |
| 153 | #if ("" != $dictType)## 有数据字典 | 153 | #if ("" != $dictType)## 有数据字典 |
| 154 | <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())" | 154 | <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())" |