新增场地信息管理功能,包括场地信息控制器、服务、数据模型及数据库表结构
This commit is contained in:
@@ -5,12 +5,15 @@ import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.domain.OutdoorFair;
|
||||
import com.ruoyi.cms.domain.OutdoorFairDictDataRequest;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
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.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,6 +42,9 @@ public class OutdoorFairController extends BaseController
|
||||
@Autowired
|
||||
private IOutdoorFairService outdoorFairService;
|
||||
|
||||
@Autowired
|
||||
private IVenueInfoService venueInfoService;
|
||||
|
||||
/**
|
||||
* 查询户外招聘会列表
|
||||
*/
|
||||
@@ -72,6 +78,7 @@ public class OutdoorFairController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody OutdoorFair outdoorFair)
|
||||
{
|
||||
fillVenueFields(outdoorFair);
|
||||
return toAjax(outdoorFairService.save(outdoorFair));
|
||||
}
|
||||
|
||||
@@ -84,6 +91,7 @@ public class OutdoorFairController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody OutdoorFair outdoorFair)
|
||||
{
|
||||
fillVenueFields(outdoorFair);
|
||||
return toAjax(outdoorFairService.updateById(outdoorFair));
|
||||
}
|
||||
|
||||
@@ -110,4 +118,17 @@ public class OutdoorFairController extends BaseController
|
||||
{
|
||||
return toAjax(outdoorFairService.insertOutdoorFairDictData(request.getDictType(), request.getDictLabel(), getUsername()));
|
||||
}
|
||||
|
||||
private void fillVenueFields(OutdoorFair outdoorFair)
|
||||
{
|
||||
if (outdoorFair.getVenueId() == null) {
|
||||
return;
|
||||
}
|
||||
VenueInfo venueInfo = venueInfoService.getById(outdoorFair.getVenueId());
|
||||
if (venueInfo == null) {
|
||||
throw new ServiceException("绑定场地不存在");
|
||||
}
|
||||
outdoorFair.setVenueName(venueInfo.getVenueName());
|
||||
outdoorFair.setBoothCount(venueInfo.getFloorCount() == null ? 0 : venueInfo.getFloorCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
import com.ruoyi.cms.domain.VenueInfoDictDataRequest;
|
||||
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.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 场地信息Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/venue-info")
|
||||
@Api(tags = "后台:场地信息维护")
|
||||
public class VenueInfoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IVenueInfoService venueInfoService;
|
||||
|
||||
/**
|
||||
* 查询场地信息列表
|
||||
*/
|
||||
@ApiOperation("查询场地信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VenueInfo venueInfo)
|
||||
{
|
||||
startPage();
|
||||
List<VenueInfo> list = venueInfoService.selectVenueInfoList(venueInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取场地信息详细信息
|
||||
*/
|
||||
@ApiOperation("获取场地信息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(venueInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增场地信息
|
||||
*/
|
||||
@ApiOperation("新增场地信息")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:add')")
|
||||
@Log(title = "场地信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody VenueInfo venueInfo)
|
||||
{
|
||||
fillHandleFields(venueInfo);
|
||||
return toAjax(venueInfoService.save(venueInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改场地信息
|
||||
*/
|
||||
@ApiOperation("修改场地信息")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:edit')")
|
||||
@Log(title = "场地信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody VenueInfo venueInfo)
|
||||
{
|
||||
fillHandleFields(venueInfo);
|
||||
return toAjax(venueInfoService.updateById(venueInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除场地信息
|
||||
*/
|
||||
@ApiOperation("删除场地信息")
|
||||
@PreAuthorize("@ss.hasPermi('cms:venueInfo:remove')")
|
||||
@Log(title = "场地信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(venueInfoService.removeByIds(Arrays.asList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增场地信息维护页面使用的字典项
|
||||
*/
|
||||
@ApiOperation("新增场地信息字典项")
|
||||
@PreAuthorize("@ss.hasAnyPermi('cms:venueInfo:add,cms:venueInfo:edit')")
|
||||
@Log(title = "场地信息字典项", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/dict-data")
|
||||
public AjaxResult addDictData(@Validated @RequestBody VenueInfoDictDataRequest request)
|
||||
{
|
||||
return toAjax(venueInfoService.insertVenueInfoDictData(request.getDictType(), request.getDictLabel(), getUsername()));
|
||||
}
|
||||
|
||||
private void fillHandleFields(VenueInfo venueInfo)
|
||||
{
|
||||
if (venueInfo.getHandleDate() == null) {
|
||||
venueInfo.setHandleDate(new Date());
|
||||
}
|
||||
if (StringUtils.isBlank(venueInfo.getHandler())) {
|
||||
venueInfo.setHandler(getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,14 @@ public class OutdoorFair extends BaseEntity
|
||||
@ApiModelProperty("举办区域")
|
||||
private String region;
|
||||
|
||||
@Excel(name = "绑定场地ID")
|
||||
@ApiModelProperty("绑定场地ID")
|
||||
private Long venueId;
|
||||
|
||||
@Excel(name = "绑定场地")
|
||||
@ApiModelProperty("绑定场地")
|
||||
private String venueName;
|
||||
|
||||
@Excel(name = "举办地址")
|
||||
@ApiModelProperty("举办地址")
|
||||
private String address;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.cms.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 场地信息对象 cms_venue_info
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("场地信息")
|
||||
@TableName("cms_venue_info")
|
||||
public class VenueInfo extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@Excel(name = "场地类型")
|
||||
@ApiModelProperty("场地类型")
|
||||
private String venueType;
|
||||
|
||||
@Excel(name = "场地名称")
|
||||
@ApiModelProperty("场地名称")
|
||||
private String venueName;
|
||||
|
||||
@Excel(name = "场地面积")
|
||||
@ApiModelProperty("场地面积")
|
||||
private BigDecimal venueArea;
|
||||
|
||||
@Excel(name = "展位数量")
|
||||
@ApiModelProperty("展位数量")
|
||||
private Integer floorCount;
|
||||
|
||||
@Excel(name = "场地地址")
|
||||
@ApiModelProperty("场地地址")
|
||||
private String venueAddress;
|
||||
|
||||
@Excel(name = "联系电话")
|
||||
@ApiModelProperty("联系电话")
|
||||
private String contactPhone;
|
||||
|
||||
@Excel(name = "乘坐线路ID")
|
||||
@ApiModelProperty("乘坐线路ID,多个用英文逗号分隔")
|
||||
private String routeLineIds;
|
||||
|
||||
@Excel(name = "乘坐线路")
|
||||
@ApiModelProperty("乘坐线路名称,多个用英文逗号分隔")
|
||||
private String routeLineNames;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "经办日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@ApiModelProperty("经办日期")
|
||||
private Date handleDate;
|
||||
|
||||
@Excel(name = "经办机构")
|
||||
@ApiModelProperty("经办机构")
|
||||
private String handleOrg;
|
||||
|
||||
@Excel(name = "经办人")
|
||||
@ApiModelProperty("经办人")
|
||||
private String handler;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.cms.domain;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 场地信息字典新增请求
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("场地信息字典新增请求")
|
||||
public class VenueInfoDictDataRequest
|
||||
{
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@ApiModelProperty(value = "字典类型", required = true)
|
||||
private String dictType;
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@ApiModelProperty(value = "字典标签", required = true)
|
||||
private String dictLabel;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 场地信息Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
public interface VenueInfoMapper extends BaseMapper<VenueInfo>
|
||||
{
|
||||
/**
|
||||
* 查询字典项是否存在
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @return 存在数量
|
||||
*/
|
||||
@Select("select count(1) from sys_dict_data where dict_type = #{dictType} and dict_value = #{dictValue}")
|
||||
int countDictDataByTypeAndValue(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
|
||||
|
||||
/**
|
||||
* 获取字典下一个排序
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 下一个排序值
|
||||
*/
|
||||
@Select("select coalesce(max(dict_sort), 0) + 1 from sys_dict_data where dict_type = #{dictType}")
|
||||
Long selectNextDictSort(@Param("dictType") String dictType);
|
||||
|
||||
/**
|
||||
* 新增系统字典项
|
||||
*
|
||||
* @param dictSort 字典排序
|
||||
* @param dictLabel 字典标签
|
||||
* @param dictValue 字典值
|
||||
* @param dictType 字典类型
|
||||
* @param createBy 创建人
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Insert("insert into sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, list_class, is_default, status, create_by, create_time, remark) " +
|
||||
"values ((select coalesce(max(dict_code), 0) + 1 from sys_dict_data), #{dictSort}, #{dictLabel}, #{dictValue}, #{dictType}, 'default', 'N', '0', #{createBy}, sysdate(), '场地信息维护页面新增')")
|
||||
int insertDictData(@Param("dictSort") Long dictSort,
|
||||
@Param("dictLabel") String dictLabel,
|
||||
@Param("dictValue") String dictValue,
|
||||
@Param("dictType") String dictType,
|
||||
@Param("createBy") String createBy);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
|
||||
/**
|
||||
* 场地信息Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
public interface IVenueInfoService extends IService<VenueInfo>
|
||||
{
|
||||
/**
|
||||
* 查询场地信息列表
|
||||
*
|
||||
* @param venueInfo 场地信息
|
||||
* @return 场地信息集合
|
||||
*/
|
||||
List<VenueInfo> selectVenueInfoList(VenueInfo venueInfo);
|
||||
|
||||
/**
|
||||
* 新增场地信息相关字典项
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @param createBy 创建人
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertVenueInfoDictData(String dictType, String dictLabel, String createBy);
|
||||
}
|
||||
@@ -39,6 +39,7 @@ public class OutdoorFairServiceImpl extends ServiceImpl<OutdoorFairMapper, Outdo
|
||||
queryWrapper.like(StringUtils.isNotBlank(outdoorFair.getHostUnit()), OutdoorFair::getHostUnit, outdoorFair.getHostUnit());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(outdoorFair.getFairType()), OutdoorFair::getFairType, outdoorFair.getFairType());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(outdoorFair.getRegion()), OutdoorFair::getRegion, outdoorFair.getRegion());
|
||||
queryWrapper.eq(outdoorFair.getVenueId() != null, OutdoorFair::getVenueId, outdoorFair.getVenueId());
|
||||
queryWrapper.orderByDesc(OutdoorFair::getHoldTime);
|
||||
queryWrapper.orderByDesc(OutdoorFair::getCreateTime);
|
||||
return list(queryWrapper);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.VenueInfo;
|
||||
import com.ruoyi.cms.mapper.VenueInfoMapper;
|
||||
import com.ruoyi.cms.service.IVenueInfoService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 场地信息Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@Service
|
||||
public class VenueInfoServiceImpl extends ServiceImpl<VenueInfoMapper, VenueInfo> implements IVenueInfoService
|
||||
{
|
||||
private static final String VENUE_TYPE_DICT = "venue_info_type";
|
||||
|
||||
/**
|
||||
* 查询场地信息列表
|
||||
*
|
||||
* @param venueInfo 场地信息
|
||||
* @return 场地信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<VenueInfo> selectVenueInfoList(VenueInfo venueInfo)
|
||||
{
|
||||
LambdaQueryWrapper<VenueInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotBlank(venueInfo.getVenueType()), VenueInfo::getVenueType, venueInfo.getVenueType());
|
||||
queryWrapper.like(StringUtils.isNotBlank(venueInfo.getVenueName()), VenueInfo::getVenueName, venueInfo.getVenueName());
|
||||
queryWrapper.like(StringUtils.isNotBlank(venueInfo.getVenueAddress()), VenueInfo::getVenueAddress, venueInfo.getVenueAddress());
|
||||
queryWrapper.orderByDesc(VenueInfo::getCreateTime);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增场地信息相关字典项
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @param createBy 创建人
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Override
|
||||
public int insertVenueInfoDictData(String dictType, String dictLabel, String createBy)
|
||||
{
|
||||
if (!VENUE_TYPE_DICT.equals(dictType)) {
|
||||
throw new ServiceException("只允许维护场地类型字典");
|
||||
}
|
||||
String trimmedLabel = StringUtils.trim(dictLabel);
|
||||
if (StringUtils.isBlank(trimmedLabel)) {
|
||||
throw new ServiceException("字典名称不能为空");
|
||||
}
|
||||
if (trimmedLabel.length() > 100) {
|
||||
throw new ServiceException("字典名称长度不能超过100个字符");
|
||||
}
|
||||
if (baseMapper.countDictDataByTypeAndValue(dictType, trimmedLabel) > 0) {
|
||||
return 1;
|
||||
}
|
||||
Long dictSort = baseMapper.selectNextDictSort(dictType);
|
||||
int rows = baseMapper.insertDictData(dictSort, trimmedLabel, trimmedLabel, dictType, createBy);
|
||||
if (rows > 0) {
|
||||
DictUtils.removeDictCache(dictType);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user