feat(communityCenter): 发布标签

feature/community-center
yang 2025-05-15 16:06:39 +08:00
parent 43a6bc98b8
commit 6395fc7260
16 changed files with 359 additions and 13 deletions

View File

@ -0,0 +1,58 @@
package com.mcwl.web.controller.communityCenter;
import cn.hutool.core.bean.BeanUtil;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.PublishLabel;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.domain.vo.PublishVo;
import com.mcwl.communityCenter.service.CommunityUserService;
import com.mcwl.communityCenter.service.PublishLabelService;
import com.mcwl.communityCenter.service.PublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
/**
*
*/
@Api(tags = "发布标签")
@RestController
@RequestMapping("publishLabel")
@RequiredArgsConstructor
public class PublishLabelController {
private final PublishLabelService publishLabelService;
/**
*
*/
@ApiOperation("获取发布标签列表")
@PostMapping("list")
public R<List<String>> listPublishLabel(@RequestBody @Valid PublishLabelListRes publishLabelListRes) {
return R.ok(publishLabelService.listPublishLabel(publishLabelListRes));
}
/**
*
*/
@ApiOperation("新增发布标签")
@PostMapping("add")
public R<String> addPublishLabel(@RequestBody @Valid PublishLabelAddRes publishLabelAddRes) {
publishLabelService.addPublishLabel(publishLabelAddRes);
return R.ok();
}
}

View File

@ -60,6 +60,11 @@ public class Publish extends BaseEntity {
*/
private Long userId;
/**
*
*/
private String labelName;
/**
* -
*/

View File

@ -0,0 +1,41 @@
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;
import java.util.Date;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("cc_publish_label")
public class PublishLabel extends BaseEntity {
private Long id;
/**
* id - id
*/
private Long tenantId;
/**
* id
*/
private Long communityId;
/**
*
*/
private String labelName;
}

View File

@ -0,0 +1,44 @@
package com.mcwl.communityCenter.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@ApiModel(value = "新增发布标签请求参数")
@NoArgsConstructor
@AllArgsConstructor
public class PublishLabelAddRes {
/**
* id
*/
@NotNull(message = "租户id不能为空")
@ApiModelProperty(value = "租户id", required = true)
private Long tenantId;
/**
* id
*/
@NotNull(message = "社区id不能为空")
@ApiModelProperty(value = "社区id", required = true)
private Long communityId;
/**
*
*/
@NotBlank(message = "标签名称不能为空")
@ApiModelProperty(value = "标签名称", required = true)
private String labelName;
}

View File

@ -0,0 +1,36 @@
package com.mcwl.communityCenter.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@ApiModel(value = "发布标签列表请求参数")
@NoArgsConstructor
@AllArgsConstructor
public class PublishLabelListRes {
/**
* id
*/
@NotNull(message = "租户id不能为空")
@ApiModelProperty(value = "租户id", required = true)
private Long tenantId;
/**
* id
*/
@NotNull(message = "社区id不能为空")
@ApiModelProperty(value = "社区id", required = true)
private Long communityId;
}

View File

@ -25,4 +25,7 @@ public class PublishPageRes extends PageDomain {
@ApiModelProperty(value = "类型 0只看星主 1精选", required = true)
private Integer type;
@ApiModelProperty(value = "标签名")
private String labelName;
}

View File

@ -26,6 +26,11 @@ public class PublishRes {
@ApiModelProperty(value = "社区id", required = true)
@NotNull(message = "社区id不能为空")
private Long communityId;
/**
*
*/
@ApiModelProperty(value = "标签名")
private String labelName;
/**
*
*/
@ -51,9 +56,10 @@ public class PublishRes {
private String fileName;
/**
* -
*
*/
@ApiModelProperty(value = "发布时间 - 定时发布")
private Date publishTime;
@ApiModelProperty(value = "是否精选")
private Integer isElite = 0;
}

View File

@ -80,6 +80,12 @@ public class PersonHomeVo {
@ApiModelProperty(value = "图片url")
private String imageUrl;
/**
*
*/
@ApiModelProperty(value = "标签名")
private String labelName;
/**
*

View File

@ -40,6 +40,12 @@ public class PublishVo {
@ApiModelProperty(value = "用户id")
private Long userId;
/**
*
*/
@ApiModelProperty(value = "标签名")
private String labelName;
/**
*
*/

View File

@ -0,0 +1,23 @@
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.Publish;
import com.mcwl.communityCenter.domain.PublishLabel;
import com.mcwl.communityCenter.domain.dto.MyPublishPageRes;
import com.mcwl.communityCenter.domain.dto.PublishLabelListRes;
import com.mcwl.communityCenter.domain.dto.PublishPageRes;
import com.mcwl.communityCenter.domain.dto.PublishRemoveRes;
import com.mcwl.communityCenter.domain.vo.PublishVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface PublishLabelMapper extends BaseMapper<PublishLabel> {
@InterceptorIgnore(tenantLine = "true")
List<String> listPublishLabel(PublishLabelListRes publishLabelListRes);
}

View File

@ -0,0 +1,20 @@
package com.mcwl.communityCenter.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.Publish;
import com.mcwl.communityCenter.domain.PublishLabel;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.domain.vo.PublishVo;
import javax.validation.Valid;
import java.util.List;
public interface PublishLabelService extends IService<PublishLabel> {
List<String> listPublishLabel(PublishLabelListRes publishLabelListRes);
void addPublishLabel(PublishLabelAddRes publishLabelAddRes);
}

View File

@ -0,0 +1,69 @@
package com.mcwl.communityCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
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.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.core.redis.RedisCache;
import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.communityCenter.constant.AdviceConstant;
import com.mcwl.communityCenter.domain.*;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.domain.vo.CommentVo;
import com.mcwl.communityCenter.domain.vo.PersonHomeVo;
import com.mcwl.communityCenter.domain.vo.PublishVo;
import com.mcwl.communityCenter.mapper.*;
import com.mcwl.communityCenter.service.*;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
@RequiredArgsConstructor
public class PublishLabelServiceImpl extends ServiceImpl<PublishLabelMapper, PublishLabel> implements PublishLabelService {
private final CommunityUserMapper communityUserMapper;
@Override
public List<String> listPublishLabel(PublishLabelListRes publishLabelListRes) {
return baseMapper.listPublishLabel(publishLabelListRes);
}
@Override
public void addPublishLabel(PublishLabelAddRes publishLabelAddRes) {
CommunityUser communityUser = communityUserMapper.selectCommunityUser(publishLabelAddRes.getTenantId(),
publishLabelAddRes.getCommunityId(), SecurityUtils.getUserId());
if (communityUser == null) {
throw new ServiceException("您不是该社区的成员,无法添加标签", HttpStatus.SHOW_ERROR_MSG);
}
if (communityUser.getUserType() != 2) {
throw new ServiceException("您不是星主,无法添加标签", HttpStatus.SHOW_ERROR_MSG);
}
PublishLabelListRes publishLabelListRes = BeanUtil.copyProperties(publishLabelAddRes, PublishLabelListRes.class);
List<String> publishLabelList = this.listPublishLabel(publishLabelListRes);
if (publishLabelList.size() >= 3) {
throw new ServiceException("最多只能添加三个标签", HttpStatus.SHOW_ERROR_MSG);
}
PublishLabel publishLabel = BeanUtil.copyProperties(publishLabelAddRes, PublishLabel.class);
baseMapper.insert(publishLabel);
}
}

View File

@ -103,6 +103,10 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您不是该社区成员");
}
if (publishRes.getIsElite() != null && communityUser.getUserType() != 2) {
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您不是星主,无法设置精选");
}
if ("1".equals(communityUser.getIsBlack())) {
return R.fail(HttpStatus.SHOW_ERROR_MSG, "您已被拉黑");
}

View File

@ -0,0 +1,15 @@
<?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.PublishLabelMapper">
<select id="listPublishLabel" resultType="java.lang.String">
select label_name
from cc_publish_label
where tenant_id = #{tenantId}
and community_id = #{communityId}
and del_flag = '0'
order by create_time desc
</select>
</mapper>

View File

@ -5,9 +5,12 @@
<mapper namespace="com.mcwl.communityCenter.mapper.PublishMapper">
<insert id="insertPublish">
insert into cc_publish
(tenant_id, community_id, user_id, content, image_url, file_url, file_name, publish_time, create_time)
(tenant_id, community_id, user_id, content, image_url, label_name, file_url, file_name, publish_time,
is_elite,
create_time)
values (#{publish.tenantId}, #{publish.communityId}, #{publish.userId}, #{publish.content}, #{publish.imageUrl},
#{publish.fileUrl}, #{publish.fileName}, #{publish.publishTime}, now())
#{publish.labelName}, #{publish.fileUrl}, #{publish.fileName}, #{publish.publishTime},
#{publish.isElite}, now())
</insert>
<update id="elitePublish">
update cc_publish
@ -130,6 +133,9 @@
and p.is_elite = 1
</if>
</if>
<if test="publishPageRes.labelName != null and publishPageRes.labelName != ''">
and p.label_name = #{publishPageRes.labelName}
</if>
</where>
order by p.create_time desc
</select>

View File

@ -54,6 +54,7 @@ import com.mcwl.system.service.ISysUserPayAccountService;
import com.mcwl.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -308,7 +309,7 @@ public class AliPayServiceImpl implements AliPayService {
return R.fail(HttpStatus.SHOW_ERROR_MSG, "请勿频繁点击");
}
try {
redisCache.setCacheObject("alipay:fetch:user:" + SecurityUtils.getUserId(), "1");
redisCache.setCacheObject("alipay:fetch:user:" + SecurityUtils.getUserId(), "1", 3, TimeUnit.MINUTES);
Long userId = SecurityUtils.getUserId();
@ -347,7 +348,7 @@ public class AliPayServiceImpl implements AliPayService {
// 证书用certificateExecute(request)密钥用execute(request)
AlipayFundTransUniTransferResponse response = getAlipayFundTransUniTransferResponse(amount, sysUserPayAccount.getOpenId());
System.out.println(response.getBody());
log.info(response.getBody());
if (response.isSuccess()) {
@ -363,12 +364,10 @@ public class AliPayServiceImpl implements AliPayService {
// 账户余额不足,发送邮件通知
// ArrayList<String> tos = CollUtil.newArrayList("2119157836@qq.com");
String content = String.format("账户余额不足:用户%s提现%s", sysUser.getNickName(), amount);
MailUtil.send(tos, "魔创未来", content, false);
this.sendAlertEmail(tos, String.format("账户余额不足:用户%s提现%s", sysUser.getNickName(), amount));
throw new ServiceException("网络异常,请稍后再试", HttpStatus.SHOW_ERROR_MSG);
}
System.out.println("用户" + SecurityUtils.getLoginUser().getUser().getNickName() + "提现失败:" + response.getSubMsg());
log.error("用户{}提现失败:{}", SecurityUtils.getLoginUser().getUser().getNickName(), response.getSubMsg());
throw new ServiceException("提现失败", HttpStatus.SHOW_ERROR_MSG);
} finally {
redisCache.deleteObject("alipay:fetch:user:" + SecurityUtils.getUserId());
@ -473,7 +472,7 @@ public class AliPayServiceImpl implements AliPayService {
// 已经绑定过,直接返回
return "success";
}
System.out.println("绑定成功openId/uid" + (StrUtil.isEmpty(openId) ? uid : openId));
log.info("绑定成功openId/uid{}", StrUtil.isEmpty(openId) ? uid : openId);
// 将openId与当前商城用户绑定保存到数据库
SysUserPayAccount userPayAccount = new SysUserPayAccount();
userPayAccount.setUserId(userId);
@ -484,7 +483,7 @@ public class AliPayServiceImpl implements AliPayService {
redisCache.setCacheObject("alipay:bind:user:status:" + userId, "1", 4, TimeUnit.SECONDS);
return "success";
} else {
System.out.println("绑定失败:" + response.getSubMsg());
log.error("绑定失败:{}", response.getSubMsg());
redisCache.setCacheObject("alipay:bind:user:status:" + userId, "0", 4, TimeUnit.SECONDS);
return "fail";
}
@ -623,6 +622,11 @@ public class AliPayServiceImpl implements AliPayService {
return alipayClient.certificateExecute(request);
}
@Async
public void sendAlertEmail(List<String> emails, String content) {
MailUtil.send(emails, "魔创未来", content, false);
}
public AlipayConfig getAlipayConfig() throws FileNotFoundException {
AlipayConfig config = new AlipayConfig();