feat(memberCenter): 重构会员权益功能并添加社区文件管理
parent
0005e1da6b
commit
4d50a05ed7
|
@ -0,0 +1,51 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
|
||||
import com.mcwl.common.core.domain.R;
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.dto.*;
|
||||
import com.mcwl.communityCenter.service.CommunityFileLogService;
|
||||
import com.mcwl.communityCenter.service.CommunityFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 社区文件
|
||||
*/
|
||||
@Api(tags = "社区文件")
|
||||
@RestController
|
||||
@RequestMapping("communityFile")
|
||||
@RequiredArgsConstructor
|
||||
public class CommunityFileController {
|
||||
|
||||
private final CommunityFileService communityFileService;
|
||||
|
||||
private final CommunityFileLogService communityFileLogService;
|
||||
|
||||
/**
|
||||
* 社区文件上传
|
||||
*/
|
||||
@ApiOperation(value = "社区文件上传")
|
||||
@PostMapping("/upload")
|
||||
public R<Object> upload(@RequestBody @Valid CommunityUploadFileRes communityUploadFileRes) {
|
||||
communityFileService.upload(communityUploadFileRes);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 社区文件列表
|
||||
*/
|
||||
@ApiOperation(value = "社区文件列表")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo getCommunityFileList(@RequestBody @Valid CommunityFilePageListRes communityFilePageListRes) {
|
||||
return communityFileService.getCommunityFileList(communityFilePageListRes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -31,16 +31,6 @@ public class PublishController {
|
|||
|
||||
private final PublishService publishService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取发布列表
|
||||
*/
|
||||
@ApiOperation(value = "获取发布列表")
|
||||
@PostMapping("list")
|
||||
public TableDataInfo list(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
return publishService.getPublishList(publishPageRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布详情
|
||||
*/
|
||||
|
@ -50,7 +40,7 @@ public class PublishController {
|
|||
|
||||
PublishVo publishVo = publishService.getDetail(publishDetailRes);
|
||||
if (Objects.isNull(publishVo)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"获取详情失败");
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG, "获取详情失败");
|
||||
}
|
||||
return R.ok(publishVo);
|
||||
}
|
||||
|
@ -65,22 +55,31 @@ public class PublishController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取发布图片列表
|
||||
* 获取发布列表
|
||||
*/
|
||||
@ApiOperation(value = "获取发布图片列表")
|
||||
@PostMapping("publishImage")
|
||||
public TableDataInfo publishImage(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
return publishService.publishImage(publishPageRes);
|
||||
@ApiOperation(value = "获取发布列表")
|
||||
@PostMapping("publishList")
|
||||
public TableDataInfo publishList(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
return publishService.publishList(publishPageRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布文件列表
|
||||
*/
|
||||
@ApiOperation(value = "获取发布文件列表")
|
||||
@PostMapping("publishFile")
|
||||
public TableDataInfo publishFile(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
return publishService.publishFile(publishPageRes);
|
||||
}
|
||||
// /**
|
||||
// * 获取发布图片列表
|
||||
// */
|
||||
// @ApiOperation(value = "获取发布图片列表")
|
||||
// @PostMapping("publishImage")
|
||||
// public TableDataInfo publishImage(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
// return publishService.publishImage(publishPageRes);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取发布文件列表
|
||||
// */
|
||||
// @ApiOperation(value = "获取发布文件列表")
|
||||
// @PostMapping("publishFile")
|
||||
// public TableDataInfo publishFile(@RequestBody @Valid PublishPageRes publishPageRes) {
|
||||
// return publishService.publishFile(publishPageRes);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除
|
||||
|
@ -92,4 +91,19 @@ public class PublishController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 精选/取消精选
|
||||
*/
|
||||
@ApiOperation(value = "精选/取消精选")
|
||||
@GetMapping("elite")
|
||||
public R<Object> elitePublish(@NotNull(message = "社区id不能为空")
|
||||
@ApiParam(value = "社区id")
|
||||
@Valid Long communityId,
|
||||
@NotNull(message = "发布文章id不能为空")
|
||||
@ApiParam(value = "发布文章id")
|
||||
@Valid Long publishId) {
|
||||
publishService.elitePublish(communityId, publishId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,21 +3,26 @@ package com.mcwl.web.controller.memberCenter;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.mcwl.common.core.domain.R;
|
||||
import com.mcwl.memberCenter.domain.Benefit;
|
||||
import com.mcwl.memberCenter.domain.BenefitValue;
|
||||
import com.mcwl.memberCenter.domain.dto.BenefitDto;
|
||||
import com.mcwl.memberCenter.domain.vo.BenefitVo;
|
||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||
import com.mcwl.memberCenter.service.BenefitService;
|
||||
import com.mcwl.memberCenter.service.BenefitValueService;
|
||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/***
|
||||
* 权益
|
||||
|
@ -30,6 +35,8 @@ public class BenefitController {
|
|||
|
||||
private final BenefitService benefitService;
|
||||
|
||||
private final BenefitValueService benefitValueService;
|
||||
|
||||
/**
|
||||
* 权益列表
|
||||
*/
|
||||
|
@ -38,10 +45,16 @@ public class BenefitController {
|
|||
@GetMapping("list")
|
||||
public R<List<BenefitVo>> list() {
|
||||
List<Benefit> benefitList = benefitService.list();
|
||||
Map<Long, Double> benefitValueMap = benefitValueService.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(BenefitValue::getId, BenefitValue::getBenefitValue));
|
||||
|
||||
List<BenefitVo> benefitVoList = new ArrayList<>();
|
||||
for (Benefit benefit : benefitList) {
|
||||
BenefitVo benefitVo = BeanUtil.copyProperties(benefit, BenefitVo.class);
|
||||
Double value = benefitValueMap.get(benefit.getBenefitDiscountId());
|
||||
benefitVo.setBenefitType(benefit.getBenefitType().getValue());
|
||||
benefitVo.setBenefitDiscount(value);
|
||||
benefitVoList.add(benefitVo);
|
||||
}
|
||||
|
||||
|
@ -54,12 +67,19 @@ public class BenefitController {
|
|||
// @PreAuthorize("@ss.hasPermi('system:benefit:add')")
|
||||
@ApiOperation(value = "添加权益")
|
||||
@PostMapping("add")
|
||||
public void add(@RequestBody @Valid BenefitDto benefitDto) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Object> add(@RequestBody @Valid BenefitDto benefitDto) {
|
||||
Double value = benefitDto.getBenefitDiscount();
|
||||
BenefitValue benefitValue = new BenefitValue();
|
||||
benefitValue.setBenefitValue(value);
|
||||
benefitValueService.save(benefitValue);
|
||||
|
||||
benefitDto.setId(null);
|
||||
Benefit benefit = BeanUtil.copyProperties(benefitDto, Benefit.class);
|
||||
benefit.setBenefitDiscountId(benefitValue.getId());
|
||||
benefitService.save(benefit);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +92,10 @@ public class BenefitController {
|
|||
Benefit benefit = benefitService.getById(id);
|
||||
BenefitVo benefitVo = BeanUtil.copyProperties(benefit, BenefitVo.class);
|
||||
benefitVo.setBenefitType(benefit.getBenefitType().getValue());
|
||||
|
||||
BenefitValue benefitValue = benefitValueService.lambdaQuery().eq(BenefitValue::getId, benefit.getBenefitDiscountId()).one();
|
||||
benefitVo.setBenefitDiscount(benefitValue.getBenefitValue());
|
||||
|
||||
return R.ok(benefitVo);
|
||||
}
|
||||
|
||||
|
@ -81,20 +105,27 @@ public class BenefitController {
|
|||
// @PreAuthorize("@ss.hasPermi('system:benefit:edit')")
|
||||
@ApiOperation(value = "修改权益")
|
||||
@PostMapping("update")
|
||||
public void update(@RequestBody @Valid BenefitDto benefitDto) {
|
||||
public R<Object> update(@RequestBody @Valid BenefitDto benefitDto) {
|
||||
|
||||
Benefit benefit = BeanUtil.copyProperties(benefitDto, Benefit.class);
|
||||
benefitService.updateById(benefit);
|
||||
|
||||
BenefitValue benefitValue = benefitValueService.lambdaQuery().eq(BenefitValue::getId, benefit.getBenefitDiscountId()).one();
|
||||
benefitValue.setBenefitValue(benefitDto.getBenefitDiscount());
|
||||
benefitValueService.updateById(benefitValue);
|
||||
|
||||
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
// @PreAuthorize("@ss.hasPermi('system:benefit:remove')")
|
||||
// @PreAuthorize("@ss.hasPermi('system:benefit:remove')")
|
||||
@ApiOperation(value = "删除权益")
|
||||
@GetMapping("delete")
|
||||
public void delete(@NotNull(message = "id不能为空") Long id) {
|
||||
public R<Object> delete(@NotNull(message = "id不能为空") Long id) {
|
||||
benefitService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 社区文件表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cc_community_file")
|
||||
@Builder
|
||||
public class CommunityFile extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件对象key
|
||||
*/
|
||||
private String objectKey;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 社区文件表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cc_community_file_log")
|
||||
public class CommunityFileLog extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 社区文件id
|
||||
*/
|
||||
private Long communityFileId;
|
||||
|
||||
/**
|
||||
* 下载用户id
|
||||
*/
|
||||
private Long downloadUserId;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 社区请求参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "社区请求参数")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommunityFilePageListRes extends PageDomain {
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
@NotNull(message = "租户id不能为空")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
@NotNull(message = "社区id不能为空")
|
||||
private Long communityId;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 社区请求参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "社区请求参数")
|
||||
public class CommunityUploadFileRes {
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
@NotNull(message = "租户id不能为空")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
@NotNull(message = "社区id不能为空")
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
@ApiModelProperty(value = "文件", required = true)
|
||||
@NotNull(message = "文件不能为空")
|
||||
private MultipartFile file;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -22,4 +22,8 @@ public class PublishPageRes extends PageDomain {
|
|||
@ApiParam(value = "租户id", required = true)
|
||||
private Long tenantId;
|
||||
|
||||
@NotNull(message = "类型不能为空")
|
||||
@ApiParam(value = "类型 0只看星主 1精选 2问答", required = true)
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package com.mcwl.communityCenter.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 社区文件返回数据
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "社区文件返回数据")
|
||||
public class CommunityFileVo {
|
||||
|
||||
/**
|
||||
* 社区文件id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区文件id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区id")
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@ApiModelProperty(value = "文件路径")
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
@ApiModelProperty(value = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 上传人
|
||||
*/
|
||||
@ApiModelProperty(value = "上传人")
|
||||
private String uploadUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
@ApiModelProperty(value = "上传时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 下载记录
|
||||
*/
|
||||
@ApiModelProperty(value = "用户下载记录")
|
||||
private DownloadFileUserVo downloadFileUser;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.mcwl.communityCenter.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户下载记录
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "用户下载记录")
|
||||
public class DownloadFileUserVo {
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private List<String> avatarUrlList;
|
||||
|
||||
@ApiModelProperty(value = "下载用户数")
|
||||
private Integer count;
|
||||
|
||||
}
|
|
@ -86,6 +86,11 @@ public class PublishVo {
|
|||
@ApiModelProperty(value = "评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
/**
|
||||
* 精选
|
||||
*/
|
||||
@ApiModelProperty(value = "精选")
|
||||
private Integer isElite;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.CommunityFileLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CommunityFileLogMapper extends BaseMapper<CommunityFileLog> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.dto.CommunityFilePageListRes;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface CommunityFileMapper extends BaseMapper<CommunityFile> {
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<CommunityFile> getCommunityFileList(Page<CommunityFile> page, @Param("communityFilePageListRes") CommunityFilePageListRes communityFilePageListRes);
|
||||
}
|
|
@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.dto.PublishPageRes;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PublishMapper extends BaseMapper<Publish> {
|
||||
|
@ -27,16 +29,20 @@ public interface PublishMapper extends BaseMapper<Publish> {
|
|||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Page<Publish> selectByTenantIdAndCommunityIdAndNotNullImagePage(Page<Publish> page,
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@Param("communityId")
|
||||
Long communityId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Page<Publish> selectByTenantIdAndCommunityIdAndNotNullFilePage(Page<Publish> page,
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@Param("communityId")
|
||||
Long communityId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Page<Publish> selectByTenantIdAndCommunityIdAndNotNullFilePage(Page<Publish> page,
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@Param("communityId")
|
||||
Long communityId);
|
||||
|
||||
void elitePublish(@Param("communityId") Long communityId, @Param("publishId") Long publishId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<Publish> publishList(Page<Publish> page,@Param("publishPageRes") PublishPageRes publishPageRes);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.CommunityFileLog;
|
||||
|
||||
public interface CommunityFileLogService extends IService<CommunityFileLog> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.dto.*;
|
||||
|
||||
public interface CommunityFileService extends IService<CommunityFile> {
|
||||
|
||||
void upload(CommunityUploadFileRes communityUploadFileRes);
|
||||
|
||||
TableDataInfo getCommunityFileList(CommunityFilePageListRes communityFilePageListRes);
|
||||
}
|
|
@ -31,4 +31,8 @@ public interface PublishService extends IService<Publish> {
|
|||
TableDataInfo publishImage(@Valid PublishPageRes publishPageRes);
|
||||
|
||||
TableDataInfo publishFile(@Valid PublishPageRes publishPageRes);
|
||||
|
||||
void elitePublish(Long communityId, Long publishId);
|
||||
|
||||
TableDataInfo publishList(PublishPageRes publishPageRes);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.CommunityFileLog;
|
||||
import com.mcwl.communityCenter.mapper.CommunityFileLogMapper;
|
||||
import com.mcwl.communityCenter.mapper.CommunityFileMapper;
|
||||
import com.mcwl.communityCenter.service.CommunityFileLogService;
|
||||
import com.mcwl.communityCenter.service.CommunityFileService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CommunityFileLogServiceImpl extends ServiceImpl<CommunityFileLogMapper, CommunityFileLog> implements CommunityFileLogService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.constant.HttpStatus;
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.obs.ObsUtils;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.dto.*;
|
||||
import com.mcwl.communityCenter.mapper.CommunityFileMapper;
|
||||
import com.mcwl.communityCenter.service.CommunityFileService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CommunityFileServiceImpl extends ServiceImpl<CommunityFileMapper, CommunityFile> implements CommunityFileService {
|
||||
|
||||
private final ObsUtils obsUtils;
|
||||
@Override
|
||||
public void upload(CommunityUploadFileRes communityUploadFileRes) {
|
||||
Long tenantId = communityUploadFileRes.getTenantId();
|
||||
Long communityId = communityUploadFileRes.getCommunityId();
|
||||
MultipartFile file = communityUploadFileRes.getFile();
|
||||
Map<String, String> map = obsUtils.uploadFile(file);
|
||||
String filename = file.getOriginalFilename();
|
||||
long fileSize = file.getSize();
|
||||
|
||||
CommunityFile communityFile = CommunityFile.builder()
|
||||
.tenantId(tenantId)
|
||||
.communityId(communityId)
|
||||
.userId(SecurityUtils.getUserId())
|
||||
.fileUrl(map.get("path"))
|
||||
.objectKey(map.get("objectKey"))
|
||||
.fileName(filename)
|
||||
.fileSize(fileSize)
|
||||
.build();
|
||||
baseMapper.insert(communityFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo getCommunityFileList(CommunityFilePageListRes communityFilePageListRes) {
|
||||
Page<CommunityFile> page = new Page<>(communityFilePageListRes.getPageNum(), communityFilePageListRes.getPageSize());
|
||||
List<CommunityFile> publishList = baseMapper.getCommunityFileList(page, communityFilePageListRes);
|
||||
|
||||
// 封装返回
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setRows(publishList);
|
||||
tableDataInfo.setTotal(page.getTotal());
|
||||
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
||||
tableDataInfo.setMsg("查询成功");
|
||||
return tableDataInfo;
|
||||
}
|
||||
}
|
|
@ -186,16 +186,28 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
|
|||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elitePublish(Long communityId, Long publishId) {
|
||||
baseMapper.elitePublish(communityId, publishId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo publishList(PublishPageRes publishPageRes) {
|
||||
Page<Publish> page = this.initPage(publishPageRes);
|
||||
List<Publish> publishList = baseMapper.publishList(page, publishPageRes);
|
||||
|
||||
// 封装返回
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setRows(publishList);
|
||||
tableDataInfo.setTotal(page.getTotal());
|
||||
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
||||
tableDataInfo.setMsg("查询成功");
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
private Page<Publish> initPage(PublishPageRes publishPageRes) {
|
||||
Page<Publish> page = new Page<>(publishPageRes.getPageNum(), publishPageRes.getPageSize());
|
||||
|
||||
if (StringUtils.isBlank(publishPageRes.getOrderByColumn())) {
|
||||
publishPageRes.setOrderByColumn("create_time");
|
||||
}
|
||||
boolean isAsc = Objects.equals(publishPageRes.getIsAsc(), "asc");
|
||||
OrderItem orderItem = new OrderItem(publishPageRes.getOrderByColumn(), isAsc);
|
||||
|
||||
page.addOrder(orderItem);
|
||||
page.addOrder(new OrderItem("create_time", false));
|
||||
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -72,15 +72,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"租户或社区不存在");
|
||||
}
|
||||
|
||||
// if (Objects.equals(tenantId, userId)) {
|
||||
// return AjaxResult.error("您不能提问自己的问题");
|
||||
// }
|
||||
if (Objects.equals(tenantId, userId)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"您不能提问自己的问题");
|
||||
}
|
||||
|
||||
//提问人(userId)是否在社区中
|
||||
// Invite invite = inviteMapper.selectByTenantIdAndCommunityIdAndInviteeUserId(tenantId, communityId, userId);
|
||||
// if (Objects.isNull(invite)) {
|
||||
// return AjaxResult.error("您不是该社区成员,不能提问");
|
||||
// }
|
||||
Invite invite = inviteMapper.selectByTenantIdAndCommunityIdAndInviteeUserId(tenantId, communityId, userId);
|
||||
if (Objects.isNull(invite)) {
|
||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"您不是该社区成员,不能提问");
|
||||
}
|
||||
|
||||
Question question = new Question();
|
||||
BeanUtil.copyProperties(questionRes, question);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?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.mcwl.communityCenter.mapper.CommunityFileMapper">
|
||||
|
||||
|
||||
<select id="getCommunityFileList" resultType="com.mcwl.communityCenter.domain.CommunityFile">
|
||||
select *
|
||||
from cc_community_file
|
||||
where del_flag = '0'
|
||||
and tenant_id = #{communityFilePageListRes.tenantId}
|
||||
and community_id = #{communityFilePageListRes.communityId}
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -3,6 +3,12 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.communityCenter.mapper.PublishMapper">
|
||||
<update id="elitePublish">
|
||||
update cc_publish
|
||||
set is_elite = !is_elite
|
||||
where community_id = #{communityId}
|
||||
and id = #{publishId}
|
||||
</update>
|
||||
<select id="selectByTenantIdAndCommunityIdPage" resultType="com.mcwl.communityCenter.domain.Publish">
|
||||
select id,
|
||||
tenant_id,
|
||||
|
@ -84,4 +90,19 @@
|
|||
and del_flag = '0'
|
||||
and file_url is not null
|
||||
</select>
|
||||
<select id="publishList" resultType="com.mcwl.communityCenter.domain.Publish">
|
||||
select *
|
||||
from cc_publish
|
||||
<where>
|
||||
and tenant_id = #{publishPageRes.tenantId}
|
||||
and community_id = #{publishPageRes.communityId}
|
||||
and del_flag = '0'
|
||||
<if test="publishPageRes.type == 0">
|
||||
and user_id = #{publishPageRes.tenantId}
|
||||
</if>
|
||||
<if test="publishPageRes.type == 1">
|
||||
and is_elite = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
|
@ -32,7 +32,7 @@ public class Benefit extends BaseEntity {
|
|||
/**
|
||||
* 权益折扣,当权益类型为折扣时,记录折扣具体数值
|
||||
*/
|
||||
private Double benefitDiscount;
|
||||
private Long benefitDiscountId;
|
||||
/**
|
||||
* 权益排序
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.mcwl.memberCenter.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 权益值表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("mem_benefit_value")
|
||||
public class BenefitValue extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 会员权益值
|
||||
*/
|
||||
private Double benefitValue;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String benefitUnit;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.mcwl.memberCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.memberCenter.domain.Benefit;
|
||||
import com.mcwl.memberCenter.domain.BenefitValue;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权益 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BenefitValueMapper extends BaseMapper<BenefitValue> {
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.mcwl.memberCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.memberCenter.domain.Benefit;
|
||||
import com.mcwl.memberCenter.domain.BenefitValue;
|
||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BenefitValueService extends IService<BenefitValue> {
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.mcwl.memberCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.memberCenter.domain.Benefit;
|
||||
import com.mcwl.memberCenter.domain.BenefitValue;
|
||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||
import com.mcwl.memberCenter.mapper.BenefitMapper;
|
||||
import com.mcwl.memberCenter.mapper.BenefitValueMapper;
|
||||
import com.mcwl.memberCenter.service.BenefitService;
|
||||
import com.mcwl.memberCenter.service.BenefitValueService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BenefitValueServiceImpl extends ServiceImpl<BenefitValueMapper, BenefitValue> implements BenefitValueService {
|
||||
|
||||
}
|
|
@ -48,6 +48,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
|||
|
||||
private final BenefitService benefitService;
|
||||
|
||||
private final BenefitValueService benefitValueService;
|
||||
|
||||
private final RechargeRecordService rechargeRecordService;
|
||||
|
||||
private static final Map<Long, MemberLevel> memberLevelMap = new HashMap<>();
|
||||
|
@ -108,7 +110,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
|||
// 设置积分
|
||||
Benefit benefit = benefitService.getBenefitByType(memberLevelId, MemberBenefitTypeEnum.POINTS);
|
||||
if (Objects.nonNull(benefit)) {
|
||||
Double points = benefit.getBenefitDiscount();
|
||||
BenefitValue benefitValue = benefitValueService.lambdaQuery().eq(BenefitValue::getId, benefit.getBenefitDiscountId()).one();
|
||||
Double points = benefitValue.getBenefitValue();
|
||||
// 根据活动id查询活动类型,如果为积分,则积分加成
|
||||
if (promotionId != null) {
|
||||
Promotion promotion = promotionMapper.selectById(promotionId);
|
||||
|
|
|
@ -16,10 +16,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component("userMemberTask")
|
||||
@RequiredArgsConstructor
|
||||
|
@ -35,6 +33,8 @@ public class UserMemberTask {
|
|||
|
||||
private final BenefitService benefitService;
|
||||
|
||||
private final BenefitValueService benefitValueService;
|
||||
|
||||
private final PromotionService promotionService;
|
||||
|
||||
private final MemberPromotionService memberPromotionService;
|
||||
|
@ -175,6 +175,10 @@ public class UserMemberTask {
|
|||
*/
|
||||
public Double getPointsByMemberLevelId(Long memberLevelId) {
|
||||
|
||||
Map<Long, Double> benefitValueMap = benefitValueService.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(BenefitValue::getId, BenefitValue::getBenefitValue));
|
||||
|
||||
// 根据会员等级id获取会员权益
|
||||
List<MemberBenefit> memberBenefitList = memberBenefitService.lambdaQuery()
|
||||
.eq(MemberBenefit::getMemberLevelId, memberLevelId)
|
||||
|
@ -190,8 +194,8 @@ public class UserMemberTask {
|
|||
.in(Benefit::getId, benefitIdList)
|
||||
.list();
|
||||
for (Benefit benefit : benefitList) {
|
||||
if (benefit.getBenefitType().equals(MemberBenefitTypeEnum.POINTS.getValue())) {
|
||||
return benefit.getBenefitDiscount();
|
||||
if (benefit.getBenefitType().getValue().equals(MemberBenefitTypeEnum.POINTS.getValue())) {
|
||||
return benefitValueMap.getOrDefault(benefit.getBenefitDiscountId(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue