Compare commits
8 Commits
f88c68ac0a
...
6ae9eca9b6
Author | SHA1 | Date |
---|---|---|
|
6ae9eca9b6 | |
|
9dcf061dcb | |
|
02d8dc45dd | |
|
83b07054a1 | |
|
7efb7973ef | |
|
58839f1f12 | |
|
1398011ee5 | |
|
fa542d1569 |
|
@ -89,6 +89,12 @@
|
|||
<artifactId>mcwl-myInvitation</artifactId>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mcwl</groupId>
|
||||
<artifactId>mcwl-communityCenter</artifactId>
|
||||
<version>3.8.8</version>
|
||||
</dependency>
|
||||
<!-- 公共模块-->
|
||||
<dependency>
|
||||
<groupId>com.mcwl</groupId>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.service.CommunityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 社区
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("community")
|
||||
@RequiredArgsConstructor
|
||||
public class CommunityController {
|
||||
|
||||
private final CommunityService communityService;
|
||||
|
||||
|
||||
/**
|
||||
* 社区列表
|
||||
* @return 社区列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public List<Community> getCommunityList(){
|
||||
return communityService.list();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加社区
|
||||
* @param community 社区
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public boolean addCommunity(@RequestBody Community community){
|
||||
return communityService.save(community);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除社区
|
||||
* @param id 社区id
|
||||
* @return 删除结果
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public boolean deleteCommunity(Long id){
|
||||
return communityService.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改社区
|
||||
* @param community 社区
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public boolean updateCommunity(@RequestBody Community community){
|
||||
return communityService.updateById(community);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.communityCenter.service.InviteMappingService;
|
||||
import com.mcwl.communityCenter.service.InviteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 邀请
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("invite")
|
||||
@RequiredArgsConstructor
|
||||
public class InviteController {
|
||||
|
||||
private final InviteService inviteService;
|
||||
|
||||
/**
|
||||
* 邀请码链接
|
||||
*/
|
||||
@GetMapping("inviteCode")
|
||||
public AjaxResult inviteCode(){
|
||||
// 获取邀请码链接
|
||||
String inviteCode = inviteService.getInviteCode();
|
||||
return AjaxResult.success(inviteCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.dto.PublishRes;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("publish")
|
||||
@RequiredArgsConstructor
|
||||
public class PublishController {
|
||||
|
||||
private final PublishService publishService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取发布列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("list")
|
||||
public TableDataInfo getCommunityList(@RequestBody PageDomain pageDomain) {
|
||||
return publishService.listByPage(pageDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布详情
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public AjaxResult getPublishDetail(Long id) {
|
||||
|
||||
PublishVo publishVo = publishService.getDetail(id);
|
||||
if (Objects.isNull(publishVo)) {
|
||||
return AjaxResult.error("获取详情失败");
|
||||
}
|
||||
return AjaxResult.success(publishVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public AjaxResult addPublish(@RequestBody PublishRes publishRes) {
|
||||
Publish publish = new Publish();
|
||||
BeanUtil.copyProperties(publishRes, publish);
|
||||
return AjaxResult.success(publishService.save(publish));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@GetMapping("remove")
|
||||
public AjaxResult deletePublish(Long id) {
|
||||
return AjaxResult.success(publishService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 提问
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("question")
|
||||
@RequiredArgsConstructor
|
||||
public class QuestionController {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -152,5 +152,17 @@ public class MemberController {
|
|||
return AjaxResult.success(unitPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是会员
|
||||
*/
|
||||
@GetMapping("isMember")
|
||||
public AjaxResult isMember() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Member member = memberService.getUseUserMemberByUserId(userId);
|
||||
if (Optional.ofNullable(member).isPresent()) {
|
||||
return AjaxResult.success(true);
|
||||
}
|
||||
return AjaxResult.success(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.mcwl.memberCenter.service.MemberLevelService;
|
|||
import com.mcwl.pay.config.AliConfig;
|
||||
import com.mcwl.pay.domain.OrderTrade;
|
||||
import com.mcwl.pay.domain.OrderTradeDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -37,6 +38,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* 支付宝支付
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AliPayIntegration {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -20,8 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*
|
||||
*模型
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.web.controller.resource
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
/**模型评论
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.web.controller.resource
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
package com.mcwl.web.controller.resource;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import com.mcwl.common.constant.DictConstants;
|
||||
import com.mcwl.common.core.controller.BaseController;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.utils.oss.OssUtil;
|
||||
import com.mcwl.resource.domain.ModelProduct;
|
||||
import com.mcwl.resource.domain.ModelVersion;
|
||||
import com.mcwl.resource.service.ModelVersionService;
|
||||
import com.mcwl.system.init.DictInit;
|
||||
import com.mcwl.web.controller.common.OssUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/** 模型版本
|
||||
|
@ -87,19 +93,33 @@ public class ModelVersionController extends BaseController {
|
|||
@PostMapping("finbyid")
|
||||
public AjaxResult finbyid(@RequestBody ModelVersion modelVersion)
|
||||
{
|
||||
|
||||
|
||||
ModelVersion modelVersion1 = modelVersionService.getById(modelVersion.getId());
|
||||
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
|
||||
//获取
|
||||
String[] split = modelVersion1.getHigh().split(",");
|
||||
|
||||
for (String s : split) {
|
||||
arrayList.add(DictInit.getDictValue(DictConstants.DICT_TYPE_MODEL_VERSION_HIGH,s));
|
||||
}
|
||||
|
||||
return AjaxResult.success(modelVersion1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("insert")
|
||||
public AjaxResult insert(@RequestBody ModelVersion modelVersion)
|
||||
{
|
||||
|
||||
modelVersionService.save(modelVersion);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("update")
|
||||
public AjaxResult update(@RequestBody ModelVersion modelVersion)
|
||||
{
|
||||
|
@ -107,6 +127,7 @@ public class ModelVersionController extends BaseController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("delete")
|
||||
public AjaxResult delete(@RequestBody ModelVersion modelVersion)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
/**活动
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.web.controller.resource
|
||||
|
|
|
@ -47,6 +47,15 @@ public class SysUserController extends BaseController
|
|||
@Autowired
|
||||
private ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取id
|
||||
*/
|
||||
@GetMapping("/getUserId")
|
||||
public AjaxResult getSysUserId() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
|
|
|
@ -15,6 +15,11 @@ public class DictConstants {
|
|||
*/
|
||||
public static final String MALL_PRODUCT_STATUS = "mall_product_status";
|
||||
|
||||
/**
|
||||
* 高清修复
|
||||
*/
|
||||
public static final String DICT_TYPE_MODEL_VERSION_HIGH = "dict_type_model_version_high";
|
||||
|
||||
/**
|
||||
* 类型模型
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
@ -28,17 +29,21 @@ public class BaseEntity implements Serializable
|
|||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.mcwl.common.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* mybatis-plus 自动填充处理器
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("createBy", SecurityUtils.getUsername(), metaObject);
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
this.setFieldValByName("tenantId", SecurityUtils.getUserId(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("updateBy", SecurityUtils.getUsername(), metaObject);
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,11 @@
|
|||
<version>3.8.8</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mcwl-knowledgePlanet</artifactId>
|
||||
<description>
|
||||
社区中心
|
||||
</description>
|
||||
|
||||
<artifactId>mcwl-communityCenter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
|
@ -0,0 +1,42 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
|
||||
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")
|
||||
public class Community extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 社区名称
|
||||
*/
|
||||
private String communityName;
|
||||
|
||||
/**
|
||||
* 社区类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 有效期类型
|
||||
*/
|
||||
private Integer validityType;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
|
||||
|
||||
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_invite")
|
||||
public class Invite extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id - 租户id
|
||||
*/
|
||||
private Long tenantId;
|
||||
/**
|
||||
* 被邀请人
|
||||
*/
|
||||
private Long inviteeUserId;
|
||||
/**
|
||||
* 受邀类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
|
||||
|
||||
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_invite_mapping")
|
||||
public class InviteMapping extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
/**
|
||||
* 用户id - 租户id
|
||||
*/
|
||||
private String tenantId;
|
||||
/**
|
||||
* 邀请链接
|
||||
*/
|
||||
private String inviteUrl;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
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")
|
||||
public class Publish extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id - 租户id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 发布时间 - 定时发布
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
private Integer commentNum;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
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_question")
|
||||
public class Question extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 用户id - 租户id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 提问用户id
|
||||
*/
|
||||
private Long questionUserId;
|
||||
|
||||
/**
|
||||
* 提问内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 答复用户id
|
||||
*/
|
||||
private Long replyUserId;
|
||||
|
||||
/**
|
||||
* 回复内容
|
||||
*/
|
||||
private String reply;
|
||||
|
||||
/**
|
||||
* 提问图片
|
||||
*/
|
||||
private String questionUrl;
|
||||
|
||||
/**
|
||||
* 是否匿名
|
||||
*/
|
||||
private Integer isAnonymous;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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_user_community")
|
||||
public class UserCommunity extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id - 多租户id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
private Long communityId;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 发布请求参数
|
||||
*/
|
||||
@Data
|
||||
public class PublishRes {
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@NotBlank(message = "内容不能为空")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 发布时间 - 定时发布
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.mcwl.communityCenter.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class PublishVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id - 租户id
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 发布时间 - 定时发布
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
private Integer commentNum;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.mcwl.communityCenter.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CustomTenantHandler implements TenantLineHandler {
|
||||
|
||||
private static final Set<String> tables = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 按id隔离
|
||||
* 需要根据业务需要进行调整.需要多租户的表名
|
||||
*/
|
||||
static {
|
||||
tables.add("cc_publish");
|
||||
tables.add("cc_question");
|
||||
tables.add("cc_user_community");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
// 假设有一个租户上下文,能够从中获取当前用户的租户
|
||||
Long tenantId;
|
||||
try {
|
||||
tenantId = SecurityUtils.getUserId();
|
||||
} catch (Exception e) {
|
||||
return new LongValue(-1L);
|
||||
}
|
||||
// 返回租户ID的表达式,LongValue 是 JSQLParser 中表示 bigint 类型的 class
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantIdColumn() {
|
||||
return "tenant_id";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreTable(String tableName) {
|
||||
// 根据需要返回是否忽略该表,true:表示忽略,false:需要解析并拼接多租户条件
|
||||
return !tables.contains(tableName);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CommunityMapper extends BaseMapper<Community> {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.InviteMapping;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InviteMapper extends BaseMapper<Invite> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.InviteMapping;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InviteMappingMapper extends BaseMapper<InviteMapping> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PublishMapper extends BaseMapper<Publish> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface QuestionMapper extends BaseMapper<Question> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.UserCommunity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserCommunityMapper extends BaseMapper<UserCommunity> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
|
||||
public interface CommunityService extends IService<Community> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.InviteMapping;
|
||||
|
||||
public interface InviteMappingService extends IService<InviteMapping> {
|
||||
String getInviteCode();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
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.Invite;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
|
||||
public interface InviteService extends IService<Invite> {
|
||||
String getInviteCode();
|
||||
}
|
|
@ -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.Community;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
|
||||
public interface PublishService extends IService<Publish> {
|
||||
TableDataInfo listByPage(PageDomain pageDomain);
|
||||
|
||||
PublishVo getDetail(Long id);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
|
||||
public interface QuestionService extends IService<Question> {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.UserCommunity;
|
||||
|
||||
public interface UserCommunityService extends IService<UserCommunity> {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.mapper.CommunityMapper;
|
||||
import com.mcwl.communityCenter.service.CommunityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community> implements CommunityService {
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.InviteMapping;
|
||||
import com.mcwl.communityCenter.mapper.InviteMapper;
|
||||
import com.mcwl.communityCenter.mapper.InviteMappingMapper;
|
||||
import com.mcwl.communityCenter.service.InviteMappingService;
|
||||
import com.mcwl.communityCenter.service.InviteService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class InviteMappingServiceImpl extends ServiceImpl<InviteMappingMapper, InviteMapping> implements InviteMappingService {
|
||||
|
||||
@Override
|
||||
public String getInviteCode() {
|
||||
|
||||
|
||||
|
||||
|
||||
return "https://aaa.com";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
import com.mcwl.communityCenter.mapper.InviteMapper;
|
||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||
import com.mcwl.communityCenter.service.InviteService;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> implements InviteService {
|
||||
@Override
|
||||
public String getInviteCode() {
|
||||
String url = "https://www.yaoqing.com?name=lisi";
|
||||
return url;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.github.pagehelper.PageInfo;
|
||||
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.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.vo.PublishVo;
|
||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> implements PublishService {
|
||||
@Override
|
||||
public TableDataInfo listByPage(PageDomain pageDomain) {
|
||||
// 分页查询
|
||||
Page<Publish> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||
boolean isAsc = Objects.equals(pageDomain.getIsAsc(), "asc");
|
||||
OrderItem orderItem = new OrderItem(pageDomain.getOrderByColumn(), isAsc);
|
||||
page.addOrder(orderItem);
|
||||
|
||||
// 条件设置
|
||||
LambdaQueryWrapper<Publish> lqw = new LambdaQueryWrapper<>();
|
||||
|
||||
// 查询
|
||||
baseMapper.selectPage(page, lqw);
|
||||
|
||||
// 返回数据
|
||||
List<PublishVo> publishVoList = new ArrayList<>();
|
||||
|
||||
// 封装数据
|
||||
List<Publish> publishList = page.getRecords();
|
||||
for (Publish publish : publishList) {
|
||||
PublishVo publishVo = new PublishVo();
|
||||
BeanUtil.copyProperties(publish, publishVo);
|
||||
publishVo.setUserName(SecurityUtils.getUsername());
|
||||
publishVo.setAvatar(SecurityUtils.getLoginUser().getUser().getAvatar());
|
||||
// TODO 评论数
|
||||
publishVo.setCommentNum(0);
|
||||
publishVoList.add(publishVo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(publishVoList);
|
||||
rspData.setTotal(page.getTotal());
|
||||
|
||||
return rspData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublishVo getDetail(Long id) {
|
||||
|
||||
Publish publish = baseMapper.selectById(id);
|
||||
if (Objects.isNull(publish)) {
|
||||
return null;
|
||||
}
|
||||
PublishVo publishVo = new PublishVo();
|
||||
BeanUtil.copyProperties(publish, publishVo);
|
||||
publishVo.setUserName(SecurityUtils.getUsername());
|
||||
publishVo.setAvatar(SecurityUtils.getLoginUser().getUser().getAvatar());
|
||||
return publishVo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||
import com.mcwl.communityCenter.mapper.QuestionMapper;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import com.mcwl.communityCenter.service.QuestionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.UserCommunity;
|
||||
import com.mcwl.communityCenter.mapper.QuestionMapper;
|
||||
import com.mcwl.communityCenter.mapper.UserCommunityMapper;
|
||||
import com.mcwl.communityCenter.service.QuestionService;
|
||||
import com.mcwl.communityCenter.service.UserCommunityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserCommunityServiceImpl extends ServiceImpl<UserCommunityMapper, UserCommunity> implements UserCommunityService {
|
||||
}
|
|
@ -59,6 +59,12 @@
|
|||
<groupId>com.mcwl</groupId>
|
||||
<artifactId>mcwl-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mcwl</groupId>
|
||||
<artifactId>mcwl-communityCenter</artifactId>
|
||||
<version>3.8.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -5,12 +5,16 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
|||
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||
import com.mcwl.communityCenter.handler.CustomTenantHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* MybatisPlus
|
||||
*
|
||||
* @author DaiZibo
|
||||
* @date 2024/12/31
|
||||
* @apiNote
|
||||
|
@ -20,9 +24,15 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Autowired
|
||||
private CustomTenantHandler customTenantHandler;
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 多租户插件
|
||||
interceptor.addInnerInterceptor(tenantLineInnerInterceptor());
|
||||
// 分页插件
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||
// 乐观锁插件
|
||||
|
@ -32,6 +42,17 @@ public class MybatisPlusConfig {
|
|||
return interceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多租户插件 https://baomidou.com/guide/interceptor-tenant-line.html
|
||||
*/
|
||||
public TenantLineInnerInterceptor tenantLineInnerInterceptor() {
|
||||
|
||||
TenantLineInnerInterceptor tenantInterceptor = new TenantLineInnerInterceptor();
|
||||
tenantInterceptor.setTenantLineHandler(customTenantHandler);
|
||||
|
||||
return tenantInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mcwl.resource.domain;
|
||||
|
||||
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;
|
||||
|
@ -7,6 +8,8 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 模型版本
|
||||
* @Author:ChenYan
|
||||
|
@ -121,4 +124,7 @@ public class ModelVersion extends BaseEntity {
|
|||
private String delFlag;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private ArrayList<String> highList;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue