标签儿管理代码框架

This commit is contained in:
ZLI263
2025-12-03 08:15:13 +08:00
parent b9c278f529
commit 5453026309
9 changed files with 647 additions and 4 deletions

View File

@@ -303,14 +303,14 @@ public class AudioFileController {
if (audioFile == null || audioFile.isEmpty()) {
log.warn("处理Audio类型时文件为空尝试重新获取");
if (request instanceof org.springframework.web.multipart.MultipartHttpServletRequest) {
org.springframework.web.multipart.MultipartHttpServletRequest multipartRequest =
(org.springframework.web.multipart.MultipartHttpServletRequest) request;
org.springframework.web.multipart.MultipartHttpServletRequest multipartRequest =
(org.springframework.web.multipart.MultipartHttpServletRequest) request;
java.util.Iterator<String> fileNames = multipartRequest.getFileNames();
if (fileNames.hasNext()) {
String paramName = fileNames.next();
audioFile = multipartRequest.getFile(paramName);
log.info("重新获取到文件,参数名: {}, 文件名: {}, 大小: {} bytes",
paramName, audioFile != null ? audioFile.getOriginalFilename() : "null",
log.info("重新获取到文件,参数名: {}, 文件名: {}, 大小: {} bytes",
paramName, audioFile != null ? audioFile.getOriginalFilename() : "null",
audioFile != null ? audioFile.getSize() : 0);
}
}

View File

@@ -0,0 +1,159 @@
package com.rj.controller;
import com.rj.entity.IndustryTags;
import com.rj.service.IIndustryTagsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* <p>
* 行业标签表 前端控制器
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
@RestController
@RequestMapping("/api/industryTags")
@Tag(name = "行业标签", description = "行业标签相关接口")
@Slf4j
public class IndustryTagsController {
@Autowired
private IIndustryTagsService industryTagsService;
/**
* 根据条件分页查询行业标签列表
*/
@GetMapping("/list")
@Operation(summary = "分页查询行业标签列表", description = "根据条件分页查询行业标签信息列表,支持按所属行业、标签分类、标签名称查询")
public ResponseEntity<Map<String, Object>> getIndustryTagsList(
@Parameter(description = "页码", example = "1")
@RequestParam(defaultValue = "1") Integer current,
@Parameter(description = "每页大小", example = "10")
@RequestParam(defaultValue = "10") Integer size,
@Parameter(description = "所属行业(精确查询)")
@RequestParam(required = false) String industry,
@Parameter(description = "标签分类(精确查询)")
@RequestParam(required = false) String tagType,
@Parameter(description = "标签名称(模糊查询)")
@RequestParam(required = false) String tagName) {
Map<String, Object> result = industryTagsService.getIndustryTagsList(
current, size, industry, tagType, tagName);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据类型不分页查询行业标签列表
*/
@GetMapping("/listByType")
@Operation(summary = "根据类型查询行业标签列表", description = "根据标签分类查询行业标签列表(不分页),可选择性按所属行业筛选")
public ResponseEntity<Map<String, Object>> getIndustryTagsByType(
@Parameter(description = "标签分类", required = true)
@RequestParam String tagType,
@Parameter(description = "所属行业(可选,精确查询)")
@RequestParam(required = false) String industry) {
Map<String, Object> result = industryTagsService.getIndustryTagsByType(tagType, industry);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
String message = (String) result.get("message");
if (message != null && message.contains("不能为空")) {
return ResponseEntity.badRequest().body(result);
}
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据ID查询行业标签
*/
@GetMapping("/get/{id}")
@Operation(summary = "根据ID查询行业标签", description = "根据行业标签ID获取详细信息")
public ResponseEntity<Map<String, Object>> getIndustryTagsById(
@Parameter(description = "行业标签ID", required = true)
@PathVariable String id) {
Map<String, Object> result = industryTagsService.getIndustryTagsById(id);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.notFound().build();
}
}
/**
* 新增行业标签
*/
@PostMapping("/add")
@Operation(summary = "新增行业标签", description = "添加新的行业标签信息")
public ResponseEntity<Map<String, Object>> addIndustryTags(
@Parameter(description = "行业标签信息", required = true)
@RequestBody IndustryTags industryTags) {
Map<String, Object> result = industryTagsService.addIndustryTags(industryTags);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.badRequest().body(result);
}
}
/**
* 更新行业标签信息
*/
@PutMapping("/update")
@Operation(summary = "更新行业标签信息", description = "更新行业标签详细信息")
public ResponseEntity<Map<String, Object>> updateIndustryTags(
@Parameter(description = "行业标签信息", required = true)
@RequestBody IndustryTags industryTags) {
Map<String, Object> result = industryTagsService.updateIndustryTags(industryTags);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
String message = (String) result.get("message");
if (message != null && message.contains("不能为空")) {
return ResponseEntity.badRequest().body(result);
}
return ResponseEntity.badRequest().body(result);
}
}
/**
* 根据ID删除行业标签
*/
@DeleteMapping("/delete/{id}")
@Operation(summary = "删除行业标签", description = "根据行业标签ID删除信息")
public ResponseEntity<Map<String, Object>> deleteIndustryTags(
@Parameter(description = "行业标签ID", required = true)
@PathVariable String id) {
Map<String, Object> result = industryTagsService.deleteIndustryTags(id);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.badRequest().body(result);
}
}
}

View File

@@ -0,0 +1,61 @@
package com.rj.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 行业标签表
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("industry_tags")
@Schema(description = "行业标签表")
public class IndustryTags implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "UUID主键")
@TableId("id")
private String id;
@Schema(description = "所属行业")
@TableField("industry")
private String industry;
@Schema(description = "标签分类")
@TableField("tag_type")
private String tagType;
@Schema(description = "标签名称")
@TableField("tag_name")
private String tagName;
@Schema(description = "标签详情")
@TableField("tag_detail")
private String tagDetail;
@Schema(description = "备注")
@TableField("remark")
private String remark;
@Schema(description = "创建时间")
@TableField("create_time")
private LocalDateTime createTime;
@Schema(description = "修改时间")
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,17 @@
package com.rj.mapper;
import com.rj.entity.IndustryTags;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 行业标签表 Mapper 接口
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
public interface IndustryTagsMapper extends BaseMapper<IndustryTags> {
}

View File

@@ -0,0 +1,71 @@
package com.rj.service;
import com.rj.entity.IndustryTags;
import java.util.Map;
/**
* <p>
* 行业标签表 服务类
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
public interface IIndustryTagsService extends com.baomidou.mybatisplus.extension.service.IService<IndustryTags> {
/**
* 根据条件分页查询行业标签列表
*
* @param current 页码
* @param size 每页大小
* @param industry 所属行业
* @param tagType 标签分类
* @param tagName 标签名称(模糊查询)
* @return 分页结果
*/
Map<String, Object> getIndustryTagsList(Integer current, Integer size, String industry,
String tagType, String tagName);
/**
* 根据类型不分页查询行业标签列表
*
* @param tagType 标签分类
* @param industry 所属行业(可选)
* @return 查询结果
*/
Map<String, Object> getIndustryTagsByType(String tagType, String industry);
/**
* 根据ID查询行业标签
*
* @param id 行业标签ID
* @return 查询结果
*/
Map<String, Object> getIndustryTagsById(String id);
/**
* 新增行业标签
*
* @param industryTags 行业标签信息
* @return 操作结果
*/
Map<String, Object> addIndustryTags(IndustryTags industryTags);
/**
* 更新行业标签信息
*
* @param industryTags 行业标签信息
* @return 操作结果
*/
Map<String, Object> updateIndustryTags(IndustryTags industryTags);
/**
* 根据ID删除行业标签
*
* @param id 行业标签ID
* @return 操作结果
*/
Map<String, Object> deleteIndustryTags(String id);
}

View File

