refactor(api): 重构API端点和前端CRUD配置
This commit is contained in:
@@ -29,7 +29,7 @@ export function edit(data) {
|
||||
|
||||
export function queryDeptList(params) {
|
||||
return request({
|
||||
url: 'api/dept',
|
||||
url: 'api/dept/queryAllDeptByArgs',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ export function get(dictName) {
|
||||
}
|
||||
}
|
||||
return request({
|
||||
url: 'api/dictDetail/queryDictDetailByArgs',
|
||||
url: 'api/dictDetail/searchDictDetail',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ export function queryAllEnableJob() {
|
||||
}
|
||||
}
|
||||
return request({
|
||||
url: 'api/job/queryAllEnableJob',
|
||||
url: 'api/job/searchJob',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -36,7 +36,7 @@ export function queryMenuListByPid(pid) {
|
||||
|
||||
export function queryMenuByArgs(params) {
|
||||
return request({
|
||||
url: 'api/menu/queryMenuByArgs',
|
||||
url: 'api/menu/queryAllMenu',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
|
||||
@@ -20,8 +20,8 @@ export function del(ids) {
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/quartzJob',
|
||||
method: 'put',
|
||||
url: 'api/quartzJob/updateQuartzJobResumeCron',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@ function CRUD(options) {
|
||||
idField: 'id',
|
||||
// 标题
|
||||
title: '',
|
||||
// 请求数据的url
|
||||
// 请求数据的url, @Controller注解的路径
|
||||
url: '',
|
||||
// 分页查询路由,@PostMapping注解的路径
|
||||
searchRouter: '',
|
||||
// 表格数据
|
||||
data: [],
|
||||
// 选择项
|
||||
@@ -134,7 +136,7 @@ function CRUD(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
crud.loading = true
|
||||
// 请求数据
|
||||
initData(crud.url, crud.getQueryParams()).then(data => {
|
||||
initData(crud.url + crud.searchRouter, crud.getQueryParams()).then(data => {
|
||||
const table = crud.getTable()
|
||||
if (table && table.lazy) { // 懒加载子节点数据,清掉已加载的数据
|
||||
table.store.states.treeData = {}
|
||||
|
||||
@@ -140,7 +140,7 @@ export default {
|
||||
name: 'Dept',
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '部门', url: 'api/dept', crudMethod: { ...crudDept }})
|
||||
return CRUD({ title: '部门', url: 'api/dept', searchRouter: '/queryAllDeptByArgs', crudMethod: { ...crudDept }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
// 设置数据字典
|
||||
|
||||
@@ -84,7 +84,7 @@ export default {
|
||||
cruds() {
|
||||
return [
|
||||
CRUD({
|
||||
title: '字典详情', url: 'api/dictDetail', query: { dictName: '' },
|
||||
title: '字典详情', url: 'api/dictDetail', searchRouter: '/searchDictDetail', query: { dictName: '' },
|
||||
crudMethod: { ...crudDictDetail },
|
||||
optShow: {
|
||||
add: true,
|
||||
|
||||
@@ -114,7 +114,7 @@ export default {
|
||||
components: { crudOperation, pagination, rrOperation, udOperation, dictDetail },
|
||||
cruds() {
|
||||
return [
|
||||
CRUD({ title: '字典', url: 'api/dict', crudMethod: { ...crudDict }})
|
||||
CRUD({ title: '字典', url: 'api/dict', searchRouter: '/searchDict', crudMethod: { ...crudDict }})
|
||||
]
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm)],
|
||||
|
||||
@@ -70,6 +70,7 @@ export default {
|
||||
return CRUD({
|
||||
title: '岗位',
|
||||
url: 'api/job',
|
||||
searchRouter: '/searchJob',
|
||||
crudMethod: { ...crudJob }
|
||||
})
|
||||
},
|
||||
|
||||
@@ -239,7 +239,7 @@ export default {
|
||||
name: 'Menu',
|
||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '菜单', url: 'api/menu', crudMethod: { ...crudMenu }})
|
||||
return CRUD({ title: '菜单', url: 'api/menu', searchRouter: '/queryAllMenu', crudMethod: { ...crudMenu }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
name: 'OnlineUser',
|
||||
components: { pagination, crudOperation, rrOperation },
|
||||
cruds() {
|
||||
return CRUD({ url: 'api/user/online', title: '在线用户' })
|
||||
return CRUD({ url: 'api/user/online', searchRouter: '/searchOnlineUser', title: '在线用户' })
|
||||
},
|
||||
mixins: [presenter(), header(), crud()],
|
||||
data() {
|
||||
|
||||
@@ -192,7 +192,7 @@ export default {
|
||||
name: 'QuartzJob',
|
||||
components: { Log, pagination, crudOperation, rrOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '定时任务', url: 'api/quartzJob', crudMethod: { ...crudJob }})
|
||||
return CRUD({ title: '定时任务', url: 'api/quartzJob', searchRouter: '/searchQuartzJob', crudMethod: { ...crudJob }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
|
||||
@@ -109,7 +109,7 @@ export default {
|
||||
},
|
||||
// 获取数据前设置好接口地址
|
||||
beforeInit() {
|
||||
this.url = 'api/quartzJob/logs'
|
||||
this.url = 'api/quartzJob/searchQuartzLog'
|
||||
this.size = 6
|
||||
return true
|
||||
},
|
||||
|
||||
@@ -168,7 +168,7 @@ export default {
|
||||
name: 'Role',
|
||||
components: { Treeselect, pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '角色', url: 'api/role', crudMethod: { ...crudRoles }})
|
||||
return CRUD({ title: '角色', url: 'api/role', searchRouter: '/searchRole', crudMethod: { ...crudRoles }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
|
||||
@@ -136,7 +136,7 @@ const defaultForm = { id: null, name: '' }
|
||||
export default {
|
||||
components: { pagination, crudOperation, rrOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '文件', url: 'api/localStorage', crudMethod: { ...crudFile }})
|
||||
return CRUD({ title: '文件', url: 'api/localStorage', searchRouter: '/searchLocalStorage', crudMethod: { ...crudFile }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
|
||||
@@ -107,7 +107,7 @@ const defaultForm = { id: null }
|
||||
export default {
|
||||
components: { pagination, crudOperation, rrOperation, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '文件', url: 'api/ossStorage', crudMethod: { ...crudFile }})
|
||||
return CRUD({ title: '文件', url: 'api/ossStorage', searchRouter: '/searchOssStorage', crudMethod: { ...crudFile }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
|
||||
@@ -228,7 +228,7 @@ export default {
|
||||
name: 'User',
|
||||
components: { CuteDeptTree, Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', url: 'api/user', crudMethod: { ...crudUser }})
|
||||
return CRUD({ title: '用户', url: 'api/user', searchRouter: '/aggregationSearchUserByArgs', crudMethod: { ...crudUser }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
// 数据字典
|
||||
|
||||
-7
@@ -59,13 +59,6 @@ public class SystemAuthController {
|
||||
return ResponseEntity.ok(userInfoVo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取验证码")
|
||||
@AnonymousPostMapping(value = "/captcha/getImage")
|
||||
public ResponseEntity<Map<String, Object>> getCode() {
|
||||
Map<String, Object> imgResult = systemAuthService.getCaptchaInfo();
|
||||
return ResponseEntity.ok(imgResult);
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@AnonymousPostMapping(value = "/logout")
|
||||
public ResponseEntity<Void> logout(HttpServletRequest request) {
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class SystemDeptController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/queryAllDeptByArgs")
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> pageArgs) throws Exception {
|
||||
|
||||
+3
-6
@@ -20,7 +20,6 @@ import cn.odboy.base.KitPageResult;
|
||||
import cn.odboy.system.dal.dataobject.SystemDictTb;
|
||||
import cn.odboy.system.dal.model.SystemCreateDictArgs;
|
||||
import cn.odboy.system.dal.model.SystemQueryDictArgs;
|
||||
import cn.odboy.system.service.SystemDictDetailService;
|
||||
import cn.odboy.system.service.SystemDictService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -46,8 +45,6 @@ public class SystemDictController {
|
||||
|
||||
@Autowired
|
||||
private SystemDictService systemDictService;
|
||||
@Autowired
|
||||
private SystemDictDetailService systemDictDetailService;
|
||||
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@@ -56,15 +53,15 @@ public class SystemDictController {
|
||||
systemDictService.exportDictXlsx(response, args);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@ApiOperation("查询所有字典")
|
||||
@PostMapping(value = "/queryAllDict")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(new SystemQueryDictArgs()));
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典")
|
||||
@PostMapping
|
||||
@ApiOperation("分页查询字典")
|
||||
@PostMapping(value = "/searchDict")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> pageArgs) {
|
||||
|
||||
+1
-8
@@ -47,14 +47,7 @@ public class SystemDictDetailController {
|
||||
private SystemDictDetailService systemDictDetailService;
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||
return queryDictDetailByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@PostMapping(value = "/queryDictDetailByArgs")
|
||||
@PostMapping(value = "/searchDictDetail")
|
||||
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> pageArgs) {
|
||||
Page<SystemDictDetailTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
|
||||
|
||||
+2
-10
@@ -52,8 +52,8 @@ public class SystemJobController {
|
||||
systemJobService.exportJobXlsx(response, args);
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping(value = "/queryAllEnableJob")
|
||||
@ApiOperation("分页查询岗位")
|
||||
@PostMapping(value = "/searchJob")
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> pageArgs) {
|
||||
@@ -61,14 +61,6 @@ public class SystemJobController {
|
||||
return ResponseEntity.ok(systemJobService.searchJobByArgs(pageArgs.getArgs(), page));
|
||||
}
|
||||
|
||||
@ApiOperation("查询岗位")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('job:list','user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||
return queryJobByArgs(args);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping(value = "/saveJob")
|
||||
@PreAuthorize("@el.check('job:add')")
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class SystemLocalStorageController {
|
||||
private SystemLocalStorageService localStorageService;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/searchLocalStorage")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<KitPageResult<SystemLocalStorageTb>> queryLocalStorage(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> pageArgs) {
|
||||
|
||||
+1
-9
@@ -77,15 +77,7 @@ public class SystemMenuController {
|
||||
return ResponseEntity.ok(ids);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenuByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||
return queryAllMenu(args);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/queryMenuByArgs")
|
||||
@PostMapping(value = "/queryAllMenu")
|
||||
@ApiOperation("查询菜单")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenu(
|
||||
|
||||
+2
-2
@@ -44,12 +44,12 @@ public class SystemOnlineController {
|
||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||
|
||||
@ApiOperation("查询在线用户")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/searchOnlineUser")
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<KitPageResult<SystemUserOnlineVo>> queryOnlineUser(
|
||||
@Validated @RequestBody KitPageArgs<SystemUserOnlineVo> pageArgs) {
|
||||
IPage<SystemUserOnlineVo> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
|
||||
return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(pageArgs.getArgs(), page));
|
||||
return ResponseEntity.ok(systemUserOnlineInfoDAO.searchOnlineUser(pageArgs.getArgs(), page));
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class SystemOssStorageController {
|
||||
private SystemOssStorageService systemOssStorageService;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/searchOssStorage")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<KitPageResult<SystemOssStorageVo>> queryOssStorage(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> pageArgs) {
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ public class SystemQuartzJobController {
|
||||
private SystemQuartzJobService systemQuartzJobService;
|
||||
|
||||
@ApiOperation("查询定时任务")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/searchQuartzJob")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<KitPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> pageArgs) {
|
||||
@@ -73,7 +73,7 @@ public class SystemQuartzJobController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询任务执行日志")
|
||||
@PostMapping(value = "/logs")
|
||||
@PostMapping(value = "/searchQuartzLog")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) {
|
||||
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
@@ -89,7 +89,7 @@ public class SystemQuartzJobController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改定时任务")
|
||||
@PutMapping
|
||||
@PostMapping(value = "/updateQuartzJobResumeCron")
|
||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||
public ResponseEntity<Void> updateQuartzJob(
|
||||
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ public class SystemRoleController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/searchRole")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs(
|
||||
@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> pageArgs) {
|
||||
@@ -79,9 +79,9 @@ public class SystemRoleController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户级别")
|
||||
@PostMapping(value = "/queryRoleLevel")
|
||||
public ResponseEntity<Dict> queryRoleLevel() {
|
||||
return ResponseEntity.ok(systemRoleService.getRoleLevel());
|
||||
@PostMapping(value = "/getCurrentUserRoleLevel")
|
||||
public ResponseEntity<Dict> getCurrentUserRoleLevel() {
|
||||
return ResponseEntity.ok(systemRoleService.getCurrentUserRoleLevel());
|
||||
}
|
||||
|
||||
@ApiOperation("新增角色")
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class SystemUserController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/aggregationSearchUserByArgs")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public ResponseEntity<KitPageResult<SystemUserVo>> queryUserByArgs(@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> pageArgs) {
|
||||
String currentUsername = KitSecurityHelper.getCurrentUsername();
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public class SystemUserOnlineInfoDAO {
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
public KitPageResult<SystemUserOnlineVo> queryUserOnlineModelPage(SystemUserOnlineVo onlineVo,
|
||||
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo,
|
||||
IPage<SystemUserOnlineVo> pageable) {
|
||||
String username = null;
|
||||
if (onlineVo != null) {
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ public class SystemRoleService {
|
||||
return systemUserRoleService.convertToRoleVo(roleTb);
|
||||
}
|
||||
|
||||
public Dict getRoleLevel() {
|
||||
public Dict getCurrentUserRoleLevel() {
|
||||
return Dict.create().set("level", checkRoleLevels(null));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user