init
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.ruoyi.xq.controller.app;
|
package com.ruoyi.xq.controller.app;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
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.dto.app.user.vo.HomeUserVo;
|
||||||
|
import com.ruoyi.xq.service.BannerService;
|
||||||
import com.ruoyi.xq.service.UserService;
|
import com.ruoyi.xq.service.UserService;
|
||||||
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;
|
||||||
@@ -12,6 +15,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/home")
|
@RequestMapping("/api/home")
|
||||||
@Tag(name = "首页相关接口")
|
@Tag(name = "首页相关接口")
|
||||||
@@ -25,4 +30,16 @@ public class HomeAppController {
|
|||||||
HomeUserVo vo = userService.homeUser(userId);
|
HomeUserVo vo = userService.homeUser(userId);
|
||||||
return R.ok(vo);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.ruoyi.xq.domain;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -24,18 +25,22 @@ public class VipPrice implements Serializable {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id")
|
@TableId(value = "id")
|
||||||
|
@Schema(description = "VIP价格ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 1-普通会员 2-黄金会员 3-钻石会员
|
* 1-普通会员 2-黄金会员 3-钻石会员
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "1-普通会员 2-黄金会员 3-钻石会员")
|
||||||
private Integer vipType;
|
private Integer vipType;
|
||||||
/**
|
/**
|
||||||
* 1-月卡 2-季卡 3-年卡
|
* 1-月卡 2-季卡 3-年卡
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "1-月卡 2-季卡 3-年卡")
|
||||||
private Integer vipTime;
|
private Integer vipTime;
|
||||||
/**
|
/**
|
||||||
* 会员价格
|
* 会员价格
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "会员价格")
|
||||||
private BigDecimal vipPrice;
|
private BigDecimal vipPrice;
|
||||||
/**
|
/**
|
||||||
* 1-启用 0-禁用
|
* 1-启用 0-禁用
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.xq.dto.app.common;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "上传文件返回数据")
|
||||||
|
public class FileResp {
|
||||||
|
|
||||||
|
@Schema(description = "文件url")
|
||||||
|
private String url;
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String path;
|
||||||
|
@Schema(description = "文件原始名")
|
||||||
|
private String originalName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.xq.dto.app.setting;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AgreementDTO {
|
||||||
|
private String agreement;
|
||||||
|
|
||||||
|
public AgreementDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AgreementDTO(String agreement) {
|
||||||
|
this.agreement = agreement;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,9 +9,6 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class HomeUserVo {
|
public class HomeUserVo {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "用户ID")
|
@Schema(description = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@Schema(description = "用户编号")
|
@Schema(description = "用户编号")
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.xq.dto.app.vip;
|
||||||
|
|
||||||
|
import com.ruoyi.xq.domain.VipPrice;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VipHomeVo {
|
||||||
|
@Schema(description = "VIP价格")
|
||||||
|
private List<VipPrice> vipPriceList;
|
||||||
|
@Schema(description = "用户ID")
|
||||||
|
private Long userId;
|
||||||
|
@Schema(description = "VIP开通状态 0-未开通 1-已开通 2-已到期")
|
||||||
|
private Integer userVipOpenStatus;
|
||||||
|
@Schema(description = "VIP到期时间,(已过期则为最近一次到期时间)")
|
||||||
|
private LocalDateTime vipTimeOut;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.ruoyi.xq.dto.app.vip;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VipPriceVo {
|
||||||
|
@Schema(description = "VIP价格ID")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 1-普通会员 2-黄金会员 3-钻石会员
|
||||||
|
*/
|
||||||
|
@Schema(description = "1-普通会员 2-黄金会员 3-钻石会员")
|
||||||
|
private Integer vipType;
|
||||||
|
/**
|
||||||
|
* 1-月卡 2-季卡 3-年卡
|
||||||
|
*/
|
||||||
|
@Schema(description = "1-月卡 2-季卡 3-年卡")
|
||||||
|
private Integer vipTime;
|
||||||
|
|
||||||
|
@Schema(description = "vip天数")
|
||||||
|
private Integer vipDays;
|
||||||
|
/**
|
||||||
|
* 会员价格
|
||||||
|
*/
|
||||||
|
@Schema(description = "会员价格")
|
||||||
|
private BigDecimal vipPrice;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "折合每天价格")
|
||||||
|
private BigDecimal dayPrice;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.xq.enums.vip;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
// VIP开通状态 0-未开通 1-已开通 2-已到期
|
||||||
|
@Getter
|
||||||
|
public enum UserVipOpenStatusEnum {
|
||||||
|
NO(0,"未开通"),
|
||||||
|
OPEN_VIP(1,"已开通"),
|
||||||
|
VIP_TIMEOUT(2,"已到期"),
|
||||||
|
;
|
||||||
|
private final Integer code;
|
||||||
|
private final String text;
|
||||||
|
|
||||||
|
UserVipOpenStatusEnum(Integer code, String text) {
|
||||||
|
this.code = code;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ruoyi.xq.enums.vip;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
// 1-正常 2-已过期 3-已取消
|
||||||
|
@Getter
|
||||||
|
public enum VipStatusEnum {
|
||||||
|
NORMAL(1,"正常"),
|
||||||
|
TIMEOUT(2,"已过期"),
|
||||||
|
CLOSE(3,"已取消"),
|
||||||
|
|
||||||
|
;
|
||||||
|
private final Integer code;
|
||||||
|
private final String text;
|
||||||
|
|
||||||
|
VipStatusEnum(Integer code, String text) {
|
||||||
|
this.code = code;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.xq.enums.vip;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum VipTypeEnum {
|
||||||
|
ONE(1,"一级会员"),
|
||||||
|
TWO(2,"二级会员"),
|
||||||
|
THREE(3,"三级会员"),
|
||||||
|
;
|
||||||
|
private final Integer code;
|
||||||
|
private final String text;
|
||||||
|
|
||||||
|
VipTypeEnum(Integer code, String text) {
|
||||||
|
this.code = code;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,4 +11,5 @@ import com.ruoyi.xq.domain.AgreementSetting;
|
|||||||
*/
|
*/
|
||||||
public interface AgreementSettingService extends IService<AgreementSetting> {
|
public interface AgreementSettingService extends IService<AgreementSetting> {
|
||||||
|
|
||||||
|
AgreementSetting getAgreementSetting();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,4 +11,9 @@ import com.ruoyi.xq.domain.UserVip;
|
|||||||
*/
|
*/
|
||||||
public interface UserVipService extends IService<UserVip> {
|
public interface UserVipService extends IService<UserVip> {
|
||||||
|
|
||||||
|
UserVip getUserVip(Long userId, Integer vipType);
|
||||||
|
|
||||||
|
UserVip getUserVipNormal(Long userId, Integer vipType);
|
||||||
|
|
||||||
|
UserVip getByUserVipMaster(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.ruoyi.xq.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.xq.domain.VipPrice;
|
import com.ruoyi.xq.domain.VipPrice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员价格设置Service接口
|
* 会员价格设置Service接口
|
||||||
*
|
*
|
||||||
@@ -10,4 +12,5 @@ import com.ruoyi.xq.domain.VipPrice;
|
|||||||
* @date 2024-03-04
|
* @date 2024-03-04
|
||||||
*/
|
*/
|
||||||
public interface VipPriceService extends IService<VipPrice> {
|
public interface VipPriceService extends IService<VipPrice> {
|
||||||
|
List<VipPrice> listByVipType(Integer vipType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,8 @@ import org.springframework.stereotype.Service;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class AgreementSettingServiceImpl extends ServiceImpl<AgreementSettingMapper,AgreementSetting> implements AgreementSettingService {
|
public class AgreementSettingServiceImpl extends ServiceImpl<AgreementSettingMapper,AgreementSetting> implements AgreementSettingService {
|
||||||
|
@Override
|
||||||
|
public AgreementSetting getAgreementSetting() {
|
||||||
|
return this.getById(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package com.ruoyi.xq.service.impl;
|
package com.ruoyi.xq.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.xq.domain.UserVip;
|
import com.ruoyi.xq.domain.UserVip;
|
||||||
|
import com.ruoyi.xq.enums.vip.VipStatusEnum;
|
||||||
import com.ruoyi.xq.mapper.UserVipMapper;
|
import com.ruoyi.xq.mapper.UserVipMapper;
|
||||||
import com.ruoyi.xq.service.UserVipService;
|
import com.ruoyi.xq.service.UserVipService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VIP用户Service业务层处理
|
* VIP用户Service业务层处理
|
||||||
*
|
*
|
||||||
@@ -17,4 +23,32 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> implements UserVipService {
|
public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> implements UserVipService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserVip getUserVip(Long userId, Integer vipType){
|
||||||
|
return this.getOne(Wrappers.lambdaQuery(UserVip.class)
|
||||||
|
.eq(UserVip::getUserId, userId)
|
||||||
|
.eq(UserVip::getVipType, vipType)
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserVip getUserVipNormal(Long userId, Integer vipType){
|
||||||
|
return this.getOne(Wrappers.lambdaQuery(UserVip.class)
|
||||||
|
.eq(UserVip::getUserId, userId)
|
||||||
|
.eq(UserVip::getVipType, vipType)
|
||||||
|
.eq(UserVip::getVipStatus, VipStatusEnum.NORMAL.getCode())
|
||||||
|
.ge(UserVip::getVipTimeout, LocalDateTime.now())
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserVip getByUserVipMaster(Long userId){
|
||||||
|
List<UserVip> userVipList = this.list(Wrappers.lambdaQuery(UserVip.class)
|
||||||
|
.eq(UserVip::getUserId, userId)
|
||||||
|
.eq(UserVip::getVipStatus, VipStatusEnum.NORMAL.getCode())
|
||||||
|
.ge(UserVip::getVipTimeout, LocalDateTime.now()));
|
||||||
|
return userVipList.stream().max(Comparator.comparing(UserVip::getVipType)).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.xq.service.impl;
|
package com.ruoyi.xq.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.xq.domain.VipPrice;
|
import com.ruoyi.xq.domain.VipPrice;
|
||||||
import com.ruoyi.xq.mapper.VipPriceMapper;
|
import com.ruoyi.xq.mapper.VipPriceMapper;
|
||||||
@@ -7,6 +8,8 @@ import com.ruoyi.xq.service.VipPriceService;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员价格设置Service业务层处理
|
* 会员价格设置Service业务层处理
|
||||||
*
|
*
|
||||||
@@ -17,4 +20,9 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class VipPriceServiceImpl extends ServiceImpl<VipPriceMapper,VipPrice> implements VipPriceService {
|
public class VipPriceServiceImpl extends ServiceImpl<VipPriceMapper,VipPrice> implements VipPriceService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VipPrice> listByVipType(Integer vipType) {
|
||||||
|
return this.list(Wrappers.lambdaQuery(VipPrice.class).eq(VipPrice::getVipType,vipType)
|
||||||
|
.orderByAsc(VipPrice::getVipTime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user