提交poiType表的增删查改方法
This commit is contained in:
parent
d38648d847
commit
8a0f4de277
|
@ -0,0 +1,95 @@
|
||||||
|
package cn.iocoder.yudao.module.map.controller.admin.poitypes;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import jakarta.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.map.controller.admin.poitypes.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.map.dal.dataobject.poitypes.PoiTypesDO;
|
||||||
|
import cn.iocoder.yudao.module.map.service.poitypes.PoiTypesService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - POI类型")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/map/poi-types")
|
||||||
|
@Validated
|
||||||
|
public class PoiTypesController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PoiTypesService poiTypesService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建POI类型")
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:create')")
|
||||||
|
public CommonResult<Long> createPoiTypes(@Valid @RequestBody PoiTypesSaveReqVO createReqVO) {
|
||||||
|
return success(poiTypesService.createPoiTypes(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新POI类型")
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:update')")
|
||||||
|
public CommonResult<Boolean> updatePoiTypes(@Valid @RequestBody PoiTypesSaveReqVO updateReqVO) {
|
||||||
|
poiTypesService.updatePoiTypes(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除POI类型")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:delete')")
|
||||||
|
public CommonResult<Boolean> deletePoiTypes(@RequestParam("id") Long id) {
|
||||||
|
poiTypesService.deletePoiTypes(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得POI类型")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:query')")
|
||||||
|
public CommonResult<PoiTypesRespVO> getPoiTypes(@RequestParam("id") Long id) {
|
||||||
|
PoiTypesDO poiTypes = poiTypesService.getPoiTypes(id);
|
||||||
|
return success(BeanUtils.toBean(poiTypes, PoiTypesRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得POI类型分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:query')")
|
||||||
|
public CommonResult<PageResult<PoiTypesRespVO>> getPoiTypesPage(@Valid PoiTypesPageReqVO pageReqVO) {
|
||||||
|
PageResult<PoiTypesDO> pageResult = poiTypesService.getPoiTypesPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, PoiTypesRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出POI类型 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('map:poi-types:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportPoiTypesExcel(@Valid PoiTypesPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<PoiTypesDO> list = poiTypesService.getPoiTypesPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "POI类型.xls", "数据", PoiTypesRespVO.class,
|
||||||
|
BeanUtils.toBean(list, PoiTypesRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package cn.iocoder.yudao.module.map.controller.admin.poitypes.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - POI类型分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PoiTypesPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "描述", example = "随便")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "类别编号", example = "2")
|
||||||
|
private String newType;
|
||||||
|
|
||||||
|
@Schema(description = "大类_中文")
|
||||||
|
private String bigCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_中文")
|
||||||
|
private String midCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_中文")
|
||||||
|
private String subCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "大类_英文")
|
||||||
|
private String bigCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_英文")
|
||||||
|
private String midCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_英文")
|
||||||
|
private String subCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package cn.iocoder.yudao.module.map.controller.admin.poitypes.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - POI类型 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class PoiTypesRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18981")
|
||||||
|
@ExcelProperty("编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "描述", example = "随便")
|
||||||
|
@ExcelProperty("描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "类别编号", example = "2")
|
||||||
|
@ExcelProperty("类别编号")
|
||||||
|
private String newType;
|
||||||
|
|
||||||
|
@Schema(description = "大类_中文")
|
||||||
|
@ExcelProperty("大类_中文")
|
||||||
|
private String bigCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_中文")
|
||||||
|
@ExcelProperty("中类_中文")
|
||||||
|
private String midCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_中文")
|
||||||
|
@ExcelProperty("小类_中文")
|
||||||
|
private String subCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "大类_英文")
|
||||||
|
@ExcelProperty("大类_英文")
|
||||||
|
private String bigCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_英文")
|
||||||
|
@ExcelProperty("中类_英文")
|
||||||
|
private String midCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_英文")
|
||||||
|
@ExcelProperty("小类_英文")
|
||||||
|
private String subCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package cn.iocoder.yudao.module.map.controller.admin.poitypes.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - POI类型新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class PoiTypesSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18981")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "描述", example = "随便")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "类别编号", example = "2")
|
||||||
|
private String newType;
|
||||||
|
|
||||||
|
@Schema(description = "大类_中文")
|
||||||
|
private String bigCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_中文")
|
||||||
|
private String midCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_中文")
|
||||||
|
private String subCategoryCn;
|
||||||
|
|
||||||
|
@Schema(description = "大类_英文")
|
||||||
|
private String bigCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "中类_英文")
|
||||||
|
private String midCategoryEn;
|
||||||
|
|
||||||
|
@Schema(description = "小类_英文")
|
||||||
|
private String subCategoryEn;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package cn.iocoder.yudao.module.map.dal.dataobject.poitypes;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POI类型 DO
|
||||||
|
*
|
||||||
|
* @author 安
|
||||||
|
*/
|
||||||
|
@TableName("map_poi_types")
|
||||||
|
@KeySequence("map_poi_types_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PoiTypesDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 类别编号
|
||||||
|
*/
|
||||||
|
private String newType;
|
||||||
|
/**
|
||||||
|
* 大类_中文
|
||||||
|
*/
|
||||||
|
private String bigCategoryCn;
|
||||||
|
/**
|
||||||
|
* 中类_中文
|
||||||
|
*/
|
||||||
|
private String midCategoryCn;
|
||||||
|
/**
|
||||||
|
* 小类_中文
|
||||||
|
*/
|
||||||
|
private String subCategoryCn;
|
||||||
|
/**
|
||||||
|
* 大类_英文
|
||||||
|
*/
|
||||||
|
private String bigCategoryEn;
|
||||||
|
/**
|
||||||
|
* 中类_英文
|
||||||
|
*/
|
||||||
|
private String midCategoryEn;
|
||||||
|
/**
|
||||||
|
* 小类_英文
|
||||||
|
*/
|
||||||
|
private String subCategoryEn;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package cn.iocoder.yudao.module.map.dal.mysql.poitypes;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.map.dal.dataobject.poitypes.PoiTypesDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.map.controller.admin.poitypes.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POI类型 Mapper
|
||||||
|
*
|
||||||
|
* @author 安
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PoiTypesMapper extends BaseMapperX<PoiTypesDO> {
|
||||||
|
|
||||||
|
default PageResult<PoiTypesDO> selectPage(PoiTypesPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<PoiTypesDO>()
|
||||||
|
.eqIfPresent(PoiTypesDO::getDescription, reqVO.getDescription())
|
||||||
|
.eqIfPresent(PoiTypesDO::getNewType, reqVO.getNewType())
|
||||||
|
.likeIfPresent(PoiTypesDO::getBigCategoryCn, reqVO.getBigCategoryCn())
|
||||||
|
.likeIfPresent(PoiTypesDO::getMidCategoryCn, reqVO.getMidCategoryCn())
|
||||||
|
.likeIfPresent(PoiTypesDO::getSubCategoryCn, reqVO.getSubCategoryCn())
|
||||||
|
.likeIfPresent(PoiTypesDO::getBigCategoryEn, reqVO.getBigCategoryEn())
|
||||||
|
.likeIfPresent(PoiTypesDO::getMidCategoryEn, reqVO.getMidCategoryEn())
|
||||||
|
.likeIfPresent(PoiTypesDO::getSubCategoryEn, reqVO.getSubCategoryEn())
|
||||||
|
.betweenIfPresent(PoiTypesDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(PoiTypesDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据分词查询的list结果,对每一个词进行CategoryCn字段的查询,返回NewType查询集合
|
||||||
|
default List<PoiTypesDO> selectByWords(List<String> words) {
|
||||||
|
LambdaQueryWrapperX<PoiTypesDO> pt = new LambdaQueryWrapperX<PoiTypesDO>();
|
||||||
|
// 循环添加查询条件 用or语句
|
||||||
|
boolean firstOr = true;
|
||||||
|
for (String word : words) {
|
||||||
|
if (firstOr) {
|
||||||
|
pt.like(PoiTypesDO::getBigCategoryCn, word)
|
||||||
|
.or()
|
||||||
|
.like(PoiTypesDO::getMidCategoryCn, word)
|
||||||
|
.or()
|
||||||
|
.like(PoiTypesDO::getSubCategoryCn, word);
|
||||||
|
firstOr = false;
|
||||||
|
} else {
|
||||||
|
pt.or().like(PoiTypesDO::getBigCategoryCn, word)
|
||||||
|
.or()
|
||||||
|
.like(PoiTypesDO::getMidCategoryCn, word)
|
||||||
|
.or()
|
||||||
|
.like(PoiTypesDO::getSubCategoryCn, word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectList(pt);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.map.dal.mysql.poitypes.PoiTypesMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue