Commit ee5083b7 authored by 张辰's avatar 张辰

add oss

parent adbcc2e2
......@@ -17,6 +17,18 @@
<groupId>com.tanpu</groupId>
<artifactId>common</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
</dependencies>
</project>
package com.tanpu.community.api.beans;
import lombok.Data;
import java.time.LocalDate;
@Data
public class KafkaDurationUptMsg {
private String ident;
private Long durMillsInc;
}
package com.tanpu.community.api.beans;
import lombok.Data;
@Data
public class KafkaVisitorMsg {
/**
* 详情id(这里指的详情id是指页面访问时访问的内容id)
*/
private String id;
/**
* 当前页面id
*/
private String to;
/**
* 页面每次访问的标识,每次进入页面产生一个新的标识,代表本次访问此页面
*/
private String ident;
/**
* 事件发生时间戳ms
*/
private Long localTime;
/**
* 当前登录的用户Id
*/
private String uid;
}
package com.tanpu.community.api.constants;
public enum BlockTypeEnum {
USER(1,"屏蔽用户"),CONTENT(2,"屏蔽内容");
USER(1,"屏蔽用户"),
THEME(2,"屏蔽主题");
private Integer code;
private String type;
......
......@@ -2,7 +2,8 @@ package com.tanpu.community.api.constants;
public enum CollectionTypeEnum {
LIKE(1,"点赞"),BOOK(2,"收藏");
LIKE(1,"点赞"),
BOOK(2,"收藏");
private Integer code;
private String type;
......
......@@ -2,9 +2,7 @@ package com.tanpu.community.api.constants;
public enum CommentTypeEnum {
TEXT(1,"纯文字");
THEME(1,"对主题的评论");
private Integer code;
private String type;
......
package com.tanpu.community.api.enums;
public enum OssRelType {
None(0, "无关联"),
Theme(1, "关联主题"),
;
public int type;
public String desc;
OssRelType(int type, String desc) {
this.type = type;
this.desc = desc;
}
}
......@@ -28,6 +28,11 @@
<artifactId>mybatis-plus-generator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
......@@ -50,6 +55,11 @@
<version>2.3</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
......@@ -87,6 +97,14 @@
<artifactId>jedis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
......
package com.tanpu.community.controller;
import com.tanpu.community.manager.KafkaManager;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -13,9 +14,13 @@ public class TestController {
@Autowired
private KafkaManager kafkaManager;
@Autowired
private VisitSummaryService visitSummaryService;
@PostMapping(value = "/sendKafka")
@ResponseBody
public String sendKafka(@RequestBody String message) {
return "success";
visitSummaryService.updateDurByIdent("12", 1);
return "22";
}
}
......@@ -33,7 +33,7 @@ public class ThemeController {
public String insertTheme(@RequestBody ThemeDTO themeDTO){
String userId="liujm";
themeDTO.setAuthorId(userId);
themeManager.insert(ThemeConvert.convertToEntity(themeDTO));
// themeManager.insert(ThemeConvert.convertToEntity(themeDTO));
return "success";
}
......@@ -57,7 +57,7 @@ public class ThemeController {
@ResponseBody
public String commetOnTheme(String themeId,String commet){
String user="liujm";
themeManager.comment(themeId,user,commet);
// themeManager.comment(themeId,user,commet);
return "success";
}
......@@ -92,7 +92,7 @@ public class ThemeController {
@ResponseBody
public String bookTheme(String themeId){
String user="liujm";
themeManager.book(themeId,user);
// themeManager.book(themeId,user);
return "success";
}
......@@ -109,7 +109,7 @@ public class ThemeController {
@ResponseBody
public String concealTheme(String themeId){
String user="liujm";
themeManager.blockContent(themeId,user);
// themeManager.blockContent(themeId,user);
return "success";
}
}
......@@ -22,8 +22,8 @@ public class CodeAutoGenerator {
String mysqlUserName = "tamp_admin";
String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community";
// String[] tables = new String[]{"visit_summary"};
String[] tables = new String[]{"visit_summary", "black_list","collection","comment","fans_rel","file_record","home_page","theme","topic"};
String[] tables = new String[]{"file_record"};
// String[] tables = new String[]{"visit_summary", "black_list","collection","comment","fans_rel","file_record","home_page","theme","topic"};
String basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.community";
......
......@@ -22,7 +22,7 @@ import javax.sql.DataSource;
*/
@Configuration
@Slf4j
@MapperScan(basePackages = CommunityConstant.PACKAGE_BASE + ".dao.mapper", sqlSessionTemplateRef = "communitySqlSessionTemplate")
@MapperScan(basePackages = CommunityConstant.PACKAGE_BASE + ".dao.mapper.community", sqlSessionTemplateRef = "communitySqlSessionTemplate")
public class CommunityDataSourceConfig {
@ConfigurationProperties(prefix = "spring.datasource.community")
@Bean(name = "communityDataSource")
......@@ -51,8 +51,7 @@ public class CommunityDataSourceConfig {
@Bean(name = "communitySqlSessionTemplate")
@Primary
public SqlSessionTemplate communitySqlSessionTemplate(@Qualifier("communitySqlSessionFactory")
SqlSessionFactory sqlSessionFactory) {
public SqlSessionTemplate communitySqlSessionTemplate(@Qualifier("communitySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
package com.tanpu.community.dao;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.tanpu.community.api.CommunityConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* created by xd on 2021/6/3
*/
@Configuration
@Slf4j
@MapperScan(basePackages = CommunityConstant.PACKAGE_BASE + ".dao.mapper.user", sqlSessionTemplateRef = "userSqlSessionTemplate")
public class UserDataSourceConfig {
@ConfigurationProperties(prefix = "spring.datasource.user")
@Bean(name = "userDataSource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "userSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("userDataSource") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(
"classpath*:mapper/user/*.xml"));
return bean.getObject();
}
@Bean(name = "userTransactionManager")
public DataSourceTransactionManager userTransactionManager(@Qualifier("userDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "userSqlSessionTemplate")
public SqlSessionTemplate userSqlSessionTemplate(@Qualifier("userSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
......@@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
* </p>
*
* @author xudong
* @since 2021-06-10
* @since 2021-06-17
*/
@TableName("file_record")
@ApiModel(value="FileRecordEntity对象", description="文件")
......@@ -27,11 +27,19 @@ public class FileRecordEntity implements Serializable {
private String originalName;
@ApiModelProperty(value = "逻辑url")
private String logicUrl;
private String logicKey;
@ApiModelProperty(value = "预览url")
private String previewUrl;
private String presignedUrl;
@ApiModelProperty(value = "关联的内容类型")
private Integer relType;
@ApiModelProperty(value = "关联的内容ID")
private String relId;
private String createBy;
private LocalDateTime createTime;
......@@ -59,12 +67,12 @@ public class FileRecordEntity implements Serializable {
this.originalName = originalName;
}
public String getLogicUrl() {
return logicUrl;
public String getLogicKey() {
return logicKey;
}
public void setLogicUrl(String logicUrl) {
this.logicUrl = logicUrl;
public void setLogicKey(String logicKey) {
this.logicKey = logicKey;
}
public String getPreviewUrl() {
......@@ -75,6 +83,30 @@ public class FileRecordEntity implements Serializable {
this.previewUrl = previewUrl;
}
public String getPresignedUrl() {
return presignedUrl;
}
public void setPresignedUrl(String presignedUrl) {
this.presignedUrl = presignedUrl;
}
public Integer getRelType() {
return relType;
}
public void setRelType(Integer relType) {
this.relType = relType;
}
public String getRelId() {
return relId;
}
public void setRelId(String relId) {
this.relId = relId;
}
public String getCreateBy() {
return createBy;
}
......@@ -120,8 +152,11 @@ public class FileRecordEntity implements Serializable {
return "FileRecordEntity{" +
"id=" + id +
", originalName=" + originalName +
", logicUrl=" + logicUrl +
", logicKey=" + logicKey +
", previewUrl=" + previewUrl +
", presignedUrl=" + presignedUrl +
", relType=" + relType +
", relId=" + relId +
", createBy=" + createBy +
", createTime=" + createTime +
", updateBy=" + updateBy +
......
......@@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
* </p>
*
* @author xudong
* @since 2021-06-10
* @since 2021-06-15
*/
@TableName("visit_summary")
@ApiModel(value="VisitSummaryEntity对象", description="浏览记录")
......@@ -24,7 +24,7 @@ public class VisitSummaryEntity implements Serializable {
private String id;
@ApiModelProperty(value = "session_id")
private String sessionId;
private String ident;
@ApiModelProperty(value = "浏览者id")
private String visitorId;
......@@ -60,12 +60,12 @@ public class VisitSummaryEntity implements Serializable {
this.id = id;
}
public String getSessionId() {
return sessionId;
public String getIdent() {
return ident;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
public void setIdent(String ident) {
this.ident = ident;
}
public String getVisitorId() {
......@@ -152,7 +152,7 @@ public class VisitSummaryEntity implements Serializable {
public String toString() {
return "VisitSummaryEntity{" +
"id=" + id +
", sessionId=" + sessionId +
", ident=" + ident +
", visitorId=" + visitorId +
", authorId=" + authorId +
", refId=" + refId +
......
package com.tanpu.community.dao.entity.user;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
*
* </p>
*
* @author xudong
* @since 2021-06-16
*/
@TableName("user_rist_rz")
@ApiModel(value="UserRistRzEntity对象", description="")
public class UserRistRzEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "唯一主键")
private String id;
@ApiModelProperty(value = "用户手机号认证")
private String urrRzPhone;
@ApiModelProperty(value = "用户手机号认证时间")
private LocalDateTime urrRzPhoneDate;
@ApiModelProperty(value = "认证用户姓名")
private String urrRzName;
@ApiModelProperty(value = "身份信息认证-证件类型")
private String urrRzCertType;
@ApiModelProperty(value = "身份信息认证-证件号")
private String urrRzCertNo;
@ApiModelProperty(value = "身份信息认证时间")
private LocalDateTime urrRzCertDate;
@ApiModelProperty(value = "合格投资者认证关联用户记录")
private String investorCertifiedId;
@ApiModelProperty(value = "合格投资者认证状态")
private Integer investorCertifiedStatus;
@ApiModelProperty(value = "合格投资者认证时间")
private LocalDateTime investorCertifiedTime;
@ApiModelProperty(value = "风险测评认证关联用户记录")
private String investorRiskrzId;
@ApiModelProperty(value = "风险测评认证状态")
private Integer investorRiskrzStatus;
@ApiModelProperty(value = "风险测评认证时间")
private LocalDateTime investorRiskrzTime;
@ApiModelProperty(value = "测评到期时间")
private LocalDateTime expireTime;
@ApiModelProperty(value = "机构ID")
private String orgId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createtime;
@ApiModelProperty(value = "创建人")
private String createby;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updatetime;
@ApiModelProperty(value = "修改人")
private String updateby;
@ApiModelProperty(value = "删除标识")
private Integer deletetag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrrRzPhone() {
return urrRzPhone;
}
public void setUrrRzPhone(String urrRzPhone) {
this.urrRzPhone = urrRzPhone;
}
public LocalDateTime getUrrRzPhoneDate() {
return urrRzPhoneDate;
}
public void setUrrRzPhoneDate(LocalDateTime urrRzPhoneDate) {
this.urrRzPhoneDate = urrRzPhoneDate;
}
public String getUrrRzName() {
return urrRzName;
}
public void setUrrRzName(String urrRzName) {
this.urrRzName = urrRzName;
}
public String getUrrRzCertType() {
return urrRzCertType;
}
public void setUrrRzCertType(String urrRzCertType) {
this.urrRzCertType = urrRzCertType;
}
public String getUrrRzCertNo() {
return urrRzCertNo;
}
public void setUrrRzCertNo(String urrRzCertNo) {
this.urrRzCertNo = urrRzCertNo;
}
public LocalDateTime getUrrRzCertDate() {
return urrRzCertDate;
}
public void setUrrRzCertDate(LocalDateTime urrRzCertDate) {
this.urrRzCertDate = urrRzCertDate;
}
public String getInvestorCertifiedId() {
return investorCertifiedId;
}
public void setInvestorCertifiedId(String investorCertifiedId) {
this.investorCertifiedId = investorCertifiedId;
}
public Integer getInvestorCertifiedStatus() {
return investorCertifiedStatus;
}
public void setInvestorCertifiedStatus(Integer investorCertifiedStatus) {
this.investorCertifiedStatus = investorCertifiedStatus;
}
public LocalDateTime getInvestorCertifiedTime() {
return investorCertifiedTime;
}
public void setInvestorCertifiedTime(LocalDateTime investorCertifiedTime) {
this.investorCertifiedTime = investorCertifiedTime;
}
public String getInvestorRiskrzId() {
return investorRiskrzId;
}
public void setInvestorRiskrzId(String investorRiskrzId) {
this.investorRiskrzId = investorRiskrzId;
}
public Integer getInvestorRiskrzStatus() {
return investorRiskrzStatus;
}
public void setInvestorRiskrzStatus(Integer investorRiskrzStatus) {
this.investorRiskrzStatus = investorRiskrzStatus;
}
public LocalDateTime getInvestorRiskrzTime() {
return investorRiskrzTime;
}
public void setInvestorRiskrzTime(LocalDateTime investorRiskrzTime) {
this.investorRiskrzTime = investorRiskrzTime;
}
public LocalDateTime getExpireTime() {
return expireTime;
}
public void setExpireTime(LocalDateTime expireTime) {
this.expireTime = expireTime;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public LocalDateTime getCreatetime() {
return createtime;
}
public void setCreatetime(LocalDateTime createtime) {
this.createtime = createtime;
}
public String getCreateby() {
return createby;
}
public void setCreateby(String createby) {
this.createby = createby;
}
public LocalDateTime getUpdatetime() {
return updatetime;
}
public void setUpdatetime(LocalDateTime updatetime) {
this.updatetime = updatetime;
}
public String getUpdateby() {
return updateby;
}
public void setUpdateby(String updateby) {
this.updateby = updateby;
}
public Integer getDeletetag() {
return deletetag;
}
public void setDeletetag(Integer deletetag) {
this.deletetag = deletetag;
}
@Override
public String toString() {
return "UserRistRzEntity{" +
"id=" + id +
", urrRzPhone=" + urrRzPhone +
", urrRzPhoneDate=" + urrRzPhoneDate +
", urrRzName=" + urrRzName +
", urrRzCertType=" + urrRzCertType +
", urrRzCertNo=" + urrRzCertNo +
", urrRzCertDate=" + urrRzCertDate +
", investorCertifiedId=" + investorCertifiedId +
", investorCertifiedStatus=" + investorCertifiedStatus +
", investorCertifiedTime=" + investorCertifiedTime +
", investorRiskrzId=" + investorRiskrzId +
", investorRiskrzStatus=" + investorRiskrzStatus +
", investorRiskrzTime=" + investorRiskrzTime +
", expireTime=" + expireTime +
", orgId=" + orgId +
", createtime=" + createtime +
", createby=" + createby +
", updatetime=" + updatetime +
", updateby=" + updateby +
", deletetag=" + deletetag +
"}";
}
}
package com.tanpu.community.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanpu.community.dao.entity.AlertInfoEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* created by xd on 2021/6/5
*/
@Mapper
public interface AlertInfoMapper extends BaseMapper<AlertInfoEntity> {
}
......@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author xudong
* @since 2021-06-10
* @since 2021-06-17
*/
public interface FileRecordMapper extends BaseMapper<FileRecordEntity> {
......
......@@ -2,6 +2,8 @@ package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
/**
* <p>
......@@ -9,8 +11,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author xudong
* @since 2021-06-10
* @since 2021-06-15
*/
public interface VisitSummaryMapper extends BaseMapper<VisitSummaryEntity> {
@Update("update visit_summary set duration=duration+#{dur} where ident=#{ident}")
void updateDurByIdent(@Param("ident") String ident, @Param("dur") Integer dur);
}
package com.tanpu.community.dao.mapper.user;
import com.tanpu.community.dao.entity.user.UserRistRzEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-16
*/
public interface UserRistRzMapper extends BaseMapper<UserRistRzEntity> {
}
package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON;
import com.tanpu.community.api.beans.KafkaDurationUptMsg;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -14,6 +17,10 @@ public class KafkaManager {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private VisitSummaryService visitSummaryService;
// public void sendMessage(String message) {
// System.out.println("#### send " + message);
// this.kafkaTemplate.send("users", message);
......@@ -26,4 +33,11 @@ public class KafkaManager {
public void consumeVisitorHis(String message) {
System.out.println("#### receive " + message);
}
// todo topic
@KafkaListener(topics = "newCommunityVisitor")
public void consumeDurationUpdate(String message) {
KafkaDurationUptMsg msg = JSON.parseObject(message, KafkaDurationUptMsg.class);
visitSummaryService.updateDurByIdent(msg.getIdent(), msg.getDurMillsInc().intValue());
}
}
......@@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
......@@ -45,21 +44,18 @@ public class ThemeManager {
//点赞
public void like(String themeId, String userId) {
CollectionEntity collectionEntity = new CollectionEntity();
collectionEntity.setCollectionType(CollectionTypeEnum.LIKE.getCode());
collectionEntity.setAuthorId(userId);
collectionEntity.setTargetId(themeId);
collectionEntity.setCreateBy(userId);
collectionEntity.setCreateTime(LocalDateTime.now());
collectionService.insertCollection(collectionEntity);
collectionService.addCollection(themeId, userId, CollectionTypeEnum.LIKE);
}
//评论
public void comment(String themeId, String userId,String comment) {
public void unlike(String themeId, String userId) {
}
// 评论(对主题)
public void commentToTheme(String themeId, String userId, String comment) {
CommentEntity commentEntity = new CommentEntity();
commentEntity.setTargetId(themeId);
commentEntity.setAuthorId(userId);
commentEntity.setCommentType(CommentTypeEnum.TEXT.getCode());
commentEntity.setCommentType(CommentTypeEnum.THEME.getCode());
commentEntity.setContent(comment);
commentService.insertComment(commentEntity);
}
......@@ -75,36 +71,49 @@ public class ThemeManager {
}
//收藏
public void book(String themeId, String userId) {
CollectionEntity collectionEntity = new CollectionEntity();
collectionEntity.setCollectionType(CollectionTypeEnum.BOOK.getCode());
collectionEntity.setAuthorId(userId);
collectionEntity.setTargetId(themeId);
collectionEntity.setCreateBy(userId);
collectionEntity.setCreateTime(LocalDateTime.now());
collectionService.insertCollection(collectionEntity);
public void favorite(String themeId, String userId) {
collectionService.addCollection(themeId, userId, CollectionTypeEnum.BOOK);
}
public void unFavorite(String themeId, String userId) {
}
//投诉(主题)
public void complaint(String themeId, String user) {
//TODO
}
//屏蔽(用户)
public void blockUser(String themeId, String userId) {
BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeService.selectTheme(themeId).getAuthorId());
if (selectOne==null){
blackListService.insertBlackList(userId, BlockTypeEnum.USER.getCode(), themeService.selectTheme(themeId).getAuthorId());
}
String blockId = themeService.selectTheme(themeId).getAuthorId();
blackListService.addBlock(blockId, userId, BlockTypeEnum.USER);
}
//屏蔽(内容)
public void blockContent(String themeId, String userId) {
BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeId);
// 解除屏蔽(用户)
public void unblockUser(String themeId, String userId) {
}
// 屏蔽(主题)
public void blockTheme(String themeId, String userId) {
blackListService.addBlock(themeId, userId, BlockTypeEnum.THEME);
BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeService.selectTheme(themeId).getAuthorId());
if (selectOne==null){
blackListService.insertBlackList(userId, BlockTypeEnum.USER.getCode(), themeId);
blackListService.addBlock(themeService.selectTheme(themeId).getAuthorId(), userId, BlockTypeEnum.USER);
}
}
public void insert(ThemeEntity themeEntity) {
themeService.insertTheme(themeEntity);
// 解除屏蔽(主题)
public void unblockTheme(String themeId, String userId) {
blackListService.removeBlackList(themeId, userId, BlockTypeEnum.USER);
}
//屏蔽(内容)
// public void blockContent(String themeId, String userId) {
// BlackListEntity selectOne = blackListService.selectOne(userId, BlockTypeEnum.USER.getCode(), themeId);
// if (selectOne==null){
// blackListService.insertBlackList(userId, BlockTypeEnum.USER.getCode(), themeId);
// }
// }
}
......@@ -34,19 +34,16 @@ public class TopicManager {
return topicService.queryTopicList();
}
public void setTopTopic(String topicId,boolean setTop) {
TopicEntity topicEntity= topicService.queryById(topicId);
if (topicEntity==null){
throw new BizException("话题id不正确:"+topicId);
public void setTopTopic(String topicId, boolean setTop) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null){
throw new BizException("话题id不正确:" + topicId);
}
if (setTop){
topicService.updateTopicToTop(topicId);
}else {
topicService.updateTopicNotTop(topicId);
}
}
public void setTopicConceal(String topicId, boolean setConceal) {
......
package com.tanpu.community.manager.exception;
public class BizException extends Exception{
public BizException(){
super();
}
public BizException(String message){
super(message);
}
public BizException(String message,Throwable cause){
super(message, cause);
}
public BizException(Throwable cause){
super(cause);
}
}
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.constants.BlockTypeEnum;
import com.tanpu.community.dao.entity.community.BlackListEntity;
import com.tanpu.community.dao.mapper.community.BlackListMapper;
import org.springframework.stereotype.Service;
......@@ -12,7 +13,12 @@ public class BlackListService {
@Resource
private BlackListMapper blackListMapper;
public void insertBlackList(BlackListEntity blackListEntity){
public void addBlock(String blockId, String userId, BlockTypeEnum type) {
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedId(blockId);
blackListEntity.setBlocker(userId);
blackListEntity.setBlockedType(type.getCode());
blackListMapper.insert(blackListEntity);
}
......@@ -21,17 +27,10 @@ public class BlackListService {
eq(BlackListEntity::getBlockedId, blockId).eq(BlackListEntity::getBlockedType, blockType));
}
public void insertBlackList(String blocker,Integer blockType,String blockId){
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedType(blockType);
blackListEntity.setBlocker(blocker);
blackListEntity.setBlockedId(blockId);
blackListMapper.insert(blackListEntity);
}
public void deleteBlackList(String blocker,String blockId,String blockType){
blackListMapper.delete(new LambdaQueryWrapper<BlackListEntity>().eq(BlackListEntity::getBlocker,blocker).
eq(BlackListEntity::getBlockedId,blockId).eq(BlackListEntity::getBlockedType,blockType));
return;
public void removeBlackList(String blocker, String blockId, BlockTypeEnum blockType) {
blackListMapper.delete(new LambdaQueryWrapper<BlackListEntity>()
.eq(BlackListEntity::getBlocker, blocker)
.eq(BlackListEntity::getBlockedId, blockId)
.eq(BlackListEntity::getBlockedType, blockType.getCode()));
}
}
......@@ -2,12 +2,14 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanpu.community.api.constants.CollectionTypeEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.mapper.community.CollectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
......@@ -15,8 +17,14 @@ public class CollectionService {
@Resource
private CollectionMapper collectionMapper;
public void insertCollection(CollectionEntity collectionEntity){
public void addCollection(String themeId, String userId, CollectionTypeEnum type){
// todo 判断是否存在
CollectionEntity collectionEntity = new CollectionEntity();
collectionEntity.setCollectionType(type.getCode());
collectionEntity.setAuthorId(userId);
collectionEntity.setTargetId(themeId);
collectionEntity.setCreateBy(userId);
collectionMapper.insert(collectionEntity);
}
......
package com.tanpu.community.service;
import com.tanpu.community.dao.entity.AlertInfoEntity;
import com.tanpu.community.dao.mapper.AlertInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* created by xd on 2021/6/6
*/
@Service
public class CommunityService {
@Autowired
private AlertInfoMapper alertInfoMapper;
public void saveAlertInfo(String content) {
AlertInfoEntity entity = AlertInfoEntity.builder().content(content).createBy("SYS").build();
alertInfoMapper.insert(entity);
}
}
package com.tanpu.community.service;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.util.AliyunOSSHelper;
import com.tanpu.community.api.enums.OssRelType;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.mapper.community.FileRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@Slf4j
@Service
public class OSSFileService {
@Value("${aliyun.oss.endpoint}")
public String endpoint;
@Value("${aliyun.oss.accessId}")
public String accessId;
@Value("${aliyun.oss.accessSK}")
public String accessSK;
@Value("${aliyun.oss.bucketName}")
public String bucketName;
private AliyunOSSHelper ossHelper;
@Resource
private FileRecordMapper fileRecordMapper;
@PostConstruct
public void init() {
ossHelper = AliyunOSSHelper.build(endpoint, accessId, accessSK);
}
@Transactional
public FileRecordEntity uploadFile(byte[] data, String fileName, String relId, OssRelType relType) {
String fileSuffix = fileName.substring(fileName.lastIndexOf('.') + 1);
return uploadFile(data, fileName, fileSuffix, relId, relType);
}
@Transactional
public FileRecordEntity uploadFile(byte[] data, String fileName, String fileSuffix,
String relId, OssRelType relType) {
// todo uniqueLong
String key = "";
String id = "";
ossHelper.writeFile(bucketName, key, data, fileSuffix);
FileRecordEntity record = new FileRecordEntity();
record.setId(id);
record.setDeleteTag(BizStatus.DeleteTag.tag_init);
record.setLogicKey(key);
record.setOriginalName(fileName);
record.setPresignedUrl(ossHelper.getPreSignedUrl(bucketName, key));
record.setRelType(relType.type);
record.setRelId(relId);
fileRecordMapper.insert(record);
return record;
}
}
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.user.UserRistRzEntity;
import com.tanpu.community.dao.mapper.user.UserRistRzMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Slf4j
@Service
public class UserService {
@Resource
private UserRistRzMapper userRistRzMapper;
// 查询是否合格投资者
public Boolean isQualifiedInvestor(String userId) {
UserRistRzEntity ristRz = userRistRzMapper.selectOne(new LambdaQueryWrapper<UserRistRzEntity>().eq(UserRistRzEntity::getCreateby, userId));
// todo 1代表合格
return (ristRz != null && ristRz.getInvestorCertifiedStatus() == 1);
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.VisitSummaryEntity;
import com.tanpu.community.dao.mapper.community.VisitSummaryMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -21,4 +22,9 @@ public class VisitSummaryService {
return visitSummaryMapper.selectCount(new LambdaQueryWrapper<VisitSummaryEntity>()
.eq(VisitSummaryEntity::getRefId, topicId));
}
// 更新访问时长
public void updateDurByIdent(String ident, Integer dur) {
visitSummaryMapper.updateDurByIdent(ident, dur);
}
}
package com.tanpu.community.web;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.CommunityApi;
import com.tanpu.community.api.beans.AlertReq;
import com.tanpu.community.service.CommunityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.LinkedList;
import java.util.List;
/**
* created by xd on 2021/6/5
*/
@Slf4j
@RestController
public class CommunityController implements CommunityApi {
@Autowired
private CommunityService communityService;
@Override
public CommonResp<List<AlertReq>> weworkRobotAlert(AlertReq alertReq) {
communityService.saveAlertInfo(JsonUtil.toJson(alertReq));
return CommonResp.success(new LinkedList<>());
}
}
......@@ -22,7 +22,14 @@ spring.datasource:
maxActive: 2
minIdle: 2
initialSize: 2
user:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username: tamp_admin
password: '@imeng123'
maxActive: 2
minIdle: 2
initialSize: 2
spring.redis:
host: 118.190.63.109
......@@ -63,3 +70,9 @@ spring:
zipkin:
enabled: false
aliyun:
oss:
endpoint: http://oss-cn-shanghai.aliyuncs.com
accessId: LTAIAKEzVydP0Q9P
accessSK: 59V9ke9txaIFzWxHFKTb1eoOOpmKpJ
bucketName: tamperfeodev
......@@ -6,8 +6,11 @@
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.FileRecordEntity">
<id column="id" property="id" />
<result column="original_name" property="originalName" />
<result column="logic_url" property="logicUrl" />
<result column="logic_key" property="logicKey" />
<result column="preview_url" property="previewUrl" />
<result column="presigned_url" property="presignedUrl" />
<result column="rel_type" property="relType" />
<result column="rel_id" property="relId" />
<result column="create_by" property="createBy" />
<result column="create_time" property="createTime" />
<result column="update_by" property="updateBy" />
......
......@@ -5,7 +5,7 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.VisitSummaryEntity">
<id column="id" property="id" />
<result column="session_id" property="sessionId" />
<result column="ident" property="ident" />
<result column="visitor_id" property="visitorId" />
<result column="author_id" property="authorId" />
<result column="ref_id" property="refId" />
......
<?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.tanpu.community.dao.mapper.user.UserRistRzMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.user.UserRistRzEntity">
<id column="id" property="id" />
<result column="urr_rz_phone" property="urrRzPhone" />
<result column="urr_rz_phone_date" property="urrRzPhoneDate" />
<result column="urr_rz_name" property="urrRzName" />
<result column="urr_rz_cert_type" property="urrRzCertType" />
<result column="urr_rz_cert_no" property="urrRzCertNo" />
<result column="urr_rz_cert_date" property="urrRzCertDate" />
<result column="investor_certified_id" property="investorCertifiedId" />
<result column="investor_certified_status" property="investorCertifiedStatus" />
<result column="investor_certified_time" property="investorCertifiedTime" />
<result column="investor_riskrz_id" property="investorRiskrzId" />
<result column="investor_riskrz_status" property="investorRiskrzStatus" />
<result column="investor_riskrz_time" property="investorRiskrzTime" />
<result column="expire_time" property="expireTime" />
<result column="org_id" property="orgId" />
<result column="createtime" property="createtime" />
<result column="createby" property="createby" />
<result column="updatetime" property="updatetime" />
<result column="updateby" property="updateby" />
<result column="deletetag" property="deletetag" />
</resultMap>
</mapper>
......@@ -25,6 +25,41 @@
<module>community-service</module>
</modules>
<repositories>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://maven.tanpuyun.com:8089/repository/maven-releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://maven.tanpuyun.com:8089/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>aliyun-repos</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
......@@ -36,7 +71,7 @@
<dependency>
<groupId>com.tanpu</groupId>
<artifactId>common</artifactId>
<version>1.0.4-RELEASE</version>
<version>1.0.5-SNAPSHOT</version>
</dependency>
<dependency>
......@@ -74,6 +109,20 @@
<version>3.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
......@@ -100,6 +149,13 @@
<type>jar</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
......@@ -115,16 +171,6 @@
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>aliyun-repos</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment