diff --git a/src/main/java/com/rymcu/vertical/core/service/props/DynProps4FilesService.java b/src/main/java/com/rymcu/vertical/core/service/props/DynProps4FilesService.java deleted file mode 100644 index c9b3349..0000000 --- a/src/main/java/com/rymcu/vertical/core/service/props/DynProps4FilesService.java +++ /dev/null @@ -1,348 +0,0 @@ -package com.rymcu.vertical.core.service.props; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.io.*; -import java.util.*; -import java.util.concurrent.TimeUnit; - -/** - * 动态配置文件,可以设置更新周期 - * 配置读取读取服务 - * @author ronger - */ -@Component -public class DynProps4FilesService { - private Logger _log = LoggerFactory.getLogger(DynProps4FilesService.class); - /** - * 属性文件 - */ - private File[] fileArray; - /** - * 启动延时 - */ - private long delay; - /** - * 更新周期 - */ - private long period; - /** - * 属性对象 - */ - private Properties property = new Properties(); - /** - * 文件监控器 - */ - private List monitors; - - /** - * @param files 属性文件 - * @param delay 从DynProps被创建到第一次动态监视的时间间隔. 约束范围delay > 0 - * @param period 动态监视的时间间隔. 约束范围period >= 0;等于0表示不执行动态监视,退化为静态配置文件. - */ - public DynProps4FilesService(File[] files, long delay, long period) throws IOException { - this.fileArray = files; - this.delay = delay; - this.period = period; - init(); - } - - public DynProps4FilesService(List fileNames, long delay, long period) throws IOException { - this.delay = delay; - this.period = period; - fileArray = new File[fileNames.size()]; - int index = 0; - for (String oriFileName : fileNames) { - String fileName = oriFileName.trim(); - if (StringUtils.indexOfIgnoreCase(fileName, "classpath:") == 0) { - fileArray[index++] = new File( - this.getClass().getClassLoader().getResource("").getPath() + File.separator + - fileName.substring("classpath:".length())); - } else { - fileArray[index++] = new File(fileName); - } - } - - init(); - } - - - public DynProps4FilesService(String fileNames, long delay, long period) throws IOException { - this.delay = delay; - this.period = period; - boolean isClassPath = false; - if (fileNames.startsWith("classpath")) { - fileNames = fileNames.substring("classpath:".length()); - isClassPath = true; - } - String[] fileName = fileNames.split("[,|,|;|;]"); - fileArray = new File[fileName.length]; - if (isClassPath) { - for (int i = 0; i < fileName.length; i++) { - fileArray[i] = new File(this.getClass().getClassLoader().getResource("").getPath() + fileName[i]); - } - } else { - for (int i = 0; i < fileName.length; i++) { - fileArray[i] = new File(fileName[i]); - } - } - - init(); - } - - public DynProps4FilesService(File[] files, long period) throws IOException { - this(files, 0, period); - } - - public DynProps4FilesService(String fileNames, long period) throws IOException { - this.period = period; - this.delay = 0; - String[] fileName = fileNames.split("[,|,|;|;]"); - - File[] files = new File[fileName.length]; - for (int i = 0; i < fileName.length; i++) { - files[i] = new File(fileName[i]); - } - init(); - } - - public DynProps4FilesService() { - } - - /** - * 加载属性文件,启动监控 - * - * @throws IOException 加载文件时出现IO异常 - */ - protected void load() throws IOException { - update(); - if (monitors == null) { - monitors = new ArrayList(fileArray.length); - } else { - for (FileMonitor monitor : monitors) { - try { - monitor.timer.cancel(); - } catch (Exception e) { - _log.warn(String.format("Timer for file [%s] cancelling failed.", monitor.file.getAbsolutePath())); - } - } - } - - for (File file : fileArray) { - long lastModify = file.lastModified(); - FileMonitor monitor = new FileMonitor(file, lastModify); - this.monitors.add(monitor); - monitor.doTask(); - } - } - - /** - * 如果文件有更新调用此方法载入 - * - * @throws IOException 没有找到文件或读文件错误时抛出 - */ - protected void update() throws IOException { - for (File file : fileArray) { - InputStream in = null; - try { - in = new FileInputStream(file); - this.property.load(in); - } catch (Exception e) { - if (e instanceof IOException) { - throw (IOException) e; - } - - throw new IOException(e); - } finally { - IOUtils.closeQuietly(in); - } - } - } - - /** - * @param key 需要获取属性值的KEY - * @param def 默认值 - * - * @return 属性值 - */ - public String getProperty(String key, String def) { - String val = this.property.getProperty(key); - return val == null ? def : val.trim(); - } - - public String getProperty(String key) { - String val = this.property.getProperty(key); - return val == null ? null : val.trim(); - } - - /** - * 设置属性值 - * - * @param key - * @param value - */ - public void setProperty(String key, String value) { - this.property.setProperty(key, value); - } - - /** - * @param key 需要获取属性值的KEY - * @param def 默认值 - * - * @return 属性值 - * - * @throws NumberFormatException 如果属性值不是整数形式 - */ - public int getInt(String key, int def) throws NumberFormatException { - String val = this.getProperty(key); - return val == null ? def : Integer.parseInt(val); - } - - public int getInt(String key) throws NumberFormatException { - return getInt(key, 0); - } - - public float getFloat(String key, float def) throws NumberFormatException { - String val = this.getProperty(key); - return val == null ? def : Float.parseFloat(val); - } - - public float getFloat(String key) throws NumberFormatException { - return getFloat(key, 0.0f); - } - - public double getDouble(String key, double def) { - String val = this.getProperty(key); - return val == null ? def : Double.parseDouble(val); - } - public double getDouble(String key) throws NumberFormatException { - return getDouble(key,0.0); - } - - - - public long getLong(String key, long def) { - String val = this.getProperty(key); - return val == null ? def : Long.parseLong(val); - } - - public long getLong(String key) throws NumberFormatException { - return getLong(key, 0L); - } - - private void init() throws IOException { - for (File file : fileArray) { - if (!file.exists() || file.length() == 0) { - throw new IllegalArgumentException("动态配置文件 " + file.getAbsolutePath() + " 不存在,或是空文件!"); - } - if (delay <= 0) { - throw new IllegalArgumentException("定时器延时时间不能为负数!"); - } - if (period <= 0) { - throw new IllegalArgumentException("定时器更新周期不能为负数!"); - } - this.property = new Properties(); - this.load();// 初始构造时,执行第一次加载. - } - //当进程终止时,取消定时任务 - Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook())); - } - - private class ShutdownHook implements Runnable { - private DynProps4FilesService dynProps4FilesService; - - @Override - public void run() { - System.out.println("Monitors cancelling start ..."); - if (monitors != null) { - for (FileMonitor monitor : monitors) { - try { - monitor.timer.cancel(); - } catch (Exception e) { - _log.warn(String.format("Timer for file [%s] cancelling failed.", - monitor.file.getAbsolutePath())); - } - } - } - } - } - - /** - * 描述:一个内部私有类,实时监控文件有没有更新,如果更新则自动载入 - */ - private class FileMonitor { - - private long lastModifiedTime; - private File file; - /** - * 定时器,以守护线程方式启动 - */ - private Timer timer = new Timer(true); - - /** - * @param lastMonitorTime 最后的更新时间 - */ - private FileMonitor(File file, long lastMonitorTime) { - this.file = file; - this.lastModifiedTime = lastMonitorTime; - } - - /** - * 对文件进行实时监控,有更新则自动载入 - */ - private void doTask() { - if (delay < 0) { - delay = 0L; - } - if (period <= 0) { - return;// 如果更新周期非正数,则退化成静态配置文件. - } - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - long t = file.lastModified(); - // 文件被删除 - // 如果动态更新过程中,配置文件被强制删除了,本次不执行任何更新.或者对配置文件进行恢复 - if (t == 0) { - try { - if (file.createNewFile()) { - OutputStream fos = new FileOutputStream(file); - property.store(fos, "文件被删除,自动恢复."); - fos.close(); - } - } catch (IOException ioe2) { - // 这里基本上只有磁盘空间满才会发生,暂时不处理 - } - return; - } - // 文件被更新 - if (t > lastModifiedTime) { - lastModifiedTime = t; - // 2秒后还在改变,则本次更新不做处理 - try { - TimeUnit.SECONDS.sleep(2); - } catch (InterruptedException e) { - // do nothing - } - if (t != file.lastModified()) { - _log.info("文件可能未更新完成,本次不更新!"); - } else { - try { - property.clear(); - update(); - _log.info("UPDATED " + file.getAbsolutePath()); - } catch (IOException ioe) { - _log.error("UPDATING " + file.getAbsolutePath() + " failed", ioe); - } - } - _log.debug("-----------------------:" + property.keySet()); - } - }// end run() - }, delay, period); - } - } -} diff --git a/src/main/java/com/rymcu/vertical/core/service/redis/RedisService.java b/src/main/java/com/rymcu/vertical/core/service/redis/RedisService.java index ebe522e..7ccb19b 100644 --- a/src/main/java/com/rymcu/vertical/core/service/redis/RedisService.java +++ b/src/main/java/com/rymcu/vertical/core/service/redis/RedisService.java @@ -7,7 +7,7 @@ import java.util.Set; /** * Redis 服务接口 - * Jimersy Lee + * @author Jimersy Lee * 2017-09-18 14:58:21 */ public interface RedisService { diff --git a/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java b/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java index caff003..90ef3af 100644 --- a/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/core/service/redis/impl/RedisServiceImpl.java @@ -3,19 +3,16 @@ package com.rymcu.vertical.core.service.redis.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.fasterxml.jackson.databind.JavaType; -import com.rymcu.vertical.core.service.props.DynProps4FilesService; +import com.rymcu.vertical.config.RedisProperties; import com.rymcu.vertical.core.service.redis.RedisResult; import com.rymcu.vertical.core.service.redis.RedisService; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -34,14 +31,10 @@ public class RedisServiceImpl implements RedisService { private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class); - private static JedisPool pool = null; @Resource - private DynProps4FilesService dynProps4Files; - - @Resource - private Environment env; + private RedisProperties redisProperties; /** @@ -53,25 +46,23 @@ public class RedisServiceImpl implements RedisService { if (pool != null) { return; } - /*JedisPoolConfig config = new JedisPoolConfig(); - config.setMaxIdle(dynProps4Files.getInt("REDIS_MAX_IDLE", JedisPoolConfig.DEFAULT_MAX_IDLE)); - config.setMaxTotal(dynProps4Files.getInt("REDIS_MAX_TOTAL", JedisPoolConfig.DEFAULT_MAX_TOTAL)); - config.setMaxWaitMillis(dynProps4Files.getLong("REDIS_MAX_WAIT", JedisPoolConfig.DEFAULT_MAX_WAIT_MILLIS)); - config.setTestOnBorrow(true); - pool = new JedisPool(config, dynProps4Files.getProperty("REDIS_HOST"), - dynProps4Files.getInt("REDIS_PORT", 6379), dynProps4Files.getInt( - "REDIS_MAX_WAIT", 1000), dynProps4Files.getProperty("REDIS_PASSWORD", null));*/ - - JedisPoolConfig config = new JedisPoolConfig(); - config.setMaxIdle(dynProps4Files.getInt("REDIS_MAX_IDLE", JedisPoolConfig.DEFAULT_MAX_IDLE)); - config.setMaxTotal(dynProps4Files.getInt("REDIS_MAX_TOTAL", JedisPoolConfig.DEFAULT_MAX_TOTAL)); - config.setMaxWaitMillis(dynProps4Files.getLong("REDIS_MAX_WAIT", JedisPoolConfig.DEFAULT_MAX_WAIT_MILLIS)); - config.setTestOnBorrow(true); - pool = new JedisPool(config, env.getProperty("spring.redis.host"), - dynProps4Files.getInt("REDIS_PORT", 6379), dynProps4Files.getInt( - "REDIS_MAX_WAIT", 1000), dynProps4Files.getProperty("REDIS_PASSWORD", env.getProperty("spring.redis.password"))); - + pool = getJedisPool(); + } + private JedisPool getJedisPool() { + if (pool == null) { + synchronized (RedisServiceImpl.class) { + if (pool == null) { + pool = new JedisPool(redisProperties, redisProperties.getHost(), + redisProperties.getPort(), redisProperties.getConnectionTimeout(), + redisProperties.getSoTimeout(), redisProperties.getPassword(), + redisProperties.getDatabase(), redisProperties.getClientName(), + redisProperties.isSsl(), redisProperties.getSslSocketFactory(), + redisProperties.getSslParameters(), redisProperties.getHostnameVerifier()); + } + } + } + return pool; } @Override @@ -106,7 +97,7 @@ public class RedisServiceImpl implements RedisService { if (jedis == null) { return; } - IOUtils.closeQuietly(jedis); + jedis.close(); } /** diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index 60aa8c2..aaa0759 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -51,4 +51,8 @@ public class ArticleDTO { private List tags; private List articleComments; + + private List portfolios; + + private Integer sortNo; } diff --git a/src/main/java/com/rymcu/vertical/dto/Author.java b/src/main/java/com/rymcu/vertical/dto/Author.java index 1f6a567..9b40ee3 100644 --- a/src/main/java/com/rymcu/vertical/dto/Author.java +++ b/src/main/java/com/rymcu/vertical/dto/Author.java @@ -8,12 +8,12 @@ import lombok.Data; @Data public class Author { - private String idUser; + private Integer idUser; private String userNickname; private String userAvatarURL; - private Integer userArticleCount; + private String userArticleCount; } diff --git a/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java new file mode 100644 index 0000000..adb755a --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/PortfolioArticleDTO.java @@ -0,0 +1,23 @@ +package com.rymcu.vertical.dto; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class PortfolioArticleDTO { + + private Integer id; + + private Integer idPortfolio; + + private Integer idArticle; + + private String headImgUrl; + + private String portfolioTitle; + + private Integer sortNo; + +} diff --git a/src/main/java/com/rymcu/vertical/dto/PortfolioDTO.java b/src/main/java/com/rymcu/vertical/dto/PortfolioDTO.java new file mode 100644 index 0000000..2b6b486 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/PortfolioDTO.java @@ -0,0 +1,35 @@ +package com.rymcu.vertical.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author ronger + */ +@Data +public class PortfolioDTO { + + private Integer idPortfolio; + /** 作品集头像 */ + private String headImgUrl; + /** 作品集作者 */ + private Integer portfolioAuthorId; + /** 作品集作者 */ + private String portfolioAuthorName; + /** 作品集作者头像 */ + private String portfolioAuthorAvatarUrl; + /** 作品集名称 */ + private String portfolioTitle; + /** 作品集介绍 */ + private String portfolioDescription; + /** 更新时间 */ + private Date updatedTime; + /** 过去时长 */ + private String timeAgo; + + private Author portfolioAuthor; + + private Integer articleNumber; + +} diff --git a/src/main/java/com/rymcu/vertical/entity/Portfolio.java b/src/main/java/com/rymcu/vertical/entity/Portfolio.java new file mode 100644 index 0000000..3cd2482 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/entity/Portfolio.java @@ -0,0 +1,37 @@ +package com.rymcu.vertical.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +/** + * @author ronger + */ +@Data +@Table(name = "vertical_portfolio") +public class Portfolio { + /** 主键 */ + @Id + @GeneratedValue(generator = "JDBC") + @Column(name = "id") + private Integer idPortfolio; + /** 作品集头像 */ + @Column(name = "portfolio_head_img_url") + private String headImgUrl; + /** 作品集名称 */ + private String portfolioTitle; + /** 作品集作者 */ + private Integer portfolioAuthorId; + /** 作品集介绍 */ + private String portfolioDescription; + /** 作品集介绍 Html */ + private String portfolioDescriptionHtml; + /** 创建时间 */ + private Date createdTime; + /** 更新时间 */ + private Date updatedTime; +} diff --git a/src/main/java/com/rymcu/vertical/entity/SpecialDay.java b/src/main/java/com/rymcu/vertical/entity/SpecialDay.java new file mode 100644 index 0000000..7c8dafb --- /dev/null +++ b/src/main/java/com/rymcu/vertical/entity/SpecialDay.java @@ -0,0 +1,44 @@ +package com.rymcu.vertical.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.util.Date; + +/** + * @author ronger + */ +@Data +@Table(name="vertical_special_day") +public class SpecialDay implements Serializable,Cloneable{ + /** */ + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idSpecialDay; + /** 名称 */ + private String specialDayName; + /** 权重/优先级,小数优秀 */ + private Integer weights; + /** 开始时间 */ + private Date startTime; + /** 过期时间 */ + private Date expirationTime; + /** 是否重复 */ + private Integer repeat; + /** 重复周期 */ + private Integer repeatCycle; + /** 0:天1:周2:月3:年 */ + private Integer repeatCycleUnit; + /** 创建时间 */ + private Date createdTime; + /** 图片路径 */ + private String imgUrl; + /** 执行全局样式 */ + private String cssStyle; + +} diff --git a/src/main/java/com/rymcu/vertical/entity/WxUser.java b/src/main/java/com/rymcu/vertical/entity/WxUser.java new file mode 100644 index 0000000..e9d4103 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/entity/WxUser.java @@ -0,0 +1,49 @@ +package com.rymcu.vertical.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @author ronger + */ +@Data +@Table(name = "vertical_wx_user") +public class WxUser { + + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idWxUser; + + private Boolean subscribe; + + private String openId; + + private String nickname; + + private String sexDesc; + + private Integer sex; + + private String language; + + private String city; + + private String province; + + private String country; + + private String headImgUrl; + + private Long subscribeTime; + + private String unionId; + + private String appId; + + private String actToken; +} diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 959525f..6194cee 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -3,7 +3,7 @@ package com.rymcu.vertical.mapper; import com.rymcu.vertical.core.mapper.Mapper; import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleTagDTO; -import com.rymcu.vertical.dto.Author; +import com.rymcu.vertical.dto.PortfolioArticleDTO; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.ArticleContent; import org.apache.ibatis.annotations.Param; @@ -23,13 +23,6 @@ public interface ArticleMapper extends Mapper
{ */ List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); - /** - * 根据用户 ID 获取作者信息 - * @param id - * @return - */ - Author selectAuthor(@Param("id") Integer id); - /** * 根据文章 ID 查询文章 * @param id @@ -119,4 +112,27 @@ public interface ArticleMapper extends Mapper
{ * @return */ Integer deleteUnusedArticleTag(@Param("idArticleTag") Integer idArticleTag); + + /** + * 查询作品集下文章 + * @param idPortfolio + * @return + */ + List selectArticlesByIdPortfolio(@Param("idPortfolio") Integer idPortfolio); + + /** + * 查询作品集未绑定文章 + * @param idPortfolio + * @param searchText + * @param idUser + * @return + */ + List selectUnbindArticlesByIdPortfolio(@Param("idPortfolio") Integer idPortfolio, @Param("searchText") String searchText, @Param("idUser") Integer idUser); + + /** + * 查询文章所属作品集列表 + * @param idArticle + * @return + */ + List selectPortfolioArticles(@Param("idArticle") Integer idArticle); } diff --git a/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java b/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java new file mode 100644 index 0000000..58f40e2 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/mapper/PortfolioMapper.java @@ -0,0 +1,76 @@ +package com.rymcu.vertical.mapper; + +import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.dto.PortfolioDTO; +import com.rymcu.vertical.entity.Portfolio; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ronger + */ +public interface PortfolioMapper extends Mapper { + /** + * 查询用户作品集 + * @param idUser + * @return + */ + List selectUserPortfoliosByIdUser(@Param("idUser") Integer idUser); + + /** + * 查询作品集 + * @param id + * @param type + * @return + */ + PortfolioDTO selectPortfolioDTOById(@Param("id") Integer id, @Param("type") Integer type); + + /** + * 统计作品集下文章数 + * @param idPortfolio + * @return + */ + Integer selectCountArticleNumber(@Param("idPortfolio") Integer idPortfolio); + + /** + * 查询文章是否已绑定 + * @param idArticle + * @param idPortfolio + * @return + */ + Integer selectCountPortfolioArticle(@Param("idArticle") Integer idArticle, @Param("idPortfolio") Integer idPortfolio); + + /** + * 插入文章与作品集绑定数据 + * @param idArticle + * @param idPortfolio + * @param maxSortNo + * @return + */ + Integer insertPortfolioArticle(@Param("idArticle") Integer idArticle, @Param("idPortfolio") Integer idPortfolio, @Param("maxSortNo") Integer maxSortNo); + + /** + * 查询作品集下最大排序号 + * @param idPortfolio + * @return + */ + Integer selectMaxSortNo(@Param("idPortfolio") Integer idPortfolio); + + /** + * 更新文章排序号 + * @param idPortfolio + * @param idArticle + * @param sortNo + * @return + */ + Integer updateArticleSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle, @Param("sortNo") Integer sortNo); + + /** + * 取消绑定文章 + * @param idPortfolio + * @param idArticle + * @return + */ + Integer unbindArticle(@Param("idPortfolio") Integer idPortfolio, @Param("idArticle") Integer idArticle); +} diff --git a/src/main/java/com/rymcu/vertical/mapper/SpecialDayMapper.java b/src/main/java/com/rymcu/vertical/mapper/SpecialDayMapper.java new file mode 100644 index 0000000..9e9a964 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/mapper/SpecialDayMapper.java @@ -0,0 +1,10 @@ +package com.rymcu.vertical.mapper; + +import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.entity.SpecialDay; + +/** + * @author ronger + */ +public interface SpecialDayMapper extends Mapper { +} diff --git a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java index 6096eab..ce95279 100644 --- a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java @@ -1,6 +1,7 @@ package com.rymcu.vertical.mapper; import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; import com.rymcu.vertical.entity.User; @@ -106,4 +107,10 @@ public interface UserMapper extends Mapper { * @return */ Integer checkNicknameByIdUser(@Param("idUser") Integer idUser, @Param("nickname") String nickname); + /** + * 根据用户 ID 获取作者信息 + * @param id + * @return + */ + Author selectAuthor(@Param("id") Integer id); } \ No newline at end of file diff --git a/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java b/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java new file mode 100644 index 0000000..9e941d3 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/mapper/WxUserMapper.java @@ -0,0 +1,10 @@ +package com.rymcu.vertical.mapper; + +import com.rymcu.vertical.core.mapper.Mapper; +import com.rymcu.vertical.entity.WxUser; + +/** + * @author ronger + */ +public interface WxUserMapper extends Mapper { +} diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index 30325a3..497cdf8 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -78,13 +78,31 @@ public interface ArticleService extends Service
{ /** * 获取分享链接数据 * @param id + * @throws BaseApiException * @return */ Map share(Integer id) throws BaseApiException; /** * 查询草稿文章类别 + * @throws BaseApiException * @return */ List findDrafts() throws BaseApiException; + + /** + * 查询作品集下文章 + * @param idPortfolio + * @return + */ + List findArticlesByIdPortfolio(Integer idPortfolio); + + /** + * 查询作品集下未绑定文章 + * @param idPortfolio + * @param searchText + * @param idUser + * @return + */ + List selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser); } diff --git a/src/main/java/com/rymcu/vertical/service/PortfolioService.java b/src/main/java/com/rymcu/vertical/service/PortfolioService.java new file mode 100644 index 0000000..504b687 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/PortfolioService.java @@ -0,0 +1,80 @@ +package com.rymcu.vertical.service; + +import com.rymcu.vertical.core.service.Service; +import com.rymcu.vertical.dto.PortfolioArticleDTO; +import com.rymcu.vertical.dto.PortfolioDTO; +import com.rymcu.vertical.dto.UserDTO; +import com.rymcu.vertical.entity.Portfolio; +import com.rymcu.vertical.web.api.exception.BaseApiException; + +import java.util.List; +import java.util.Map; + +/** + * @author ronger + */ +public interface PortfolioService extends Service { + + /** + * 查询用户作品集 + * @param userDTO + * @return + */ + List findUserPortfoliosByUser(UserDTO userDTO); + + /** 查询作品集 + * @param idPortfolio + * @param type + * @return + */ + PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type); + + /** + * 保持/更新作品集 + * @param portfolio + * @throws BaseApiException + * @return + */ + Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException; + + /** + * 查询作品集下未绑定文章 + * + * @param page + * @param rows + * @param searchText + * @param idPortfolio + * @throws BaseApiException + * @return + */ + Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException; + + /** + * 绑定文章 + * @param portfolioArticle + * @return + */ + Map bindArticle(PortfolioArticleDTO portfolioArticle); + + /** + * 更新文章排序号 + * @param portfolioArticle + * @return + */ + Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle); + + /** + * 取消绑定文章 + * @param idPortfolio + * @param idArticle + * @return + */ + Map unbindArticle(Integer idPortfolio, Integer idArticle); + + /** + * 删除作品集 + * @param idPortfolio + * @return + */ + Map deletePortfolio(Integer idPortfolio); +} diff --git a/src/main/java/com/rymcu/vertical/service/SpecialDayService.java b/src/main/java/com/rymcu/vertical/service/SpecialDayService.java new file mode 100644 index 0000000..e5a8ff0 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/SpecialDayService.java @@ -0,0 +1,10 @@ +package com.rymcu.vertical.service; + +import com.rymcu.vertical.core.service.Service; +import com.rymcu.vertical.entity.SpecialDay; + +/** + * @author ronger + */ +public interface SpecialDayService extends Service { +} diff --git a/src/main/java/com/rymcu/vertical/service/UserService.java b/src/main/java/com/rymcu/vertical/service/UserService.java index e817abc..f2fb61b 100644 --- a/src/main/java/com/rymcu/vertical/service/UserService.java +++ b/src/main/java/com/rymcu/vertical/service/UserService.java @@ -1,6 +1,7 @@ package com.rymcu.vertical.service; import com.rymcu.vertical.core.service.Service; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; import com.rymcu.vertical.entity.User; @@ -100,4 +101,11 @@ public interface UserService extends Service { * @return */ Integer findRoleWeightsByUser(Integer idUser); + + /** + * 查询作者信息 + * @param idUser + * @return + */ + Author selectAuthor(Integer idUser); } diff --git a/src/main/java/com/rymcu/vertical/service/WxUserService.java b/src/main/java/com/rymcu/vertical/service/WxUserService.java new file mode 100644 index 0000000..59e8527 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/WxUserService.java @@ -0,0 +1,14 @@ +package com.rymcu.vertical.service; + +import com.rymcu.vertical.core.service.Service; +import com.rymcu.vertical.entity.WxUser; +import me.chanjar.weixin.mp.bean.result.WxMpUser; + +/** + * @author ronger + */ +public interface WxUserService extends Service { + + WxUser saveUser(WxMpUser wxMpUser, String appId); + +} diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index 2a077fc..271c40d 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -3,10 +3,7 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.constant.NotificationConstant; import com.rymcu.vertical.core.constant.ProjectConstant; import com.rymcu.vertical.core.service.AbstractService; -import com.rymcu.vertical.dto.ArticleDTO; -import com.rymcu.vertical.dto.ArticleTagDTO; -import com.rymcu.vertical.dto.Author; -import com.rymcu.vertical.dto.CommentDTO; +import com.rymcu.vertical.dto.*; import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.ArticleContent; import com.rymcu.vertical.entity.Tag; @@ -149,14 +146,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti } newArticle.setArticleTitle(articleTitle); newArticle.setArticleTags(articleTags); - if(StringUtils.isNotBlank(articleContentHtml)){ - Integer length = articleContentHtml.length(); - if(length > MAX_PREVIEW){ - length = 200; - } - String articlePreviewContent = articleContentHtml.substring(0,length); - newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); - } newArticle.setArticleStatus(article.getArticleStatus()); newArticle.setUpdatedTime(new Date()); articleMapper.updateArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); @@ -178,6 +167,15 @@ public class ArticleServiceImpl extends AbstractService
implements Arti newArticle.setArticlePermalink(domain + "/draft/" + newArticle.getIdArticle()); newArticle.setArticleLink("/draft/" + newArticle.getIdArticle()); } + + if(StringUtils.isNotBlank(articleContentHtml)){ + Integer length = articleContentHtml.length(); + if(length > MAX_PREVIEW){ + length = MAX_PREVIEW; + } + String articlePreviewContent = articleContentHtml.substring(0,length); + newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); + } articleMapper.updateByPrimaryKeySelective(newArticle); map.put("id", newArticle.getIdArticle()); @@ -263,29 +261,55 @@ public class ArticleServiceImpl extends AbstractService
implements Arti return list; } + @Override + public List findArticlesByIdPortfolio(Integer idPortfolio) { + List list = articleMapper.selectArticlesByIdPortfolio(idPortfolio); + list.forEach(article->{ + genArticle(article,0); + }); + return list; + } + + @Override + public List selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser) { + List list = articleMapper.selectUnbindArticlesByIdPortfolio(idPortfolio,searchText,idUser); + list.forEach(article->{ + genArticle(article,0); + }); + return list; + } + private ArticleDTO genArticle(ArticleDTO article, Integer type) { - Author author = articleMapper.selectAuthor(article.getArticleAuthorId()); + Integer ARTICLE_LIST = 0; + Integer ARTICLE_VIEW = 1; + Integer ARTICLE_EDIT = 2; + Author author = genAuthor(article); article.setArticleAuthor(author); article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime())); List tags = articleMapper.selectTags(article.getIdArticle()); article.setTags(tags); - ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); - if (type == 1){ - article.setArticleContent(articleContent.getArticleContentHtml()); - } else if (type == 2) { - article.setArticleContent(articleContent.getArticleContent()); - } - - if(StringUtils.isBlank(article.getArticlePreviewContent())){ - Integer length = articleContent.getArticleContentHtml().length(); - if(length > MAX_PREVIEW){ - length = 200; + if (!type.equals(ARTICLE_LIST)) { + ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); + if (type.equals(ARTICLE_VIEW)){ + article.setArticleContent(articleContent.getArticleContentHtml()); + // 获取评论列表数据 + List commentDTOList = commentService.getArticleComments(article.getIdArticle()); + article.setArticleComments(commentDTOList); + // 获取所属作品集列表数据 + List portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); + article.setPortfolios(portfolioArticleDTOList); + } else if (type.equals(ARTICLE_EDIT)) { + article.setArticleContent(articleContent.getArticleContent()); } - String articlePreviewContent = articleContent.getArticleContentHtml().substring(0,length); - article.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); } - List commentDTOList = commentService.getArticleComments(article.getIdArticle()); - article.setArticleComments(commentDTOList); return article; } + + private Author genAuthor(ArticleDTO article) { + Author author = new Author(); + author.setUserNickname(article.getArticleAuthorName()); + author.setUserAvatarURL(article.getArticleAuthorAvatarUrl()); + author.setIdUser(article.getArticleAuthorId()); + return author; + } } diff --git a/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java new file mode 100644 index 0000000..d5814bc --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/impl/PortfolioServiceImpl.java @@ -0,0 +1,178 @@ +package com.rymcu.vertical.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.rymcu.vertical.core.service.AbstractService; +import com.rymcu.vertical.dto.*; +import com.rymcu.vertical.entity.Portfolio; +import com.rymcu.vertical.entity.User; +import com.rymcu.vertical.mapper.PortfolioMapper; +import com.rymcu.vertical.service.ArticleService; +import com.rymcu.vertical.service.PortfolioService; +import com.rymcu.vertical.service.UserService; +import com.rymcu.vertical.util.UserUtils; +import com.rymcu.vertical.util.Utils; +import com.rymcu.vertical.web.api.exception.BaseApiException; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author ronger + */ +@Service +public class PortfolioServiceImpl extends AbstractService implements PortfolioService { + + @Resource + private PortfolioMapper portfolioMapper; + @Resource + private UserService userService; + @Resource + private ArticleService articleService; + + @Override + public List findUserPortfoliosByUser(UserDTO userDTO) { + List list = portfolioMapper.selectUserPortfoliosByIdUser(userDTO.getIdUser()); + Author author = new Author(); + author.setIdUser(userDTO.getIdUser()); + author.setUserAvatarURL(userDTO.getAvatarUrl()); + author.setUserNickname(userDTO.getNickname()); + list.forEach(portfolioDTO -> { + genPortfolioAuthor(portfolioDTO,author); + }); + return list; + } + + @Override + public PortfolioDTO findPortfolioDTOById(Integer idPortfolio, Integer type) { + PortfolioDTO portfolio = portfolioMapper.selectPortfolioDTOById(idPortfolio,type); + if (portfolio == null) { + return new PortfolioDTO(); + } + Author author = userService.selectAuthor(portfolio.getPortfolioAuthorId()); + genPortfolioAuthor(portfolio,author); + Integer articleNumber = portfolioMapper.selectCountArticleNumber(portfolio.getIdPortfolio()); + portfolio.setArticleNumber(articleNumber); + return portfolio; + } + + @Override + public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException { + User user = UserUtils.getWxCurrentUser(); + if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) { + portfolio.setPortfolioAuthorId(user.getIdUser()); + portfolio.setCreatedTime(new Date()); + portfolio.setUpdatedTime(portfolio.getCreatedTime()); + portfolioMapper.insertSelective(portfolio); + } else { + portfolio.setUpdatedTime(new Date()); + portfolioMapper.updateByPrimaryKeySelective(portfolio); + } + return portfolio; + } + + @Override + public Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException { + Map map = new HashMap(1); + User user = UserUtils.getWxCurrentUser(); + Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio); + if (portfolio == null) { + map.put("message", "该作品集不存在或已被删除!"); + } else { + if (!user.getIdUser().equals(portfolio.getPortfolioAuthorId())) { + map.put("message", "非法操作!"); + } else { + PageHelper.startPage(page, rows); + List articles = articleService.selectUnbindArticles(idPortfolio,searchText,user.getIdUser()); + PageInfo pageInfo = new PageInfo(articles); + map = Utils.getArticlesGlobalResult(pageInfo); + } + } + return map; + } + + @Override + public Map bindArticle(PortfolioArticleDTO portfolioArticle) { + Map map = new HashMap(1); + Integer count = portfolioMapper.selectCountPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio()); + if (count.equals(0)) { + Integer maxSortNo = portfolioMapper.selectMaxSortNo(portfolioArticle.getIdPortfolio()); + portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(),portfolioArticle.getIdPortfolio(),maxSortNo); + map.put("message", "绑定成功!"); + } else { + map.put("message", "该文章已经在作品集下!!"); + } + return map; + } + + @Override + public Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle) { + Map map = new HashMap(1); + if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio().equals(0)) { + map.put("message", "作品集数据异常!"); + } + if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle().equals(0)) { + map.put("message", "文章数据异常!"); + } + if (portfolioArticle.getSortNo() == null) { + map.put("message", "排序号不能为空!"); + } + Integer result = portfolioMapper.updateArticleSortNo(portfolioArticle.getIdPortfolio(),portfolioArticle.getIdArticle(),portfolioArticle.getSortNo()); + if (result > 0) { + map.put("message", "更新成功!"); + } else { + map.put("message", "更新失败!"); + } + return map; + } + + @Override + public Map unbindArticle(Integer idPortfolio, Integer idArticle) { + Map map = new HashMap(1); + if (idPortfolio == null || idPortfolio.equals(0)) { + map.put("message", "作品集数据异常"); + } + if (idArticle == null || idArticle.equals(0)) { + map.put("message", "文章数据异常"); + } + Integer result = portfolioMapper.unbindArticle(idPortfolio,idArticle); + if (result > 0) { + map.put("message", "操作成功!"); + } else { + map.put("message", "操作失败!"); + } + return map; + } + + @Override + public Map deletePortfolio(Integer idPortfolio) { + Map map = new HashMap(1); + if (idPortfolio == null || idPortfolio.equals(0)) { + map.put("message", "作品集数据异常"); + } + + Integer articleNumber = portfolioMapper.selectCountArticleNumber(idPortfolio); + if (articleNumber > 0) { + map.put("message", "该作品集已绑定文章不允许删除!"); + } else { + Integer result = portfolioMapper.deleteByPrimaryKey(idPortfolio); + if (result.equals(0)) { + map.put("message", "操作失败!"); + } + } + + return map; + } + + private PortfolioDTO genPortfolioAuthor(PortfolioDTO portfolioDTO, Author author) { + portfolioDTO.setPortfolioAuthorAvatarUrl(author.getUserAvatarURL()); + portfolioDTO.setPortfolioAuthorName(author.getUserNickname()); + portfolioDTO.setPortfolioAuthorId(author.getIdUser()); + portfolioDTO.setPortfolioAuthor(author); + return portfolioDTO; + } +} diff --git a/src/main/java/com/rymcu/vertical/service/impl/SpecialDayServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/SpecialDayServiceImpl.java new file mode 100644 index 0000000..b959b36 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/impl/SpecialDayServiceImpl.java @@ -0,0 +1,20 @@ +package com.rymcu.vertical.service.impl; + +import com.rymcu.vertical.core.service.AbstractService; +import com.rymcu.vertical.entity.SpecialDay; +import com.rymcu.vertical.mapper.SpecialDayMapper; +import com.rymcu.vertical.service.SpecialDayService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author ronger + */ +@Service +public class SpecialDayServiceImpl extends AbstractService implements SpecialDayService { + + @Resource + private SpecialDayMapper specialDayMapper; + +} diff --git a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java index 16b25fd..72be192 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java @@ -1,7 +1,6 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.service.AbstractService; -import com.rymcu.vertical.core.service.redis.RedisService; import com.rymcu.vertical.dto.ArticleTagDTO; import com.rymcu.vertical.dto.LabelModel; import com.rymcu.vertical.entity.Article; @@ -36,8 +35,6 @@ public class TagServiceImpl extends AbstractService implements TagService { private TagMapper tagMapper; @Resource private ArticleMapper articleMapper; - @Resource - private RedisService redisService; @Override @Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class }) @@ -107,7 +104,7 @@ public class TagServiceImpl extends AbstractService implements TagService { @Override @Transactional(rollbackFor = Exception.class) public Map saveTag(Tag tag) { - Integer result = 0; + Integer result; Map map = new HashMap(1); if (tag.getIdTag() == null) { diff --git a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java index 8180eb5..dc8ef02 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java @@ -2,6 +2,7 @@ package com.rymcu.vertical.service.impl; import com.rymcu.vertical.core.service.AbstractService; import com.rymcu.vertical.core.service.redis.RedisService; +import com.rymcu.vertical.dto.Author; import com.rymcu.vertical.dto.TokenUser; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserInfoDTO; @@ -207,4 +208,9 @@ public class UserServiceImpl extends AbstractService implements UserServic public Integer findRoleWeightsByUser(Integer idUser) { return userMapper.selectRoleWeightsByUser(idUser); } + + @Override + public Author selectAuthor(Integer idUser) { + return userMapper.selectAuthor(idUser); + } } diff --git a/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java new file mode 100644 index 0000000..3309f0d --- /dev/null +++ b/src/main/java/com/rymcu/vertical/service/impl/WxUserServiceImpl.java @@ -0,0 +1,62 @@ +package com.rymcu.vertical.service.impl; + +import com.rymcu.vertical.core.service.AbstractService; +import com.rymcu.vertical.entity.WxUser; +import com.rymcu.vertical.mapper.WxUserMapper; +import com.rymcu.vertical.service.WxUserService; +import me.chanjar.weixin.mp.bean.result.WxMpUser; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author ronger + */ +@Service +public class WxUserServiceImpl extends AbstractService implements WxUserService { + + @Resource + private WxUserMapper wxUserMapper; + + @Override + public WxUser saveUser(WxMpUser wxMpUser, String appId) { + WxUser searchWxUser = new WxUser(); + if (StringUtils.isBlank(wxMpUser.getUnionId())) { + searchWxUser.setUnionId(wxMpUser.getUnionId()); + } else { + searchWxUser.setAppId(appId); + searchWxUser.setOpenId(searchWxUser.getOpenId()); + } + List wxUsers = wxUserMapper.select(searchWxUser); + WxUser wxUser; + if (wxUsers.isEmpty()) { + wxUser = new WxUser(); + wxUser.setAppId(appId); + wxUser = copyWxUser(wxMpUser,wxUser); + wxUserMapper.insertSelective(wxUser); + } else { + wxUser = wxUsers.get(0); + wxUser = copyWxUser(wxMpUser,wxUser); + wxUserMapper.updateByPrimaryKeySelective(wxUser); + } + return wxUser; + } + + private WxUser copyWxUser(WxMpUser wxMpUser, WxUser wxUser) { + wxUser.setNickname(wxMpUser.getNickname()); + wxUser.setHeadImgUrl(wxMpUser.getHeadImgUrl()); + wxUser.setCountry(wxMpUser.getCountry()); + wxUser.setProvince(wxMpUser.getProvince()); + wxUser.setCity(wxMpUser.getCity()); + wxUser.setSex(wxMpUser.getSex()); + wxUser.setSubscribe(wxMpUser.getSubscribe()); + wxUser.setSubscribeTime(wxMpUser.getSubscribeTime()); + wxUser.setUnionId(wxMpUser.getUnionId()); + wxUser.setOpenId(wxMpUser.getOpenId()); + wxUser.setLanguage(wxMpUser.getLanguage()); + wxUser.setSexDesc(wxMpUser.getSexDesc()); + return wxUser; + } +} diff --git a/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java b/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java index 2249a76..643dc9b 100644 --- a/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/vertical/web/api/admin/AdminController.java @@ -6,14 +6,8 @@ import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.dto.admin.TopicTagDTO; import com.rymcu.vertical.dto.admin.UserRoleDTO; -import com.rymcu.vertical.entity.Role; -import com.rymcu.vertical.entity.Tag; -import com.rymcu.vertical.entity.Topic; -import com.rymcu.vertical.entity.User; -import com.rymcu.vertical.service.RoleService; -import com.rymcu.vertical.service.TagService; -import com.rymcu.vertical.service.TopicService; -import com.rymcu.vertical.service.UserService; +import com.rymcu.vertical.entity.*; +import com.rymcu.vertical.service.*; import com.rymcu.vertical.util.Utils; import org.apache.commons.lang.StringUtils; import org.springframework.web.bind.annotation.*; @@ -39,6 +33,8 @@ public class AdminController { private TopicService topicService; @Resource private TagService tagService; + @Resource + private SpecialDayService specialDayService; @GetMapping("/users") public GlobalResult> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ @@ -47,10 +43,7 @@ public class AdminController { PageInfo pageInfo = new PageInfo<>(list); Map map = new HashMap(2); map.put("users", pageInfo.getList()); - Map pagination = new HashMap<>(3); - pagination.put("pageSize",pageInfo.getPageSize()); - pagination.put("total",pageInfo.getTotal()); - pagination.put("currentPage",pageInfo.getPageNum()); + Map pagination = Utils.getPagination(pageInfo); map.put("pagination", pagination); return GlobalResultGenerator.genSuccessResult(map); } @@ -204,4 +197,16 @@ public class AdminController { return GlobalResultGenerator.genSuccessResult(map); } + @GetMapping("/special-days") + public GlobalResult specialDays(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = specialDayService.findAll(); + PageInfo pageInfo = new PageInfo<>(list); + Map map = new HashMap<>(2); + map.put("specialDays", pageInfo.getList()); + Map pagination = Utils.getPagination(pageInfo); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + } diff --git a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java index b26ea25..722b5bc 100644 --- a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java @@ -6,13 +6,11 @@ import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.core.result.GlobalResultMessage; import com.rymcu.vertical.core.service.log.annotation.VisitLogger; -import com.rymcu.vertical.dto.ArticleDTO; -import com.rymcu.vertical.dto.ForgetPasswordDTO; -import com.rymcu.vertical.dto.TokenUser; -import com.rymcu.vertical.dto.UserRegisterInfoDTO; +import com.rymcu.vertical.dto.*; import com.rymcu.vertical.entity.User; import com.rymcu.vertical.service.ArticleService; import com.rymcu.vertical.service.JavaMailService; +import com.rymcu.vertical.service.PortfolioService; import com.rymcu.vertical.service.UserService; import com.rymcu.vertical.util.UserUtils; import com.rymcu.vertical.util.Utils; @@ -38,6 +36,8 @@ public class CommonApiController { private UserService userService; @Resource private ArticleService articleService; + @Resource + private PortfolioService portfolioService; @ApiOperation(value = "获取邮件验证码") @GetMapping("/get-email-code") @@ -120,4 +120,22 @@ public class CommonApiController { Map map = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword()); return GlobalResultGenerator.genSuccessResult(map); } + + @GetMapping("/portfolio/{id}") + @VisitLogger + public GlobalResult> portfolio(@PathVariable Integer id){ + PortfolioDTO portfolioDTO = portfolioService.findPortfolioDTOById(id,1); + Map map = new HashMap<>(1); + map.put("portfolio", portfolioDTO); + return GlobalResultGenerator.genSuccessResult(map); + } + + @GetMapping("/portfolio/{id}/articles") + public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Integer id) { + PageHelper.startPage(page, rows); + List list = articleService.findArticlesByIdPortfolio(id); + PageInfo pageInfo = new PageInfo(list); + Map map = Utils.getArticlesGlobalResult(pageInfo); + return GlobalResultGenerator.genSuccessResult(map); + } } diff --git a/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java b/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java new file mode 100644 index 0000000..4a4b0a2 --- /dev/null +++ b/src/main/java/com/rymcu/vertical/web/api/portfolio/PortfolioController.java @@ -0,0 +1,76 @@ +package com.rymcu.vertical.web.api.portfolio; + +import com.rymcu.vertical.core.result.GlobalResult; +import com.rymcu.vertical.core.result.GlobalResultGenerator; +import com.rymcu.vertical.dto.PortfolioArticleDTO; +import com.rymcu.vertical.dto.PortfolioDTO; +import com.rymcu.vertical.entity.Portfolio; +import com.rymcu.vertical.service.PortfolioService; +import com.rymcu.vertical.web.api.exception.BaseApiException; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/portfolio") +public class PortfolioController { + + @Resource + private PortfolioService portfolioService; + + @GetMapping("/detail/{id}") + public GlobalResult detail(@PathVariable Integer id,@RequestParam(defaultValue = "0") Integer type) { + PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(id, type); + Map map = new HashMap<>(1); + map.put("portfolio", portfolio); + return GlobalResultGenerator.genSuccessResult(map); + } + + @PostMapping("/post") + public GlobalResult add(@RequestBody Portfolio portfolio) throws BaseApiException { + portfolio = portfolioService.postPortfolio(portfolio); + return GlobalResultGenerator.genSuccessResult(portfolio); + } + + @PutMapping("/post") + public GlobalResult update(@RequestBody Portfolio portfolio) throws BaseApiException { + portfolio = portfolioService.postPortfolio(portfolio); + return GlobalResultGenerator.genSuccessResult(portfolio); + } + + @GetMapping("/{id}/unbind-articles") + public GlobalResult unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText,@PathVariable Integer id) throws BaseApiException { + Map map = portfolioService.findUnbindArticles(page, rows, searchText, id); + return GlobalResultGenerator.genSuccessResult(map); + } + + @PostMapping("/bind-article") + public GlobalResult bindArticle(@RequestBody PortfolioArticleDTO portfolioArticle) { + Map map = portfolioService.bindArticle(portfolioArticle); + return GlobalResultGenerator.genSuccessResult(map); + } + + @PutMapping("/update-article-sort-no") + public GlobalResult updateArticleSortNo(@RequestBody PortfolioArticleDTO portfolioArticle) { + Map map = portfolioService.updateArticleSortNo(portfolioArticle); + return GlobalResultGenerator.genSuccessResult(map); + } + + @DeleteMapping("/unbind-article") + public GlobalResult unbindArticle(Integer idArticle,Integer idPortfolio) { + Map map = portfolioService.unbindArticle(idPortfolio,idArticle); + return GlobalResultGenerator.genSuccessResult(map); + } + + @DeleteMapping("/delete") + public GlobalResult delete(Integer idPortfolio){ + Map map = portfolioService.deletePortfolio(idPortfolio); + return GlobalResultGenerator.genSuccessResult(map); + } + +} diff --git a/src/main/java/com/rymcu/vertical/web/api/user/UserController.java b/src/main/java/com/rymcu/vertical/web/api/user/UserController.java index 206578f..10f218c 100644 --- a/src/main/java/com/rymcu/vertical/web/api/user/UserController.java +++ b/src/main/java/com/rymcu/vertical/web/api/user/UserController.java @@ -5,13 +5,16 @@ import com.github.pagehelper.PageInfo; import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.dto.ArticleDTO; +import com.rymcu.vertical.dto.PortfolioDTO; import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.service.ArticleService; +import com.rymcu.vertical.service.PortfolioService; import com.rymcu.vertical.service.UserService; import com.rymcu.vertical.util.Utils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -26,6 +29,8 @@ public class UserController { private UserService userService; @Resource private ArticleService articleService; + @Resource + private PortfolioService portfolioService; @GetMapping("/{nickname}") public GlobalResult detail(@PathVariable String nickname){ @@ -46,4 +51,20 @@ public class UserController { return GlobalResultGenerator.genSuccessResult(map); } + @GetMapping("/{nickname}/portfolios") + public GlobalResult userPortfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){ + UserDTO userDTO = userService.findUserDTOByNickname(nickname); + if (userDTO == null){ + return GlobalResultGenerator.genErrorResult("用户不存在!"); + } + PageHelper.startPage(page, rows); + List list = portfolioService.findUserPortfoliosByUser(userDTO); + PageInfo pageInfo = new PageInfo(list); + Map map = new HashMap(2); + map.put("portfolios", list); + Map pagination = Utils.getPagination(pageInfo); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + } diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index f294d88..3aac306 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -37,11 +37,7 @@ - - - - - + @@ -59,6 +55,12 @@ + + + + + + insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time) values (#{idArticle},#{articleContent},#{articleContentHtml},sysdate(),sysdate()) @@ -76,13 +78,10 @@ delete from vertical_tag_article where id = #{idArticleTag} - + + + \ No newline at end of file diff --git a/src/main/java/mapper/PortfolioMapper.xml b/src/main/java/mapper/PortfolioMapper.xml new file mode 100644 index 0000000..c7f93a4 --- /dev/null +++ b/src/main/java/mapper/PortfolioMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + insert into vertical_portfolio_article (id_vertical_portfolio, id_vertical_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo}) + + + update vertical_portfolio_article set sort_no = #{sortNo} where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle} + + + delete from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle} + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/SpecialDayMapper.xml b/src/main/java/mapper/SpecialDayMapper.xml new file mode 100644 index 0000000..d4977b7 --- /dev/null +++ b/src/main/java/mapper/SpecialDayMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/UserMapper.xml b/src/main/java/mapper/UserMapper.xml index 398908e..f134db4 100644 --- a/src/main/java/mapper/UserMapper.xml +++ b/src/main/java/mapper/UserMapper.xml @@ -41,6 +41,11 @@ + + + + + insert into vertical_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate()) @@ -82,5 +87,8 @@ + \ No newline at end of file diff --git a/src/main/java/mapper/WxUserMapper.xml b/src/main/java/mapper/WxUserMapper.xml new file mode 100644 index 0000000..228a592 --- /dev/null +++ b/src/main/java/mapper/WxUserMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a6281ae..d4a3203 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: # profiles: -# active: pord +# active: dev thymeleaf: prefix: classpath:/templates/ suffix: .html @@ -12,7 +12,7 @@ spring: redis: host: 127.0.0.1 port: 6379 - password: # redis 密码 + password: d9d2j9w2 database: 1 timeout: 3000 jedis: @@ -22,31 +22,86 @@ spring: max-idle: 500 min-idle: 0 datasource: - url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false + url: jdbc:mysql://101.132.182.12:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false username: root - password: # 数据库密码 + password: d9d2j9w2.RYMCU driver-class-name: com.mysql.cj.jdbc.Driver + max-wait: 60000 + min-idle: 20 + initial-size: 10 + max-active: 50 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + time-between-eviction-runs-millis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + min-evictable-idle-time-millis: 30000 + validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + log-slow-sql: true + filters: config,stat,wall,log4j + max-pool-prepared-statement-per-connection-size: 100 + stat-view-servlet: + enabled: true + pool-prepared-statements: true resources: add-mappings: true mail: - host: smtp.163.com + host: smtp.ym.163.com port: 465 - username: # 邮箱 - password: # 密码 -env: dev + username: service@rymcu.com + password: Aa12345678 + servlet: + multipart: + max-file-size: 10MB + max-request-size: 20MB +wx: + open: + componentAppId: wx9c4a7dfb3238d5f6 + componentSecret: e32a6f75ab6b746ec3ae38a39a79ba22 + componentToken: rymcu + componentAesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E + mp: + configs: + - appId: wxf085386aa07c0857 + secret: aabd075d2851764714fd14a0d0b1b8b4 + token: rymcu + aesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E + - appId: wxa49093339a5a822b + secret: 29e9390e6d58d57a2b2a2350dbee8754 + token: qwert + aesKey: + miniapp: + configs: + - appid: wxf57df4f171606a26 + secret: 574ff86cb48a42f3980b221e942c53b1 + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON +env: pord logging: file: path: /logs/vertical + level: + com: + rymcu: + vertical: + wx: debug + web: debug server: port: 8099 servlet: context-path: /vertical + compression: + enabled: true + mime-types: application/json,application/xml,text/html,text/xml,text/plain + min-response-size: 1024 + max-http-header-size: 1024 version: 1.0 resource: - file-path: https://abc.com/vertical + domain: https://rymcu.com + file-path: https://rymcu.com/vertical baidu: data: - site: https://abc.com # 百度搜索资源配置网址 - token: xxxx # 百度搜索资源token -reserved-words: \u7cfb\u7edf\u516c\u544a\u002c\u516c\u544a - + site: https://www.rymcu.com + token: 9cdKR6bVCJzxDEJS \ No newline at end of file diff --git a/src/main/resources/static/vertical.pdman.json b/src/main/resources/static/vertical.pdman.json index d88e481..fb36b1b 100644 --- a/src/main/resources/static/vertical.pdman.json +++ b/src/main/resources/static/vertical.pdman.json @@ -1592,6 +1592,504 @@ } ], "chnname": "浏览表" + }, + { + "title": "vertical_special_day-副本", + "chnname": "特殊日", + "fields": [ + { + "name": "id", + "type": "INT_10", + "chnname": "", + "remark": "", + "pk": true, + "notNull": true, + "autoIncrement": true, + "defaultValue": "" + }, + { + "name": "special_day_name", + "type": "VARCHAR_200", + "chnname": "名称", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "weights", + "type": "INT_10", + "chnname": "权重/优先级,小数优秀", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "start_time", + "type": "DATETIME", + "chnname": "开始时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "expiration_time", + "type": "DATETIME", + "chnname": "过期时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat", + "type": "INT_10", + "chnname": "是否重复", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat_cycle", + "type": "INT_10", + "chnname": "重复周期", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat_cycle_unit", + "type": "INT_10", + "chnname": "0:天1:周2:月3:年", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "created_time", + "type": "DATETIME", + "chnname": "创建时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "img_url", + "type": "VARCHAR_500", + "chnname": "图片路径", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "css_style", + "type": "VARCHAR_2000", + "chnname": "执行全局样式", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ] + }, + { + "title": "vertical_wx_user-副本", + "chnname": "微信用户表", + "fields": [ + { + "name": "id", + "type": "INT_10", + "chnname": "微信用户表主键", + "remark": "", + "pk": true, + "notNull": true, + "autoIncrement": true, + "defaultValue": "" + }, + { + "name": "nickname", + "type": "VARCHAR_50", + "chnname": "", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "union_id", + "type": "VARCHAR_32", + "chnname": "微信全局 unionId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "open_id", + "type": "VARCHAR_32", + "chnname": "openId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "app_id", + "type": "VARCHAR_32", + "chnname": "AppId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "sex", + "type": "INT_10", + "chnname": "性别字段", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "sex_desc", + "type": "VARCHAR_32", + "chnname": "性别文本", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "head_img_url", + "type": "VARCHAR_200", + "chnname": "头像图片路径", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "country", + "type": "VARCHAR_32", + "chnname": "所属国家", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "province", + "type": "VARCHAR_32", + "chnname": "所属省/州", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "city", + "type": "VARCHAR_32", + "chnname": "所属市/区", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "act_token", + "type": "VARCHAR_64", + "chnname": "活动 Token", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "subscribe", + "type": "BIT_1", + "chnname": "是否关注", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "subscribe_time", + "type": "MEDIUMTEXT", + "chnname": "关注时间戳", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "language", + "type": "VARCHAR_10", + "chnname": "语言", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ] + }, + { + "title": "vertical_collection", + "fields": [ + { + "name": "id", + "type": "BigInt", + "remark": "", + "chnname": "主键", + "pk": true, + "notNull": true, + "autoIncrement": true + }, + { + "name": "head_img_url", + "type": "VARCHAR_500", + "remark": "", + "chnname": "作品集头像" + }, + { + "name": "name", + "type": "DefaultString", + "remark": "", + "chnname": "作品集名称" + }, + { + "name": "portfolio_author_id", + "type": "BigInt", + "remark": "", + "chnname": "作品集作者" + }, + { + "name": "description", + "type": "MiddleString", + "remark": "", + "chnname": "作品集介绍" + }, + { + "name": "created_time", + "type": "DateTime", + "remark": "", + "chnname": "创建时间" + }, + { + "name": "updated_time", + "type": "DateTime", + "remark": "", + "chnname": "更新时间" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ], + "chnname": "作品集", + "remark": "作品集" + }, + { + "title": "vertical_collection_article", + "fields": [ + { + "name": "id", + "type": "BigInt", + "remark": "", + "chnname": "主键", + "pk": true, + "notNull": true, + "autoIncrement": true + }, + { + "name": "id_vertical_portfolio", + "type": "BigInt", + "remark": "", + "chnname": "作品集表主键" + }, + { + "name": "id_vertical_article", + "type": "BigInt", + "remark": "", + "chnname": "文章表主键" + }, + { + "name": "sort_no", + "type": "Integer", + "remark": "", + "chnname": "排序号" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ], + "chnname": "作品集与文章关系表" } ], "graphCanvas": { @@ -1982,6 +2480,336 @@ } } ] + }, + { + "name": "DB_REVERSE_MYSQL", + "chnname": "逆向解析_MYSQL", + "entities": [ + { + "title": "vertical_special_day", + "chnname": "特殊日", + "fields": [ + { + "name": "id", + "type": "BigInt", + "chnname": "", + "remark": "", + "pk": true, + "notNull": true, + "autoIncrement": true, + "defaultValue": "" + }, + { + "name": "special_day_name", + "type": "VARCHAR_200", + "chnname": "名称", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "weights", + "type": "Integer", + "chnname": "权重/优先级,小数优秀", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "start_time", + "type": "DATETIME", + "chnname": "开始时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "expiration_time", + "type": "DATETIME", + "chnname": "过期时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat", + "type": "Integer", + "chnname": "是否重复", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat_cycle", + "type": "Integer", + "chnname": "重复周期", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "repeat_cycle_unit", + "type": "Integer", + "chnname": "0:天1:周2:月3:年", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "created_time", + "type": "DATETIME", + "chnname": "创建时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "img_url", + "type": "VARCHAR_500", + "chnname": "图片路径", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "css_style", + "type": "VARCHAR_2000", + "chnname": "执行全局样式", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ] + }, + { + "title": "vertical_wx_user", + "chnname": "微信用户表", + "fields": [ + { + "name": "id", + "type": "INT_10", + "chnname": "微信用户表主键", + "remark": "", + "pk": true, + "notNull": true, + "autoIncrement": true, + "defaultValue": "" + }, + { + "name": "nickname", + "type": "VARCHAR_50", + "chnname": "", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "union_id", + "type": "VARCHAR_32", + "chnname": "微信全局 unionId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "open_id", + "type": "VARCHAR_32", + "chnname": "openId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "app_id", + "type": "VARCHAR_32", + "chnname": "AppId", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "sex", + "type": "INT_10", + "chnname": "性别字段", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "sex_desc", + "type": "VARCHAR_32", + "chnname": "性别文本", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "head_img_url", + "type": "VARCHAR_200", + "chnname": "头像图片路径", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "country", + "type": "VARCHAR_32", + "chnname": "所属国家", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "province", + "type": "VARCHAR_32", + "chnname": "所属省/州", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "city", + "type": "VARCHAR_32", + "chnname": "所属市/区", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "act_token", + "type": "VARCHAR_64", + "chnname": "活动 Token", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "subscribe", + "type": "BIT_1", + "chnname": "是否关注", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "subscribe_time", + "type": "MEDIUMTEXT", + "chnname": "关注时间戳", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "language", + "type": "VARCHAR_10", + "chnname": "语言", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ] + } + ], + "graphCanvas": { + "nodes": [], + "edges": [] + }, + "associations": [] } ], "dataTypeDomains": { @@ -2501,6 +3329,78 @@ "type": "VARCHAR(64)" } } + }, + { + "name": "BIT_1", + "code": "BIT_1", + "apply": { + "MYSQL": { + "type": "BIT(1)" + } + } + }, + { + "name": "DATE", + "code": "DATE", + "apply": { + "MYSQL": { + "type": "DATE" + } + } + }, + { + "name": "MEDIUMTEXT", + "code": "MEDIUMTEXT", + "apply": { + "MYSQL": { + "type": "MEDIUMTEXT" + } + } + }, + { + "name": "VARCHAR_10", + "code": "VARCHAR_10", + "apply": { + "MYSQL": { + "type": "VARCHAR(10)" + } + } + }, + { + "name": "VARCHAR_200", + "code": "VARCHAR_200", + "apply": { + "MYSQL": { + "type": "VARCHAR(200)" + } + } + }, + { + "name": "VARCHAR_2000", + "code": "VARCHAR_2000", + "apply": { + "MYSQL": { + "type": "VARCHAR(2000)" + } + } + }, + { + "name": "VARCHAR_50", + "code": "VARCHAR_50", + "apply": { + "MYSQL": { + "type": "VARCHAR(50)" + } + } + }, + { + "name": "VARCHAR_500", + "code": "VARCHAR_500", + "apply": { + "MYSQL": { + "type": "VARCHAR(500)" + } + } } ], "database": [ @@ -2609,18 +3509,30 @@ } ], "defaultFieldsType": "1", - "javaConfig": {}, + "javaConfig": { + "JAVA_HOME": "C:\\Program Files\\Java\\jdk1.8.0_111" + }, "sqlConfig": "", "dbs": [ { "name": "rymcu", - "defaultDB": true, + "defaultDB": false, "properties": { "driver_class_name": "com.mysql.jdbc.Driver", "url": "jdbc:mysql://101.132.182.12:3306/vertical?characterEncoding=UTF-8&useSSL=false&useUnicode=true&serverTimezone=UTC", "password": "d9d2j9w2.RYMCU", "username": "root" } + }, + { + "name": "test_rymcu", + "defaultDB": true, + "properties": { + "driver_class_name": "com.mysql.jdbc.Driver", + "url": "jdbc:mysql://120.26.175.127:3306/vertical?characterEncoding=UTF-8&useSSL=false&useUnicode=true&serverTimezone=UTC", + "password": "rymcu.Test4", + "username": "root" + } } ], "wordTemplateConfig": ""