@@ -0,0 +1,262 @@
package com.rj.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rj.entity.IndustryTags;
import com.rj.mapper.IndustryTagsMapper;
import com.rj.service.IIndustryTagsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* <p>
* 行业标签表 服务实现类
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
@Slf4j
@Service
public class IndustryTagsServiceImpl extends ServiceImpl<IndustryTagsMapper, IndustryTags> implements IIndustryTagsService {
@Override
public Map<String, Object> getIndustryTagsList(Integer current, Integer size, String industry,
String tagType, String tagName) {
Map<String, Object> result = new HashMap<>();
try {
Page<IndustryTags> page = new Page<>(current, size);
LambdaQueryWrapper<IndustryTags> queryWrapper = buildQueryWrapper(industry, tagType, tagName);
Page<IndustryTags> industryTagsPage = this.page(page, queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
result.put("data", industryTagsPage.getRecords());
result.put("total", industryTagsPage.getTotal());
result.put("current", industryTagsPage.getCurrent());
result.put("size", industryTagsPage.getSize());
result.put("pages", industryTagsPage.getPages());
} catch (Exception e) {
log.error("查询行业标签列表异常", e);
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> getIndustryTagsByType(String tagType, String industry) {
Map<String, Object> result = new HashMap<>();
try {
LambdaQueryWrapper<IndustryTags> queryWrapper = new LambdaQueryWrapper<>();
// 必须指定标签类型
if (!StringUtils.hasText(tagType)) {
result.put("success", false);
result.put("message", "标签分类不能为空");
return result;
}
queryWrapper.eq(IndustryTags::getTagType, tagType);
// 如果指定了行业,则添加行业条件
if (StringUtils.hasText(industry)) {
queryWrapper.eq(IndustryTags::getIndustry, industry);
}
// 按创建时间倒序排列
queryWrapper.orderByDesc(IndustryTags::getCreateTime);
List<IndustryTags> industryTagsList = this.list(queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
result.put("data", industryTagsList);
result.put("count", industryTagsList.size());
} catch (Exception e) {
log.error("根据类型查询行业标签异常", e);
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> getIndustryTagsById(String id) {
Map<String, Object> result = new HashMap<>();
try {
IndustryTags industryTags = this.getById(id);
if (industryTags != null) {
result.put("success", true);
result.put("message", "查询成功");
result.put("data", industryTags);
} else {
result.put("success", false);
result.put("message", "行业标签不存在");
}
} catch (Exception e) {
log.error("查询行业标签异常", e);
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> addIndustryTags(IndustryTags industryTags) {
Map<String, Object> result = new HashMap<>();
try {
// 验证必填字段
if (!StringUtils.hasText(industryTags.getIndustry())) {
result.put("success", false);
result.put("message", "所属行业不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagType())) {
result.put("success", false);
result.put("message", "标签分类不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagName())) {
result.put("success", false);
result.put("message", "标签名称不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagDetail())) {
result.put("success", false);
result.put("message", "标签详情不能为空");
return result;
}
LocalDateTime now = LocalDateTime.now();
if (industryTags.getId() == null || industryTags.getId().trim().isEmpty()) {
industryTags.setId(UUID.randomUUID().toString());
}
industryTags.setCreateTime(now);
industryTags.setUpdateTime(now);
boolean success = this.save(industryTags);
if (success) {
result.put("success", true);
result.put("message", "行业标签添加成功");
result.put("data", industryTags);
} else {
result.put("success", false);
result.put("message", "行业标签添加失败");
}
} catch (Exception e) {
log.error("添加行业标签异常", e);
result.put("success", false);
result.put("message", "添加异常:" + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> updateIndustryTags(IndustryTags industryTags) {
Map<String, Object> result = new HashMap<>();
try {
if (industryTags.getId() == null || industryTags.getId().trim().isEmpty()) {
result.put("success", false);
result.put("message", "行业标签ID不能为空");
return result;
}
// 验证必填字段
if (!StringUtils.hasText(industryTags.getIndustry())) {
result.put("success", false);
result.put("message", "所属行业不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagType())) {
result.put("success", false);
result.put("message", "标签分类不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagName())) {
result.put("success", false);
result.put("message", "标签名称不能为空");
return result;
}
if (!StringUtils.hasText(industryTags.getTagDetail())) {
result.put("success", false);
result.put("message", "标签详情不能为空");
return result;
}
industryTags.setUpdateTime(LocalDateTime.now());
boolean success = this.updateById(industryTags);
if (success) {
result.put("success", true);
result.put("message", "行业标签信息更新成功");
result.put("data", industryTags);
} else {
result.put("success", false);
result.put("message", "行业标签信息更新失败");
}
} catch (Exception e) {
log.error("更新行业标签异常", e);
result.put("success", false);
result.put("message", "更新异常:" + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> deleteIndustryTags(String id) {
Map<String, Object> result = new HashMap<>();
try {
boolean success = this.removeById(id);
if (success) {
result.put("success", true);
result.put("message", "行业标签删除成功");
} else {
result.put("success", false);
result.put("message", "行业标签删除失败");
}
} catch (Exception e) {
log.error("删除行业标签异常", e);
result.put("success", false);
result.put("message", "删除异常:" + e.getMessage());
}
return result;
}
/**
* 构建查询条件
*/
private LambdaQueryWrapper<IndustryTags> buildQueryWrapper(String industry, String tagType, String tagName) {
LambdaQueryWrapper<IndustryTags> queryWrapper = new LambdaQueryWrapper<>();
// 添加所属行业查询条件
if (StringUtils.hasText(industry)) {
queryWrapper.eq(IndustryTags::getIndustry, industry.trim());
}
// 添加标签分类查询条件
if (StringUtils.hasText(tagType)) {
queryWrapper.eq(IndustryTags::getTagType, tagType.trim());
}
// 添加标签名称模糊查询条件
if (StringUtils.hasText(tagName)) {
queryWrapper.like(IndustryTags::getTagName, tagName.trim());
}
// 按创建时间倒序排列
queryWrapper.orderByDesc(IndustryTags::getCreateTime);
return queryWrapper;
}
}