| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.CaseMain; |
| | | import com.ruoyi.system.model.CaseMainFile; |
| | | import com.ruoyi.system.model.CaseType; |
| | | import com.ruoyi.system.query.CaseMainListQuery; |
| | | import com.ruoyi.system.query.CaseTypeListQuery; |
| | | import com.ruoyi.system.service.CaseMainFileService; |
| | | import com.ruoyi.system.service.CaseMainService; |
| | | import com.ruoyi.system.service.CaseTypeService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-10-16 |
| | | */ |
| | | @RestController |
| | | @Api(tags = "案件管理") |
| | | @RequestMapping("/case-main") |
| | | public class CaseMainController { |
| | | |
| | | @Resource |
| | | private CaseTypeService caseTypeService; |
| | | @Resource |
| | | private CaseMainService caseMainService; |
| | | @Resource |
| | | private CaseMainFileService caseMainFileService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | @ApiOperation(value = "案件分类不分页列表") |
| | | @PostMapping(value = "/listType") |
| | | public R<List<CaseType>> listType() { |
| | | return R.ok(caseTypeService.list()); |
| | | } |
| | | @ApiOperation(value = "案件分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<CaseMain>> pageList(@RequestBody CaseMainListQuery query) { |
| | | return R.ok(caseMainService.pageList(query)); |
| | | } |
| | | @ApiOperation(value = "添加") |
| | | @Transactional |
| | | @Log(title = "案件-添加", businessType = BusinessType.INSERT) |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> save(@RequestBody CaseMain entity) { |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | entity.setUpdateBy(sysUser.getNickName()); |
| | | caseMainService.save(entity); |
| | | List<CaseMainFile> list = entity.getList(); |
| | | for (CaseMainFile caseMainFile : list) { |
| | | caseMainFile.setCaseId(entity.getId()); |
| | | } |
| | | caseMainFileService.saveBatch(list); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "修改") |
| | | @Transactional |
| | | @Log(title = "案件-修改", businessType = BusinessType.UPDATE) |
| | | @PostMapping(value = "/edit") |
| | | public R<Boolean> edit(@RequestBody CaseMain entity) { |
| | | caseMainService.updateById(entity); |
| | | caseMainFileService.remove(new LambdaQueryWrapper<CaseMainFile>() |
| | | .eq(CaseMainFile::getCaseId, entity.getId())); |
| | | List<CaseMainFile> list = entity.getList(); |
| | | for (CaseMainFile caseMainFile : list) { |
| | | caseMainFile.setCaseId(entity.getId()); |
| | | } |
| | | caseMainFileService.saveBatch(list); |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "案件-删除", businessType = BusinessType.DELETE) |
| | | @Transactional |
| | | @ApiOperation(value = "案件-删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public R delete(@RequestParam String ids) { |
| | | caseMainService.removeBatchByIds(Arrays.asList(ids.split(","))); |
| | | caseMainFileService.remove(new LambdaQueryWrapper<CaseMainFile>() |
| | | .in(CaseMainFile::getCaseId, Arrays.asList(ids.split(",")))); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |