Merge branch 'main' of http://124.243.245.42:3000/zkr/shz-backend into main
This commit is contained in:
@@ -1,23 +1,38 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.cms.domain.FairCompany;
|
||||
import com.ruoyi.cms.domain.OutdoorFair;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBooth;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBoothBooking;
|
||||
import com.ruoyi.cms.domain.OutdoorFairDictDataRequest;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
import com.ruoyi.cms.mapper.FairCompanyMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothBookingMapper;
|
||||
import com.ruoyi.cms.mapper.CompanyMapper;
|
||||
import com.ruoyi.cms.service.IOutdoorFairService;
|
||||
import com.ruoyi.cms.service.IVenueInfoService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -45,6 +60,18 @@ public class OutdoorFairController extends BaseController
|
||||
@Autowired
|
||||
private IVenueInfoService venueInfoService;
|
||||
|
||||
@Autowired
|
||||
private FairCompanyMapper fairCompanyMapper;
|
||||
|
||||
@Autowired
|
||||
private CompanyMapper companyMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothBookingMapper outdoorFairBoothBookingMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothMapper outdoorFairBoothMapper;
|
||||
|
||||
/**
|
||||
* 查询户外招聘会列表
|
||||
*/
|
||||
@@ -75,11 +102,16 @@ public class OutdoorFairController extends BaseController
|
||||
@ApiOperation("新增户外招聘会")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:add')")
|
||||
@Log(title = "户外招聘会", businessType = BusinessType.INSERT)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody OutdoorFair outdoorFair)
|
||||
{
|
||||
fillVenueFields(outdoorFair);
|
||||
return toAjax(outdoorFairService.save(outdoorFair));
|
||||
boolean saved = outdoorFairService.save(outdoorFair);
|
||||
if (saved) {
|
||||
resetBoothSnapshot(outdoorFair, true);
|
||||
}
|
||||
return toAjax(saved);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,11 +120,18 @@ public class OutdoorFairController extends BaseController
|
||||
@ApiOperation("修改户外招聘会")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
|
||||
@Log(title = "户外招聘会", businessType = BusinessType.UPDATE)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody OutdoorFair outdoorFair)
|
||||
{
|
||||
OutdoorFair oldFair = outdoorFair.getId() == null ? null : outdoorFairService.getById(outdoorFair.getId());
|
||||
fillVenueFields(outdoorFair);
|
||||
return toAjax(outdoorFairService.updateById(outdoorFair));
|
||||
boolean updated = outdoorFairService.updateById(outdoorFair);
|
||||
if (updated) {
|
||||
boolean venueChanged = oldFair == null || !java.util.Objects.equals(oldFair.getVenueId(), outdoorFair.getVenueId());
|
||||
resetBoothSnapshot(outdoorFair, venueChanged);
|
||||
}
|
||||
return toAjax(updated);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +158,120 @@ public class OutdoorFairController extends BaseController
|
||||
return toAjax(outdoorFairService.insertOutdoorFairDictData(request.getDictType(), request.getDictLabel(), getUsername()));
|
||||
}
|
||||
|
||||
@ApiOperation("查询户外招聘会参会企业")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:query')")
|
||||
@GetMapping("/{fairId}/companies")
|
||||
public AjaxResult listCompanies(@PathVariable Long fairId, String companyName, Integer current, Integer pageSize)
|
||||
{
|
||||
List<FairCompany> relations = fairCompanyMapper.selectList(new LambdaQueryWrapper<FairCompany>()
|
||||
.eq(FairCompany::getJobFairId, fairId)
|
||||
.orderByDesc(FairCompany::getId));
|
||||
if (relations.isEmpty()) {
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.put("rows", new ArrayList<>());
|
||||
result.put("total", 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Long> companyIds = relations.stream().map(FairCompany::getCompanyId).collect(Collectors.toList());
|
||||
Map<Long, Company> companyMap = companyMapper.selectBatchIds(companyIds).stream()
|
||||
.collect(Collectors.toMap(Company::getCompanyId, item -> item, (a, b) -> a));
|
||||
Map<Long, OutdoorFairBoothBooking> bookingMap = outdoorFairBoothBookingMapper.selectList(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId)
|
||||
.eq(OutdoorFairBoothBooking::getStatus, "reserved"))
|
||||
.stream()
|
||||
.filter(item -> item.getCompanyId() != null)
|
||||
.collect(Collectors.toMap(OutdoorFairBoothBooking::getCompanyId, item -> item, (a, b) -> a));
|
||||
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
for (FairCompany relation : relations) {
|
||||
Company company = companyMap.get(relation.getCompanyId());
|
||||
if (company == null) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotBlank(companyName) && (company.getName() == null || !company.getName().contains(companyName))) {
|
||||
continue;
|
||||
}
|
||||
OutdoorFairBoothBooking booking = bookingMap.get(company.getCompanyId());
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("id", relation.getId());
|
||||
row.put("fairId", fairId);
|
||||
row.put("companyId", company.getCompanyId());
|
||||
row.put("companyName", company.getName());
|
||||
row.put("industry", company.getIndustry());
|
||||
row.put("scale", company.getScale());
|
||||
row.put("contactPerson", company.getContactPerson());
|
||||
row.put("contactPhone", company.getContactPersonPhone());
|
||||
row.put("boothId", booking == null ? null : booking.getBoothId());
|
||||
row.put("boothNumber", booking == null ? null : booking.getBoothNumber());
|
||||
row.put("jobList", new ArrayList<>());
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
int total = rows.size();
|
||||
int page = current == null || current < 1 ? 1 : current;
|
||||
int size = pageSize == null || pageSize < 1 ? 10 : pageSize;
|
||||
int fromIndex = Math.min((page - 1) * size, total);
|
||||
int toIndex = Math.min(fromIndex + size, total);
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.put("rows", rows.subList(fromIndex, toIndex));
|
||||
result.put("total", total);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("新增户外招聘会参会企业")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
|
||||
@PostMapping("/{fairId}/companies")
|
||||
public AjaxResult addCompany(@PathVariable Long fairId, @RequestBody Map<String, Object> request)
|
||||
{
|
||||
Long companyId = Long.valueOf(String.valueOf(request.get("companyId")));
|
||||
Company company = companyMapper.selectById(companyId);
|
||||
if (company == null || company.getStatus() == null || company.getStatus() != 1) {
|
||||
return AjaxResult.error("只能添加审核通过的企业");
|
||||
}
|
||||
ensureFairCompany(fairId, companyId);
|
||||
return success();
|
||||
}
|
||||
|
||||
@ApiOperation("移除户外招聘会参会企业")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
|
||||
@DeleteMapping("/{fairId}/companies/{id}")
|
||||
public AjaxResult removeCompany(@PathVariable Long fairId, @PathVariable Long id)
|
||||
{
|
||||
return toAjax(fairCompanyMapper.delete(new LambdaQueryWrapper<FairCompany>()
|
||||
.eq(FairCompany::getJobFairId, fairId)
|
||||
.eq(FairCompany::getId, id)));
|
||||
}
|
||||
|
||||
private void ensureFairCompany(Long fairId, Long companyId)
|
||||
{
|
||||
Long count = fairCompanyMapper.selectCount(new LambdaQueryWrapper<FairCompany>()
|
||||
.eq(FairCompany::getJobFairId, fairId)
|
||||
.eq(FairCompany::getCompanyId, companyId));
|
||||
if (count != null && count > 0) {
|
||||
return;
|
||||
}
|
||||
FairCompany fairCompany = new FairCompany();
|
||||
fairCompany.setJobFairId(fairId);
|
||||
fairCompany.setCompanyId(companyId);
|
||||
fairCompanyMapper.insert(fairCompany);
|
||||
}
|
||||
|
||||
private void resetBoothSnapshot(OutdoorFair outdoorFair, boolean forceRecreate)
|
||||
{
|
||||
if (outdoorFair.getId() == null) {
|
||||
return;
|
||||
}
|
||||
if (forceRecreate) {
|
||||
outdoorFairBoothBookingMapper.physicalDeleteByFairId(outdoorFair.getId());
|
||||
outdoorFairBoothMapper.physicalDeleteByFairId(outdoorFair.getId());
|
||||
}
|
||||
Long boothCount = outdoorFairBoothMapper.selectCount(new LambdaQueryWrapper<OutdoorFairBooth>()
|
||||
.eq(OutdoorFairBooth::getFairId, outdoorFair.getId()));
|
||||
outdoorFair.setBoothCount(boothCount == null ? 0 : boothCount.intValue());
|
||||
outdoorFairService.updateById(outdoorFair);
|
||||
}
|
||||
|
||||
private void fillVenueFields(OutdoorFair outdoorFair)
|
||||
{
|
||||
if (outdoorFair.getVenueId() == null) {
|
||||
@@ -129,6 +282,8 @@ public class OutdoorFairController extends BaseController
|
||||
throw new ServiceException("绑定场地不存在");
|
||||
}
|
||||
outdoorFair.setVenueName(venueInfo.getVenueName());
|
||||
outdoorFair.setBoothCount(venueInfo.getFloorCount() == null ? 0 : venueInfo.getFloorCount());
|
||||
if (outdoorFair.getBoothCount() == null) {
|
||||
outdoorFair.setBoothCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,16 @@ import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
import com.ruoyi.cms.domain.OutdoorFair;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBooth;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBoothBooking;
|
||||
import com.ruoyi.cms.domain.VenueBooth;
|
||||
import com.ruoyi.cms.domain.FairCompany;
|
||||
import com.ruoyi.cms.domain.VenueInfoDictDataRequest;
|
||||
import com.ruoyi.cms.domain.VenueBoothSwapRequest;
|
||||
import com.ruoyi.cms.mapper.CompanyMapper;
|
||||
import com.ruoyi.cms.mapper.FairCompanyMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothBookingMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairMapper;
|
||||
import com.ruoyi.cms.mapper.VenueBoothMapper;
|
||||
import com.ruoyi.cms.service.IVenueInfoService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@@ -57,18 +59,21 @@ public class VenueInfoController extends BaseController
|
||||
@Autowired
|
||||
private IVenueInfoService venueInfoService;
|
||||
|
||||
@Autowired
|
||||
private VenueBoothMapper venueBoothMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairMapper outdoorFairMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothBookingMapper outdoorFairBoothBookingMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothMapper outdoorFairBoothMapper;
|
||||
|
||||
@Autowired
|
||||
private CompanyMapper companyMapper;
|
||||
|
||||
@Autowired
|
||||
private FairCompanyMapper fairCompanyMapper;
|
||||
|
||||
/**
|
||||
* 查询场地信息列表
|
||||
*/
|
||||
@@ -143,78 +148,6 @@ public class VenueInfoController extends BaseController
|
||||
return toAjax(venueInfoService.insertVenueInfoDictData(request.getDictType(), request.getDictLabel(), getUsername()));
|
||||
}
|
||||
|
||||
@ApiOperation("查询场地展位图")
|
||||
@PreAuthorize("@ss.hasAnyPermi('cms:venueInfo:query,cms:outdoorFair:query')")
|
||||
@GetMapping("/{venueId}/booths")
|
||||
public AjaxResult listBooths(@PathVariable Long venueId)
|
||||
{
|
||||
List<VenueBooth> list = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
|
||||
.eq(VenueBooth::getVenueId, venueId)
|
||||
.orderByAsc(VenueBooth::getPositionY)
|
||||
.orderByAsc(VenueBooth::getPositionX)
|
||||
.orderByAsc(VenueBooth::getBoothNumber));
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("保存场地展位图")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:edit')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/{venueId}/booths")
|
||||
public AjaxResult saveBooths(@PathVariable Long venueId, @RequestBody List<VenueBooth> booths)
|
||||
{
|
||||
venueBoothMapper.physicalDeleteDeletedByVenueId(venueId);
|
||||
List<VenueBooth> existingBooths = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
|
||||
.eq(VenueBooth::getVenueId, venueId));
|
||||
Map<Long, VenueBooth> existingById = existingBooths.stream()
|
||||
.filter(item -> item.getId() != null)
|
||||
.collect(Collectors.toMap(VenueBooth::getId, item -> item, (a, b) -> a));
|
||||
Map<String, VenueBooth> existingByNumber = existingBooths.stream()
|
||||
.filter(item -> StringUtils.isNotBlank(item.getBoothNumber()))
|
||||
.collect(Collectors.toMap(VenueBooth::getBoothNumber, item -> item, (a, b) -> a));
|
||||
Set<String> boothNumbers = new HashSet<>();
|
||||
Set<Long> savedIds = new HashSet<>();
|
||||
if (booths != null) {
|
||||
for (VenueBooth booth : booths) {
|
||||
if (StringUtils.isBlank(booth.getBoothNumber())) {
|
||||
return AjaxResult.error("展位号不能为空");
|
||||
}
|
||||
if (!boothNumbers.add(booth.getBoothNumber())) {
|
||||
return AjaxResult.error("展位号不能重复:" + booth.getBoothNumber());
|
||||
}
|
||||
}
|
||||
for (VenueBooth booth : booths) {
|
||||
VenueBooth existing = booth.getId() == null ? null : existingById.get(booth.getId());
|
||||
if (existing == null) {
|
||||
existing = existingByNumber.get(booth.getBoothNumber());
|
||||
}
|
||||
booth.setVenueId(venueId);
|
||||
if (existing == null) {
|
||||
booth.setId(null);
|
||||
venueBoothMapper.insert(booth);
|
||||
} else {
|
||||
booth.setId(existing.getId());
|
||||
venueBoothMapper.updateById(booth);
|
||||
}
|
||||
if (booth.getId() != null) {
|
||||
savedIds.add(booth.getId());
|
||||
}
|
||||
}
|
||||
VenueInfo venueInfo = venueInfoService.getById(venueId);
|
||||
if (venueInfo != null) {
|
||||
venueInfo.setFloorCount(booths.size());
|
||||
venueInfoService.updateById(venueInfo);
|
||||
}
|
||||
}
|
||||
List<Long> removedIds = existingBooths.stream()
|
||||
.map(VenueBooth::getId)
|
||||
.filter(id -> id != null && !savedIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
if (!removedIds.isEmpty()) {
|
||||
venueBoothMapper.physicalDeleteByVenueIdAndIds(venueId, removedIds);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
@ApiOperation("查询户外招聘会展位图")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:query')")
|
||||
@GetMapping("/fair/{fairId}/booth-map")
|
||||
@@ -224,16 +157,16 @@ public class VenueInfoController extends BaseController
|
||||
if (fair == null || fair.getVenueId() == null) {
|
||||
return success(new ArrayList<>());
|
||||
}
|
||||
List<VenueBooth> booths = venueBoothMapper.selectList(new LambdaQueryWrapper<VenueBooth>()
|
||||
.eq(VenueBooth::getVenueId, fair.getVenueId())
|
||||
.orderByAsc(VenueBooth::getPositionY)
|
||||
.orderByAsc(VenueBooth::getPositionX)
|
||||
.orderByAsc(VenueBooth::getBoothNumber));
|
||||
List<OutdoorFairBooth> booths = outdoorFairBoothMapper.selectList(new LambdaQueryWrapper<OutdoorFairBooth>()
|
||||
.eq(OutdoorFairBooth::getFairId, fairId)
|
||||
.orderByAsc(OutdoorFairBooth::getPositionY)
|
||||
.orderByAsc(OutdoorFairBooth::getPositionX)
|
||||
.orderByAsc(OutdoorFairBooth::getBoothNumber));
|
||||
List<OutdoorFairBoothBooking> bookings = outdoorFairBoothBookingMapper.selectList(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId));
|
||||
Map<Long, OutdoorFairBoothBooking> bookingMap = bookings.stream().collect(Collectors.toMap(OutdoorFairBoothBooking::getBoothId, item -> item, (a, b) -> a));
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (VenueBooth booth : booths) {
|
||||
for (OutdoorFairBooth booth : booths) {
|
||||
OutdoorFairBoothBooking booking = bookingMap.get(booth.getId());
|
||||
Map<String, Object> row = new java.util.HashMap<>();
|
||||
row.put("id", booth.getId());
|
||||
@@ -250,8 +183,85 @@ public class VenueInfoController extends BaseController
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("保存户外招聘会展位图副本")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/fair/{fairId}/booths")
|
||||
public AjaxResult saveFairBooths(@PathVariable Long fairId, @RequestBody List<OutdoorFairBooth> booths)
|
||||
{
|
||||
OutdoorFair fair = outdoorFairMapper.selectById(fairId);
|
||||
if (fair == null || fair.getVenueId() == null) {
|
||||
return AjaxResult.error("当前招聘会未绑定场地");
|
||||
}
|
||||
List<OutdoorFairBooth> existingBooths = outdoorFairBoothMapper.selectList(new LambdaQueryWrapper<OutdoorFairBooth>()
|
||||
.eq(OutdoorFairBooth::getFairId, fairId));
|
||||
Map<Long, OutdoorFairBooth> existingById = existingBooths.stream()
|
||||
.filter(item -> item.getId() != null)
|
||||
.collect(Collectors.toMap(OutdoorFairBooth::getId, item -> item, (a, b) -> a));
|
||||
Map<String, OutdoorFairBooth> existingByNumber = existingBooths.stream()
|
||||
.filter(item -> StringUtils.isNotBlank(item.getBoothNumber()))
|
||||
.collect(Collectors.toMap(OutdoorFairBooth::getBoothNumber, item -> item, (a, b) -> a));
|
||||
Set<String> boothNumbers = new HashSet<>();
|
||||
Set<Long> savedIds = new HashSet<>();
|
||||
if (booths != null) {
|
||||
for (OutdoorFairBooth booth : booths) {
|
||||
if (StringUtils.isBlank(booth.getBoothNumber())) {
|
||||
return AjaxResult.error("展位号不能为空");
|
||||
}
|
||||
if (!boothNumbers.add(booth.getBoothNumber())) {
|
||||
return AjaxResult.error("展位号不能重复:" + booth.getBoothNumber());
|
||||
}
|
||||
}
|
||||
for (OutdoorFairBooth booth : booths) {
|
||||
OutdoorFairBooth existing = booth.getId() == null ? null : existingById.get(booth.getId());
|
||||
if (existing == null) {
|
||||
existing = existingByNumber.get(booth.getBoothNumber());
|
||||
}
|
||||
booth.setFairId(fairId);
|
||||
booth.setSourceVenueId(fair.getVenueId());
|
||||
if (existing == null) {
|
||||
booth.setId(null);
|
||||
outdoorFairBoothMapper.insert(booth);
|
||||
} else {
|
||||
booth.setId(existing.getId());
|
||||
if (booth.getSourceBoothId() == null) {
|
||||
booth.setSourceBoothId(existing.getSourceBoothId());
|
||||
}
|
||||
outdoorFairBoothMapper.updateById(booth);
|
||||
}
|
||||
if (booth.getId() != null) {
|
||||
savedIds.add(booth.getId());
|
||||
List<OutdoorFairBoothBooking> bookings = outdoorFairBoothBookingMapper.selectList(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId)
|
||||
.eq(OutdoorFairBoothBooking::getBoothId, booth.getId()));
|
||||
for (OutdoorFairBoothBooking booking : bookings) {
|
||||
booking.setBoothNumber(booth.getBoothNumber());
|
||||
outdoorFairBoothBookingMapper.updateById(booking);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Long> removedIds = existingBooths.stream()
|
||||
.map(OutdoorFairBooth::getId)
|
||||
.filter(id -> id != null && !savedIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
if (!removedIds.isEmpty()) {
|
||||
Long bookedRemovedCount = outdoorFairBoothBookingMapper.selectCount(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId)
|
||||
.in(OutdoorFairBoothBooking::getBoothId, removedIds));
|
||||
if (bookedRemovedCount != null && bookedRemovedCount > 0) {
|
||||
return AjaxResult.error("不能删除已预定展位,请先取消预定");
|
||||
}
|
||||
outdoorFairBoothMapper.physicalDeleteByFairIdAndIds(fairId, removedIds);
|
||||
}
|
||||
fair.setBoothCount(booths == null ? 0 : booths.size());
|
||||
outdoorFairMapper.updateById(fair);
|
||||
return success();
|
||||
}
|
||||
|
||||
@ApiOperation("预定户外招聘会展位")
|
||||
@PreAuthorize("@ss.hasPermi('cms:outdoorFair:edit')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/fair/{fairId}/booth-booking")
|
||||
public AjaxResult bookBooth(@PathVariable Long fairId, @RequestBody OutdoorFairBoothBooking booking)
|
||||
{
|
||||
@@ -262,20 +272,28 @@ public class VenueInfoController extends BaseController
|
||||
if (company == null || company.getStatus() == null || company.getStatus() != 1) {
|
||||
return AjaxResult.error("只能预定审核通过的企业");
|
||||
}
|
||||
VenueBooth booth = venueBoothMapper.selectById(booking.getBoothId());
|
||||
OutdoorFairBooth booth = outdoorFairBoothMapper.selectById(booking.getBoothId());
|
||||
if (booth == null || !fairId.equals(booth.getFairId())) {
|
||||
return AjaxResult.error("展位不存在或不属于当前招聘会");
|
||||
}
|
||||
booking.setFairId(fairId);
|
||||
booking.setBoothNumber(booth == null ? booking.getBoothNumber() : booth.getBoothNumber());
|
||||
booking.setBoothNumber(booth.getBoothNumber());
|
||||
booking.setCompanyName(company.getName());
|
||||
booking.setStatus(StringUtils.isBlank(booking.getStatus()) ? "reserved" : booking.getStatus());
|
||||
outdoorFairBoothBookingMapper.physicalDeleteDeletedByFairIdAndBoothId(fairId, booking.getBoothId());
|
||||
OutdoorFairBoothBooking existing = outdoorFairBoothBookingMapper.selectOne(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId)
|
||||
.eq(OutdoorFairBoothBooking::getBoothId, booking.getBoothId())
|
||||
.last("limit 1"));
|
||||
if (existing == null) {
|
||||
return toAjax(outdoorFairBoothBookingMapper.insert(booking));
|
||||
int rows = outdoorFairBoothBookingMapper.insert(booking);
|
||||
ensureFairCompany(fairId, booking.getCompanyId());
|
||||
return toAjax(rows);
|
||||
}
|
||||
booking.setId(existing.getId());
|
||||
return toAjax(outdoorFairBoothBookingMapper.updateById(booking));
|
||||
int rows = outdoorFairBoothBookingMapper.updateById(booking);
|
||||
ensureFairCompany(fairId, booking.getCompanyId());
|
||||
return toAjax(rows);
|
||||
}
|
||||
|
||||
@ApiOperation("取消户外招聘会展位预定")
|
||||
@@ -283,9 +301,7 @@ public class VenueInfoController extends BaseController
|
||||
@DeleteMapping("/fair/{fairId}/booth-booking/{boothId}")
|
||||
public AjaxResult cancelBooth(@PathVariable Long fairId, @PathVariable Long boothId)
|
||||
{
|
||||
return toAjax(outdoorFairBoothBookingMapper.delete(new LambdaQueryWrapper<OutdoorFairBoothBooking>()
|
||||
.eq(OutdoorFairBoothBooking::getFairId, fairId)
|
||||
.eq(OutdoorFairBoothBooking::getBoothId, boothId)));
|
||||
return toAjax(outdoorFairBoothBookingMapper.physicalDeleteByFairIdAndBoothId(fairId, boothId));
|
||||
}
|
||||
|
||||
@ApiOperation("调换户外招聘会展位")
|
||||
@@ -313,6 +329,20 @@ public class VenueInfoController extends BaseController
|
||||
return success();
|
||||
}
|
||||
|
||||
private void ensureFairCompany(Long fairId, Long companyId)
|
||||
{
|
||||
Long count = fairCompanyMapper.selectCount(new LambdaQueryWrapper<FairCompany>()
|
||||
.eq(FairCompany::getJobFairId, fairId)
|
||||
.eq(FairCompany::getCompanyId, companyId));
|
||||
if (count != null && count > 0) {
|
||||
return;
|
||||
}
|
||||
FairCompany fairCompany = new FairCompany();
|
||||
fairCompany.setJobFairId(fairId);
|
||||
fairCompany.setCompanyId(companyId);
|
||||
fairCompanyMapper.insert(fairCompany);
|
||||
}
|
||||
|
||||
private void fillHandleFields(VenueInfo venueInfo)
|
||||
{
|
||||
if (venueInfo.getHandleDate() == null) {
|
||||
|
||||
@@ -9,17 +9,23 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("场地展位")
|
||||
@TableName("cms_venue_booth")
|
||||
public class VenueBooth extends BaseEntity
|
||||
@ApiModel("户外招聘会展位副本")
|
||||
@TableName("cms_outdoor_fair_booth")
|
||||
public class OutdoorFairBooth extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("场地ID")
|
||||
private Long venueId;
|
||||
@ApiModelProperty("招聘会ID")
|
||||
private Long fairId;
|
||||
|
||||
@ApiModelProperty("来源场地ID")
|
||||
private Long sourceVenueId;
|
||||
|
||||
@ApiModelProperty("来源场地展位ID")
|
||||
private Long sourceBoothId;
|
||||
|
||||
@ApiModelProperty("展位号")
|
||||
private String boothNumber;
|
||||
@@ -2,7 +2,17 @@ package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBoothBooking;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface OutdoorFairBoothBookingMapper extends BaseMapper<OutdoorFairBoothBooking>
|
||||
{
|
||||
@Delete("DELETE FROM cms_outdoor_fair_booth_booking WHERE fair_id = #{fairId} AND booth_id = #{boothId} AND del_flag <> '0'")
|
||||
int physicalDeleteDeletedByFairIdAndBoothId(@Param("fairId") Long fairId, @Param("boothId") Long boothId);
|
||||
|
||||
@Delete("DELETE FROM cms_outdoor_fair_booth_booking WHERE fair_id = #{fairId} AND booth_id = #{boothId}")
|
||||
int physicalDeleteByFairIdAndBoothId(@Param("fairId") Long fairId, @Param("boothId") Long boothId);
|
||||
|
||||
@Delete("DELETE FROM cms_outdoor_fair_booth_booking WHERE fair_id = #{fairId}")
|
||||
int physicalDeleteByFairId(@Param("fairId") Long fairId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.OutdoorFairBooth;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OutdoorFairBoothMapper extends BaseMapper<OutdoorFairBooth>
|
||||
{
|
||||
@Delete("DELETE FROM cms_outdoor_fair_booth WHERE fair_id = #{fairId}")
|
||||
int physicalDeleteByFairId(@Param("fairId") Long fairId);
|
||||
|
||||
@Delete({
|
||||
"<script>",
|
||||
"DELETE FROM cms_outdoor_fair_booth WHERE fair_id = #{fairId} AND id IN",
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
|
||||
"#{id}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int physicalDeleteByFairIdAndIds(@Param("fairId") Long fairId, @Param("ids") List<Long> ids);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.VenueBooth;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface VenueBoothMapper extends BaseMapper<VenueBooth>
|
||||
{
|
||||
@Delete("DELETE FROM cms_venue_booth WHERE venue_id = #{venueId} AND del_flag <> '0'")
|
||||
int physicalDeleteDeletedByVenueId(@Param("venueId") Long venueId);
|
||||
|
||||
@Delete({
|
||||
"<script>",
|
||||
"DELETE FROM cms_venue_booth WHERE venue_id = #{venueId} AND id IN",
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
|
||||
"#{id}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int physicalDeleteByVenueIdAndIds(@Param("venueId") Long venueId, @Param("ids") List<Long> ids);
|
||||
}
|
||||
@@ -100,22 +100,42 @@ public class InterviewInvitationServiceImpl implements InterviewInvitationServic
|
||||
log.info("interview_invitation 表创建成功(序列自增)!");
|
||||
} else {
|
||||
log.info("interview_invitation 表结构正常,检查新增列...");
|
||||
// 为已有数据库添加新列(幂等操作,使用 DO 块兼容不支持 IF NOT EXISTS 的数据库版本)
|
||||
try {
|
||||
stmt.execute("DO $$ BEGIN ALTER TABLE interview_invitation ADD COLUMN company_name varchar(200) NULL; EXCEPTION WHEN duplicate_column THEN END; $$;");
|
||||
} catch (Exception e) { log.warn("添加 company_name 列失败: {}", e.getMessage()); }
|
||||
try {
|
||||
stmt.execute("DO $$ BEGIN ALTER TABLE interview_invitation ADD COLUMN job_name varchar(200) NULL; EXCEPTION WHEN duplicate_column THEN END; $$;");
|
||||
} catch (Exception e) { log.warn("添加 job_name 列失败: {}", e.getMessage()); }
|
||||
try {
|
||||
stmt.execute("DO $$ BEGIN ALTER TABLE interview_invitation ADD COLUMN interviewer_name varchar(100) NULL; EXCEPTION WHEN duplicate_column THEN END; $$;");
|
||||
} catch (Exception e) { log.warn("添加 interviewer_name 列失败: {}", e.getMessage()); }
|
||||
// 为已有数据库添加新列:先查 information_schema 判断列是否存在,存在则跳过
|
||||
// 不使用 IF NOT EXISTS / DO $$ 语法,因为 Druid 1.2.23 StatFilter 无法解析这些 PG 扩展语法
|
||||
addColumnIfNotExists(stmt, "interview_invitation", "company_name", "varchar(200) NULL");
|
||||
addColumnIfNotExists(stmt, "interview_invitation", "job_name", "varchar(200) NULL");
|
||||
addColumnIfNotExists(stmt, "interview_invitation", "interviewer_name", "varchar(100) NULL");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("初始化表失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 幂等添加列:先查 information_schema 判断列是否存在,不存在才执行 ALTER TABLE ADD COLUMN
|
||||
* 不使用 IF NOT EXISTS / DO $$ 语法,避免 Druid StatFilter mergeSql 报错
|
||||
*/
|
||||
private void addColumnIfNotExists(Statement stmt, String tableName, String columnName, String columnDef) {
|
||||
try {
|
||||
String checkSql = "SELECT COUNT(*) FROM information_schema.columns WHERE table_name='" + tableName + "' AND column_name='" + columnName + "'";
|
||||
java.sql.ResultSet rs = stmt.executeQuery(checkSql);
|
||||
boolean exists = false;
|
||||
if (rs.next()) {
|
||||
exists = rs.getInt(1) > 0;
|
||||
}
|
||||
rs.close();
|
||||
if (!exists) {
|
||||
String alterSql = "ALTER TABLE " + tableName + " ADD COLUMN " + columnName + " " + columnDef;
|
||||
stmt.execute(alterSql);
|
||||
log.info("成功添加列: {}.{}", tableName, columnName);
|
||||
} else {
|
||||
log.info("列已存在,跳过: {}.{}", tableName, columnName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("添加列 {}.{} 失败: {}", tableName, columnName, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InterviewInvitation> getInterviewInvitationList(InterviewInvitation interviewInvitation) {
|
||||
return interviewInvitationMapper.getInterviewInvitationList(interviewInvitation);
|
||||
|
||||
Reference in New Issue
Block a user