This commit is contained in:
张良(004796)
2024-03-06 18:30:52 +08:00
parent 7e1f31ed2f
commit 60293b4a70
19 changed files with 404 additions and 4 deletions

View File

@@ -0,0 +1,74 @@
package com.ruoyi.xq.controller.app;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.vo.SysOssVo;
import com.ruoyi.system.service.ISysOssService;
import com.ruoyi.xq.dto.app.common.FileResp;
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.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/file")
@Tag(name = "文件接口")
@Slf4j
public class FileController {
@Autowired
private ISysOssService iSysOssService;
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "上传文件",
parameters = {
@Parameter(name = "file", description = "文件", required = true),
@Parameter(name = "type", description = "业务类型dynamic=动态图片user=用户相关im=聊天common=其他", required = false)
})
public R<FileResp> upload(@RequestPart("file") MultipartFile file,
String type) {
log.error("上传文件图片类型 type={}",type);
if (ObjectUtil.isNull(file)) {
return R.fail("上传文件不能为空");
}
SysOssVo oss = iSysOssService.upload(file);
FileResp resp = new FileResp();
resp.setUrl(oss.getUrl());
resp.setPath(oss.getFileName());
resp.setOriginalName(oss.getOriginalName());
return R.ok(resp);
}
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
@PostMapping(value = "/uploadImage", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "上传图片类型的文件",
parameters = {
@Parameter(name = "file", description = "文件", required = true),
@Parameter(name = "type", description = "业务类型dynamic=动态图片user=用户相关im=聊天common=其他", required = false)
})
public R<FileResp> uploadImage(@RequestPart("file") MultipartFile file,
String type) {
log.error("上传文件图片类型 type={}",type);
if (ObjectUtil.isNull(file)) {
return R.fail("上传文件不能为空");
}
SysOssVo oss = iSysOssService.upload(file);
FileResp resp = new FileResp();
resp.setUrl(oss.getUrl());
resp.setPath(oss.getFileName());
resp.setOriginalName(oss.getOriginalName());
return R.ok(resp);
}
}

View File

@@ -1,9 +1,12 @@
package com.ruoyi.xq.controller.app;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xq.domain.Banner;
import com.ruoyi.xq.dto.app.user.vo.HomeUserVo;
import com.ruoyi.xq.service.BannerService;
import com.ruoyi.xq.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -12,6 +15,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/home")
@Tag(name = "首页相关接口")
@@ -25,4 +30,16 @@ public class HomeAppController {
HomeUserVo vo = userService.homeUser(userId);
return R.ok(vo);
}
@Autowired
private BannerService bannerService;
@GetMapping("/banner")
@Operation(summary = "轮播图")
@Log(title = "轮播图", businessType = BusinessType.OTHER, isSaveDb = false)
public R<List<Banner>> banner(){
List<Banner> list = bannerService.list(Wrappers.lambdaQuery(Banner.class)
.eq(Banner::getEnableStatus, 1));
return R.ok(list);
}
}

View File

@@ -0,0 +1,47 @@
package com.ruoyi.xq.controller.app;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xq.dto.app.setting.AgreementDTO;
import com.ruoyi.xq.service.AgreementSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/setting")
@Tag(name = "获取设置相关接口")
public class SettingAppController {
@Autowired
private AgreementSettingService agreementSettingService;
@GetMapping("/agreement/user")
@Operation(summary = "获取用户协议")
@Log(title = "获取用户协议", businessType = BusinessType.OTHER, isSaveDb = false)
public R<AgreementDTO> userAgreement() {
String userAgreement = agreementSettingService.getAgreementSetting().getUserAgreement();
return R.ok(new AgreementDTO(userAgreement));
}
@GetMapping("/agreement/privacy")
@Operation(summary = "获取隐私协议")
@Log(title = "获取隐私协议", businessType = BusinessType.OTHER, isSaveDb = false)
public R<AgreementDTO> privacyAgreement() {
String privacyAgreement = agreementSettingService.getAgreementSetting().getPrivacyAgreement();
return R.ok(new AgreementDTO(privacyAgreement));
}
@GetMapping("/agreement/anchorJoin")
@Operation(summary = "用户主播入驻协议")
@Log(title = "用户主播入驻协议", businessType = BusinessType.OTHER, isSaveDb = false)
public R<AgreementDTO> anchorJoinAgreement() {
String anchorJoinAgreement = agreementSettingService.getAgreementSetting().getAnchorJoinAgreement();
return R.ok(new AgreementDTO(anchorJoinAgreement));
}
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.xq.controller.app;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.xq.domain.UserVip;
import com.ruoyi.xq.domain.VipPrice;
import com.ruoyi.xq.dto.app.vip.VipHomeVo;
import com.ruoyi.xq.enums.vip.UserVipOpenStatusEnum;
import com.ruoyi.xq.enums.vip.VipStatusEnum;
import com.ruoyi.xq.service.UserVipService;
import com.ruoyi.xq.service.VipPriceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;
@RestController
@RequestMapping("/api/vip")
@Tag(name = "首页相关接口")
public class VipController {
@Autowired
private VipPriceService vipPriceService;
@Autowired
private UserVipService userVipService;
@GetMapping("/home")
@Operation(summary = "获取VIP信息")
@Log(title = "获取VIP信息", businessType = BusinessType.OTHER, isSaveDb = false)
public R<VipHomeVo> vipHome(Integer vipType){
Long userId = LoginHelper.getUserId();
List<VipPrice> vipPrices = vipPriceService.listByVipType(vipType);
UserVip userVip = userVipService.getUserVip(userId, vipType);
VipHomeVo vo = new VipHomeVo();
vo.setVipPriceList(vipPrices);
vo.setUserId(userId);
if(userVip == null){
vo.setUserVipOpenStatus(UserVipOpenStatusEnum.NO.getCode());
}else{
LocalDateTime now = LocalDateTime.now();
if(userVip.getVipStatus().equals(VipStatusEnum.CLOSE.getCode())){
vo.setUserVipOpenStatus(UserVipOpenStatusEnum.NO.getCode());
}else {
if(vo.getVipTimeOut().isBefore(now)){
vo.setUserVipOpenStatus(UserVipOpenStatusEnum.VIP_TIMEOUT.getCode());
vo.setVipTimeOut(userVip.getVipTimeout());
}else{
vo.setUserVipOpenStatus(UserVipOpenStatusEnum.OPEN_VIP.getCode());
vo.setVipTimeOut(userVip.getVipTimeout());
}
}
}
return R.ok(vo);
}
}