refactor(system): 优化系统模块接口命名和参数校验
- 重构了多个控制器的查询接口,统一命名规范 - 新增参数校验,提高接口健壮性 - 更新了前端 API调用,以适应后端接口变更 - 优化了部分前端组件的错误提示文案
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// export function getDicts() {
|
||||
// return request({
|
||||
// url: 'api/dict/queryAllDict',
|
||||
// method: 'post'
|
||||
// })
|
||||
// }
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/dict/saveDict',
|
||||
|
||||
@@ -9,7 +9,7 @@ export function get(dictName) {
|
||||
}
|
||||
}
|
||||
return request({
|
||||
url: 'api/dictDetail',
|
||||
url: 'api/dictDetail/queryDictDetailByArgs',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function queryEmailConfig() {
|
||||
export function getLastEmailConfig() {
|
||||
return request({
|
||||
url: 'api/email/queryEmailConfig',
|
||||
url: 'api/email/getLastEmailConfig',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getAllJob() {
|
||||
export function queryAllEnableJob() {
|
||||
const params = {
|
||||
page: 1,
|
||||
size: 999999,
|
||||
@@ -9,7 +9,7 @@ export function getAllJob() {
|
||||
}
|
||||
}
|
||||
return request({
|
||||
url: 'api/job',
|
||||
url: 'api/job/queryAllEnableJob',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -7,9 +7,9 @@ export function queryMenuListByPid(pid) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getMenus(params) {
|
||||
export function queryMenuByArgs(params) {
|
||||
return request({
|
||||
url: 'api/menus',
|
||||
url: 'api/menus/queryMenuByArgs',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
@@ -62,4 +62,4 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, queryMenuListByPid, queryMenuSuperior, getMenus, queryChildMenuSet }
|
||||
export default { add, edit, del, queryMenuListByPid, queryMenuSuperior, queryMenuByArgs, queryChildMenuSet }
|
||||
|
||||
@@ -31,8 +31,8 @@ export function sync() {
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/qiNiuContent',
|
||||
method: 'delete',
|
||||
url: 'api/qiNiuContent/removeFileByIds',
|
||||
method: 'post',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ export function add(data) {
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/quartzJob',
|
||||
method: 'delete',
|
||||
url: 'api/quartzJob/removeJobByIds',
|
||||
method: 'post',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { queryEmailConfig, modifyEmailConfig } from '@/api/system/email'
|
||||
import { getLastEmailConfig, modifyEmailConfig } from '@/api/system/email'
|
||||
export default {
|
||||
name: 'Config',
|
||||
data() {
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
queryEmailConfig().then(res => {
|
||||
getLastEmailConfig().then(res => {
|
||||
this.form = res
|
||||
})
|
||||
},
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
lazy
|
||||
:load="getMenus"
|
||||
:load="queryMenuByArgs"
|
||||
:data="crud.data"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
row-key="id"
|
||||
@@ -199,14 +199,14 @@ export default {
|
||||
this.menus.push({ id: 0, label: '顶级类目', children: null })
|
||||
}
|
||||
},
|
||||
getMenus(tree, treeNode, resolve) {
|
||||
queryMenuByArgs(tree, treeNode, resolve) {
|
||||
const params = {
|
||||
page: 1,
|
||||
size: 999999,
|
||||
args: { pid: tree.id }
|
||||
}
|
||||
setTimeout(() => {
|
||||
crudMenu.getMenus(params).then(res => {
|
||||
crudMenu.queryMenuByArgs(params).then(res => {
|
||||
resolve(res.content)
|
||||
})
|
||||
}, 100)
|
||||
|
||||
@@ -148,7 +148,7 @@ export default {
|
||||
isLt2M = file.size / 1024 / 1024 < 100
|
||||
if (!isLt2M) {
|
||||
this.loading = false
|
||||
this.$message.error('上传文件大小不能超过 100MB!')
|
||||
this.$message.error('上传文件大小不能超过 100MB')
|
||||
}
|
||||
this.form.name = file.name
|
||||
return isLt2M
|
||||
|
||||
@@ -185,7 +185,7 @@ import crudUser from '@/api/system/user'
|
||||
import { isvalidPhone } from '@/utils/validate'
|
||||
import { queryDeptList, queryDeptSuperiorTree } from '@/api/system/dept'
|
||||
import { queryRoleList, getLevel } from '@/api/system/role'
|
||||
import { getAllJob } from '@/api/system/job'
|
||||
import { queryAllEnableJob } from '@/api/system/job'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
@@ -450,7 +450,7 @@ export default {
|
||||
},
|
||||
// 获取弹窗内岗位数据
|
||||
getJobs() {
|
||||
getAllJob().then(res => {
|
||||
queryAllEnableJob().then(res => {
|
||||
this.jobs = res.content
|
||||
}).catch(() => { })
|
||||
},
|
||||
|
||||
+6
-7
@@ -1,16 +1,15 @@
|
||||
package cn.odboy.core.controller;
|
||||
|
||||
import cn.odboy.core.constant.SystemCaptchaBizEnum;
|
||||
import cn.odboy.core.dal.model.SystemCheckEmailCaptchaArgs;
|
||||
import cn.odboy.core.service.SystemEmailService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -35,9 +34,9 @@ public class SystemCaptchaController {
|
||||
|
||||
@ApiOperation("验证码验证")
|
||||
@PostMapping(value = "/checkEmailCaptcha")
|
||||
public ResponseEntity<Void> checkEmailCaptcha(@RequestParam String email, @RequestParam String code, @RequestParam String codeBi) {
|
||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(codeBi);
|
||||
systemEmailService.checkEmailCaptcha(biEnum, email, code);
|
||||
public ResponseEntity<Void> checkEmailCaptcha(@Validated @RequestBody SystemCheckEmailCaptchaArgs args) {
|
||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||
systemEmailService.checkEmailCaptcha(biEnum, args.getEmail(), args.getCode());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -29,6 +29,12 @@ public class SystemDictDetailController {
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping
|
||||
public ResponseEntity<CsResultVo<List<SystemDictDetailTb>>> queryDictDetailByCrud(@Validated @RequestBody CsPageArgs<QuerySystemDictDetailArgs> args) {
|
||||
return queryDictDetailByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping(value = "/queryDictDetailByArgs")
|
||||
public ResponseEntity<CsResultVo<List<SystemDictDetailTb>>> queryDictDetailByArgs(@Validated @RequestBody CsPageArgs<QuerySystemDictDetailArgs> args) {
|
||||
QuerySystemDictDetailArgs criteria = args.getArgs();
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ public class SystemEmailController {
|
||||
private final SystemEmailService systemEmailService;
|
||||
|
||||
@ApiOperation("查询配置")
|
||||
@PostMapping(value = "/queryEmailConfig")
|
||||
public ResponseEntity<SystemEmailConfigTb> queryEmailConfig() {
|
||||
@PostMapping(value = "/getLastEmailConfig")
|
||||
public ResponseEntity<SystemEmailConfigTb> getLastEmailConfig() {
|
||||
return new ResponseEntity<>(systemEmailService.getLastEmailConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -37,7 +37,7 @@ public class SystemJobController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/queryAllEnableJob")
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemJobTb>>> queryJobByArgs(@Validated @RequestBody CsPageArgs<QuerySystemJobArgs> args) {
|
||||
QuerySystemJobArgs criteria = args.getArgs();
|
||||
@@ -45,6 +45,13 @@ public class SystemJobController {
|
||||
return new ResponseEntity<>(systemJobService.queryJobByArgs(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemJobTb>>> queryJobByCrud(@Validated @RequestBody CsPageArgs<QuerySystemJobArgs> args) {
|
||||
return queryJobByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping(value = "/saveJob")
|
||||
@PreAuthorize("@el.check('job:add')")
|
||||
|
||||
+7
@@ -68,6 +68,13 @@ public class SystemMenuController {
|
||||
@PostMapping
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemMenuTb>>> queryAllMenuByCrud(@Validated @RequestBody CsPageArgs<QuerySystemMenuArgs> args) throws Exception {
|
||||
return queryAllMenu(args);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/queryMenuByArgs")
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<CsResultVo<List<SystemMenuTb>>> queryAllMenu(@Validated @RequestBody CsPageArgs<QuerySystemMenuArgs> args) throws Exception {
|
||||
QuerySystemMenuArgs criteria = args.getArgs();
|
||||
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
||||
|
||||
+2
-2
@@ -98,8 +98,8 @@ public class SystemQiniuController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除多张图片")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Void> deleteAllQiNiu(@RequestBody Long[] ids) {
|
||||
@PostMapping(value = "/removeFileByIds")
|
||||
public ResponseEntity<Void> removeFileByIds(@RequestBody Long[] ids) {
|
||||
qiniuContentService.removeFileByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ public class SystemQuartzJobController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除定时任务")
|
||||
@DeleteMapping
|
||||
@PostMapping(value = "/removeJobByIds")
|
||||
@PreAuthorize("@el.check('quartzJob:del')")
|
||||
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
systemQuartzJobService.removeJobByIds(ids);
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package cn.odboy.core.dal.model;
|
||||
|
||||
import cn.odboy.base.CsSerializeObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SystemCheckEmailCaptchaArgs extends CsSerializeObject {
|
||||
@NotBlank(message = "邮箱不能为空")
|
||||
private String email;
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String code;
|
||||
@NotBlank(message = "验证码业务标识不能为空")
|
||||
private String bizCode;
|
||||
}
|
||||
Reference in New Issue
Block a user