|
|
@@ -0,0 +1,139 @@
|
|
|
+package cn.iocoder.yudao.module.guide.controller.admin.sights;
|
|
|
+
|
|
|
+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.annotations.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.guide.controller.admin.sights.vo.*;
|
|
|
+import cn.iocoder.yudao.module.guide.dal.dataobject.sights.SightsDO;
|
|
|
+import cn.iocoder.yudao.module.guide.dal.dataobject.sights.SightsI18nExtensionDO;
|
|
|
+import cn.iocoder.yudao.module.guide.service.sights.SightsService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 观光景点基本信息")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/guide/sights")
|
|
|
+@Validated
|
|
|
+public class SightsController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SightsService sightsService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建观光景点基本信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:create')")
|
|
|
+ public CommonResult<Long> createSights(@Valid @RequestBody SightsSaveReqVO createReqVO) {
|
|
|
+ return success(sightsService.createSights(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新观光景点基本信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:update')")
|
|
|
+ public CommonResult<Boolean> updateSights(@Valid @RequestBody SightsSaveReqVO updateReqVO) {
|
|
|
+ sightsService.updateSights(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除观光景点基本信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:delete')")
|
|
|
+ public CommonResult<Boolean> deleteSights(@RequestParam("id") Long id) {
|
|
|
+ sightsService.deleteSights(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得观光景点基本信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:query')")
|
|
|
+ public CommonResult<SightsRespVO> getSights(@RequestParam("id") Long id) {
|
|
|
+ SightsDO sights = sightsService.getSights(id);
|
|
|
+ return success(BeanUtils.toBean(sights, SightsRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得观光景点基本信息分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:query')")
|
|
|
+ public CommonResult<PageResult<SightsRespVO>> getSightsPage(@Valid SightsPageReqVO pageReqVO) {
|
|
|
+ PageResult<SightsDO> pageResult = sightsService.getSightsPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, SightsRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出观光景点基本信息 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportSightsExcel(@Valid SightsPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<SightsDO> list = sightsService.getSightsPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "观光景点基本信息.xls", "数据", SightsRespVO.class,
|
|
|
+ BeanUtils.toBean(list, SightsRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ // ==================== 子表(观光景点对语言扩充信息) ====================
|
|
|
+
|
|
|
+ @GetMapping("/sights-i18n-extension/page")
|
|
|
+ @Operation(summary = "获得观光景点对语言扩充信息分页")
|
|
|
+ @Parameter(name = "sightsId", description = "景点")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:query')")
|
|
|
+ public CommonResult<PageResult<SightsI18nExtensionDO>> getSightsI18nExtensionPage(PageParam pageReqVO,
|
|
|
+ @RequestParam("sightsId") Long sightsId) {
|
|
|
+ return success(sightsService.getSightsI18nExtensionPage(pageReqVO, sightsId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/sights-i18n-extension/create")
|
|
|
+ @Operation(summary = "创建观光景点对语言扩充信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:create')")
|
|
|
+ public CommonResult<Long> createSightsI18nExtension(@Valid @RequestBody SightsI18nExtensionDO sightsI18nExtension) {
|
|
|
+ return success(sightsService.createSightsI18nExtension(sightsI18nExtension));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/sights-i18n-extension/update")
|
|
|
+ @Operation(summary = "更新观光景点对语言扩充信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:update')")
|
|
|
+ public CommonResult<Boolean> updateSightsI18nExtension(@Valid @RequestBody SightsI18nExtensionDO sightsI18nExtension) {
|
|
|
+ sightsService.updateSightsI18nExtension(sightsI18nExtension);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/sights-i18n-extension/delete")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @Operation(summary = "删除观光景点对语言扩充信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:delete')")
|
|
|
+ public CommonResult<Boolean> deleteSightsI18nExtension(@RequestParam("id") Long id) {
|
|
|
+ sightsService.deleteSightsI18nExtension(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/sights-i18n-extension/get")
|
|
|
+ @Operation(summary = "获得观光景点对语言扩充信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('guide:sights:query')")
|
|
|
+ public CommonResult<SightsI18nExtensionDO> getSightsI18nExtension(@RequestParam("id") Long id) {
|
|
|
+ return success(sightsService.getSightsI18nExtension(id));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|