This commit is contained in:
2025-05-22 10:27:57 +08:00
parent 9139457203
commit bfbde8a0f5
229 changed files with 11846 additions and 3588 deletions
@@ -0,0 +1,150 @@
package com.gxwebsoft.law.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.Area;
import com.gxwebsoft.common.system.service.AreaService;
import com.gxwebsoft.law.service.LawOrgService;
import com.gxwebsoft.law.entity.LawOrg;
import com.gxwebsoft.law.param.LawOrgParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 机构控制器
*
* @author LX
* @since 2025-04-14 00:35:34
*/
@Api(tags = "机构管理")
@RestController
@RequestMapping("/api/law/law-org")
public class LawOrgController extends BaseController {
@Resource
private LawOrgService lawOrgService;
@Resource
private AreaService areaService;
@ApiOperation("分页查询机构")
@GetMapping("/page")
public ApiResult<PageResult<LawOrg>> page(LawOrgParam param) {
// 使用关联查询
return success(lawOrgService.pageRel(param));
}
@ApiOperation("查询全部机构")
@GetMapping()
public ApiResult<List<LawOrg>> list(LawOrgParam param) {
// 使用关联查询
return success(lawOrgService.listRel(param));
}
@PreAuthorize("hasAuthority('law:lawOrg:list')")
@ApiOperation("根据id查询机构")
@GetMapping("/{id}")
public ApiResult<LawOrg> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(lawOrgService.getByIdRel(id));
}
@ApiOperation("添加机构")
@PostMapping()
public ApiResult<?> save(@RequestBody LawOrg lawOrg) {
if (lawOrg.getProvince() != null) {
Area province = areaService.getProvinceByName(lawOrg.getProvince());
if (province != null) {
lawOrg.setProvinceId(province.getId());
}
}
if (lawOrg.getCity() != null) {
Area city = areaService.getCityByName(lawOrg.getCity());
if (city != null) {
lawOrg.setCityId(city.getId());
}
}
if (lawOrg.getRegion() != null) {
Area region = areaService.getRegionByName(lawOrg.getRegion());
if (region != null) {
lawOrg.setAreaId(region.getId());
}
}
if (lawOrgService.save(lawOrg)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改机构")
@PutMapping()
public ApiResult<?> update(@RequestBody LawOrg lawOrg) {
if (lawOrg.getProvince() != null) {
Area province = areaService.getProvinceByName(lawOrg.getProvince());
if (province != null) {
lawOrg.setProvinceId(province.getId());
}
}
if (lawOrg.getCity() != null) {
Area city = areaService.getCityByName(lawOrg.getCity());
if (city != null) {
lawOrg.setCityId(city.getId());
}
}
if (lawOrg.getRegion() != null) {
Area region = areaService.getRegionByName(lawOrg.getRegion());
if (region != null) {
lawOrg.setAreaId(region.getId());
}
}
if (lawOrgService.updateById(lawOrg)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除机构")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (lawOrgService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加机构")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<LawOrg> list) {
if (lawOrgService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改机构")
@PutMapping("/batch")
public ApiResult<?> updateBatch(@RequestBody BatchParam<LawOrg> batchParam) {
if (batchParam.update(lawOrgService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除机构")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (lawOrgService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}