| | |
| | | package com.vincent.rsf.server.ai.controller; |
| | | |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.server.ai.entity.AiParam; |
| | | import com.vincent.rsf.server.ai.service.AiParamService; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AiParam, BaseParam> pageParam = new PageParam<>(baseParam, AiParam.class); |
| | | return R.ok().add(aiParamService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(aiParamService.page(pageParam, pageParam.buildWrapper(true) |
| | | .eq("tenant_id", getTenantId()) |
| | | .eq("deleted", 0))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiParam:list')") |
| | | @PostMapping("/aiParam/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(aiParamService.list()); |
| | | return R.ok().add(aiParamService.list(new LambdaQueryWrapper<AiParam>() |
| | | .eq(AiParam::getTenantId, getTenantId()) |
| | | .eq(AiParam::getDeleted, 0) |
| | | .orderByDesc(AiParam::getCreateTime) |
| | | .orderByDesc(AiParam::getId))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiParam:list')") |
| | | @PostMapping({"/aiParam/many/{ids}", "/aiParams/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(aiParamService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(aiParamService.list(new LambdaQueryWrapper<AiParam>() |
| | | .eq(AiParam::getTenantId, getTenantId()) |
| | | .eq(AiParam::getDeleted, 0) |
| | | .in(AiParam::getId, Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiParam:list')") |
| | | @GetMapping("/aiParam/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(aiParamService.getById(id)); |
| | | return R.ok().add(aiParamService.getOne(new LambdaQueryWrapper<AiParam>() |
| | | .eq(AiParam::getId, id) |
| | | .eq(AiParam::getTenantId, getTenantId()) |
| | | .eq(AiParam::getDeleted, 0) |
| | | .last("limit 1"))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAnyAuthority('system:aiParam:save','system:aiParam:update')") |
| | | @PostMapping("/aiParam/validate-draft") |
| | | public R validateDraft(@RequestBody AiParam aiParam) { |
| | | aiParam.setTenantId(getTenantId()); |
| | | return R.ok().add(aiParamService.validateDraft(aiParam, getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:aiParam:save')") |
| | | @OperationLog("Create AiParam") |
| | | @PostMapping("/aiParam/save") |
| | | public R save(@RequestBody AiParam aiParam) { |
| | | aiParamService.validateBeforeSave(aiParam); |
| | | aiParam.setTenantId(getTenantId()); |
| | | aiParamService.validateBeforeSave(aiParam, getTenantId()); |
| | | aiParam.setCreateBy(getLoginUserId()); |
| | | aiParam.setCreateTime(new Date()); |
| | | aiParam.setUpdateBy(getLoginUserId()); |
| | |
| | | @OperationLog("Update AiParam") |
| | | @PostMapping("/aiParam/update") |
| | | public R update(@RequestBody AiParam aiParam) { |
| | | aiParamService.validateBeforeUpdate(aiParam); |
| | | aiParam.setTenantId(getTenantId()); |
| | | aiParamService.validateBeforeUpdate(aiParam, getTenantId()); |
| | | aiParam.setUpdateBy(getLoginUserId()); |
| | | aiParam.setUpdateTime(new Date()); |
| | | if (!aiParamService.updateById(aiParam)) { |
| | |
| | | @PreAuthorize("hasAuthority('system:aiParam:list')") |
| | | @PostMapping("/aiParam/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(aiParamService.list(), AiParam.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(aiParamService.list(new LambdaQueryWrapper<AiParam>() |
| | | .eq(AiParam::getTenantId, getTenantId()) |
| | | .eq(AiParam::getDeleted, 0) |
| | | .orderByDesc(AiParam::getCreateTime) |
| | | .orderByDesc(AiParam::getId)), AiParam.class), response); |
| | | } |
| | | } |