文件上传https

This commit is contained in:
chen-xin-zhi 2025-03-18 19:31:30 +08:00
parent ba4553cf62
commit d1bddaf892
14 changed files with 432 additions and 20 deletions

View File

@ -34,6 +34,7 @@ import com.cultural.heritage.service.book.BookingDateService;
import com.cultural.heritage.service.book.BookingTimeService; import com.cultural.heritage.service.book.BookingTimeService;
import com.cultural.heritage.service.book.PhotoProductsService; import com.cultural.heritage.service.book.PhotoProductsService;
import com.cultural.heritage.service.common.CommonService; import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.utils.DecoderUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -321,6 +322,7 @@ public class PhotoProductsController {
PhotoProducts photoProducts = photoProductsService.getById(id); PhotoProducts photoProducts = photoProductsService.getById(id);
PhotoProductsMainInfoVO photoProductsMainInfoVO = new PhotoProductsMainInfoVO(); PhotoProductsMainInfoVO photoProductsMainInfoVO = new PhotoProductsMainInfoVO();
BeanUtils.copyProperties(photoProducts, photoProductsMainInfoVO); BeanUtils.copyProperties(photoProducts, photoProductsMainInfoVO);
photoProductsMainInfoVO.setRichText(DecoderUtils.decodeText(photoProductsMainInfoVO.getRichText()));
return ResultUtils.success(photoProductsMainInfoVO); return ResultUtils.success(photoProductsMainInfoVO);
} }
@ -420,6 +422,7 @@ public class PhotoProductsController {
// 封装成BookingPhotoProductsVO列表 // 封装成BookingPhotoProductsVO列表
PhotoProductsVO photoProductsVO = new PhotoProductsVO(); PhotoProductsVO photoProductsVO = new PhotoProductsVO();
BeanUtils.copyProperties(photoProducts, photoProductsVO); BeanUtils.copyProperties(photoProducts, photoProductsVO);
photoProductsVO.setRichText(DecoderUtils.decodeText(photoProductsVO.getRichText()));
// TODO // TODO
// photoProductsVO.setIntroImg(FileConstant.SERVER_HOST + photoProductsVO.getIntroImg()); // photoProductsVO.setIntroImg(FileConstant.SERVER_HOST + photoProductsVO.getIntroImg());
photoProductsVO.setBookingDateVOList(bookingDateVOList); photoProductsVO.setBookingDateVOList(bookingDateVOList);

View File

@ -0,0 +1,155 @@
package com.cultural.heritage.controller.other;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cultural.heritage.annotation.AuthCheck;
import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.CommonStringRequest;
import com.cultural.heritage.model.dto.banner.BannerAddRequest;
import com.cultural.heritage.model.dto.banner.BannerQueryRequest;
import com.cultural.heritage.model.dto.banner.BannerUpdateRequest;
import com.cultural.heritage.model.entity.Banner;
import com.cultural.heritage.model.vo.banner.BannerVO;
import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.other.BannerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/banner")
@Slf4j
@Tag(name = "轮播图管理")
public class BannerController {
@Resource
private BannerService bannerService;
@Resource
private CommonService commonService;
/**
* web端管理员添加轮播图
* @param bannerAddRequest 轮播图添加请求体
* @return 是否添加成功
*/
@PostMapping("/add")
@Operation(summary = "web端管理员添加轮播图", description = "参数轮播图添加请求体权限管理员boss, admin)方法名addBanner")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> addBanner(@RequestBody BannerAddRequest bannerAddRequest) {
if (bannerAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Banner banner = new Banner();
BeanUtils.copyProperties(bannerAddRequest, banner);
bannerService.validBanner(banner, false);
boolean result = bannerService.save(banner);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图添加失败");
return ResultUtils.success(true);
}
/**
* web端管理员删除轮播图
* @param commonRequest 轮播图id
* @return 是否成功删除
*/
@PostMapping("/delete")
@Operation(summary = "web端管理员删除轮播图", description = "参数轮播图id权限管理员boss, admin)方法名delBanner")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> delBanner(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long id = commonRequest.getId();
boolean result = bannerService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图删除失败");
return ResultUtils.success(true);
}
/**
* web端管理员更新轮播图
* @param bannerUpdateRequest 轮播图更新请求体
* @return 是否更新成功
*/
@PostMapping("/update")
@Operation(summary = "web端管理员更新轮播图", description = "参数轮播图更新请求体权限管理员boss, admin)方法名updateBanner")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateBanner(@RequestBody BannerUpdateRequest bannerUpdateRequest) {
if (bannerUpdateRequest == null || bannerUpdateRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Banner banner = new Banner();
BeanUtils.copyProperties(bannerUpdateRequest, banner);
bannerService.validBanner(banner, true);
boolean result = bannerService.updateById(banner);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图更新失败");
return ResultUtils.success(true);
}
/**
* Web端管理员分页查看轮播图
* @return 轮播图列表
*/
@PostMapping("/query/web")
@Operation(summary = "Web端管理员分页查看轮播图", description = "参数权限管理员boss, admin),方法名:listBannerByPage")
public BaseResponse<Page<BannerVO>> listBannerByPage(@RequestBody BannerQueryRequest bannerQueryRequest) {
if (bannerQueryRequest == null) throw new BusinessException(ErrorCode.PARAMS_ERROR);
long current = bannerQueryRequest.getCurrent();
long pageSize = bannerQueryRequest.getPageSize();
Page<Banner> page = bannerService.page(new Page<>(current, pageSize),null);
List<Banner> bannerList = page.getRecords();
List<BannerVO> bannerVOList = commonService.convertList(bannerList, BannerVO.class);
Page<BannerVO> voPage = new Page<>();
voPage.setRecords(bannerVOList);
voPage.setPages(page.getPages());
voPage.setCurrent(page.getCurrent());
voPage.setTotal(page.getTotal());
voPage.setSize(page.getSize());
return ResultUtils.success(voPage);
}
/**
* 小程序用户根据类型查看轮播图
* @return 轮播图列表
*/
@GetMapping("/query")
@Operation(summary = "小程序用户根据类型查看轮播图", description = "参数:无,权限:所有人,方法名:queryBannerByType")
public BaseResponse<List<BannerVO>> queryBannerByType(@RequestBody CommonStringRequest commonStringRequest) {
if (commonStringRequest == null || StringUtils.isBlank(commonStringRequest.getType())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
String type = commonStringRequest.getType();
List<Banner> bannerList = commonService.findByFieldEqTargetField("type", type, bannerService);
List<BannerVO> bannerVOList = commonService.convertList(bannerList, BannerVO.class);
return ResultUtils.success(bannerVOList);
}
}

View File

@ -118,27 +118,9 @@ public class WeChatController {
} }
/**
* 小程序用户查看文章
* @return 用户地址列表
*/
@GetMapping("/query")
@Operation(summary = "小程序用户查看文章", description = "参数:无,权限:所有人,方法名:queryAllArticle")
public BaseResponse<List<OfficialAccountArticleVO>> queryAllArticle() {
List<OfficialAccountArticle> officialAccountArticleList = weChatOfficialAccountService.list();
List<OfficialAccountArticleVO> officialAccountArticleVOS = commonService.convertList(officialAccountArticleList, OfficialAccountArticleVO.class);
Collections.reverse(officialAccountArticleVOS);
return ResultUtils.success(officialAccountArticleVOS);
}
/** /**
* Web端管理员分页查看文章 * Web端管理员分页查看文章
* @return 用户地址列表 * @return 公众号文章列表
*/ */
@PostMapping("/query/web") @PostMapping("/query/web")
@Operation(summary = "Web端管理员分页查看文章", description = "参数权限web端管理员方法名:listArticleByPage") @Operation(summary = "Web端管理员分页查看文章", description = "参数权限web端管理员方法名:listArticleByPage")
@ -160,6 +142,24 @@ public class WeChatController {
/**
* 小程序用户查看文章
* @return 公众号文章列表
*/
@GetMapping("/query")
@Operation(summary = "小程序用户查看文章", description = "参数:无,权限:所有人,方法名:queryAllArticle")
public BaseResponse<List<OfficialAccountArticleVO>> queryAllArticle() {
List<OfficialAccountArticle> officialAccountArticleList = weChatOfficialAccountService.list();
List<OfficialAccountArticleVO> officialAccountArticleVOS = commonService.convertList(officialAccountArticleList, OfficialAccountArticleVO.class);
Collections.reverse(officialAccountArticleVOS);
return ResultUtils.success(officialAccountArticleVOS);
}

View File

@ -0,0 +1,8 @@
package com.cultural.heritage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cultural.heritage.model.entity.Banner;
public interface BannerMapper extends BaseMapper<Banner> {
}

View File

@ -2,11 +2,13 @@ package com.cultural.heritage.model.dto.article;
import com.cultural.heritage.common.PageRequest; import com.cultural.heritage.common.PageRequest;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Data @Data
public class OfficialAccountArticleQueryRequest extends PageRequest implements Serializable { public class OfficialAccountArticleQueryRequest extends PageRequest implements Serializable {

View File

@ -0,0 +1,31 @@
package com.cultural.heritage.model.dto.banner;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "轮播图添加请求体", requiredProperties = {"type", "url"})
public class BannerAddRequest implements Serializable {
/**
* 类型
*/
@Schema(description = "类型")
private String type;
/**
* URL
*/
@Schema(description = "URL")
private String url;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,19 @@
package com.cultural.heritage.model.dto.banner;
import com.cultural.heritage.common.PageRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Data
public class BannerQueryRequest extends PageRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,36 @@
package com.cultural.heritage.model.dto.banner;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "轮播图更新请求体", requiredProperties = {"id", "type", "url"})
public class BannerUpdateRequest implements Serializable {
/**
* id
*/
@Schema(description = "id")
private Long id;
/**
* 类型
*/
@Schema(description = "类型")
private String type;
/**
* URL
*/
@Schema(description = "URL")
private String url;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,62 @@
package com.cultural.heritage.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 轮播图
* @TableName banner
*/
@Data
@TableName("banner")
public class Banner implements Serializable {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 类型
*/
private String type;
/**
* URL
*/
private String url;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer isDelete;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -7,10 +7,11 @@ import lombok.Data;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* 商品 * 公众号文章
* @TableName official_account_article * @TableName official_account_article
*/ */
@Data @Data
@ -47,6 +48,24 @@ public class OfficialAccountArticle implements Serializable {
private String url; private String url;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer isDelete;
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -0,0 +1,32 @@
package com.cultural.heritage.model.vo.banner;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class BannerVO implements Serializable {
/**
* id
*/
private Long id;
/**
* 类型
*/
private String type;
/**
* URL
*/
private String url;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,13 @@
package com.cultural.heritage.service.other;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cultural.heritage.model.entity.Banner;
public interface BannerService extends IService<Banner> {
/**
* 校验参数
*/
void validBanner(Banner banner, boolean update);
}

View File

@ -0,0 +1,25 @@
package com.cultural.heritage.service.other.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.BannerMapper;
import com.cultural.heritage.model.entity.Banner;
import com.cultural.heritage.service.other.BannerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
@Override
public void validBanner(Banner banner, boolean update) {
Long id = banner.getId();
String type = banner.getType();
String url = banner.getUrl();
ThrowUtils.throwIf(update && id == null, ErrorCode.OPERATION_ERROR, "id参数错误");
ThrowUtils.throwIf(StringUtils.isAnyBlank(type, url), ErrorCode.OPERATION_ERROR, "存在参数为空");
}
}

View File

@ -0,0 +1,7 @@
<?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="com.cultural.heritage.mapper.BannerMapper">
</mapper>