From 930f47e1bd5f07a794a16d0ea48ee229d84bd7a6 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期五, 23 五月 2025 10:08:22 +0800 Subject: [PATCH] 新增定时任务模块 --- lmk-job/src/main/java/cn/lili/LmkJobApplication.java | 33 +++ lmk-job/src/main/resources/logback-spring.xml | 58 +++++ lmk-job/pom.xml | 33 +++ framework/src/main/resources/mapper/lmk/MyCollectMapper.xml | 12 + framework/src/main/java/cn/lili/modules/lmk/domain/vo/CollectTypeNumVO.java | 22 ++ framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 11 + pom.xml | 1 framework/src/main/java/cn/lili/modules/lmk/enums/general/CollectTypeEnum.java | 45 ++++ framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java | 9 framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java | 6 /dev/null | 30 -- framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java | 10 framework/src/main/resources/mapper/lmk/VideoMapper.xml | 15 + framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 8 lmk-job/src/main/resources/application.yml | 266 ++++++++++++++++++++++++ framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java | 8 lmk-job/src/main/java/cn/lili/job/VideoJob.java | 42 +++ 17 files changed, 577 insertions(+), 32 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/CollectTypeNumVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/CollectTypeNumVO.java new file mode 100644 index 0000000..d216c92 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/CollectTypeNumVO.java @@ -0,0 +1,22 @@ +package cn.lili.modules.lmk.domain.vo; + +import lombok.Data; + +/** + * @author锛歺p + * @date锛�2025/5/23 9:23 + */ +@Data +public class CollectTypeNumVO { + + /** + * 瑙嗛id + */ + private String id; + + /** + * 鏀惰棌鏁伴噺 + */ + private Long collectNum; + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/enums/general/CollectTypeEnum.java b/framework/src/main/java/cn/lili/modules/lmk/enums/general/CollectTypeEnum.java new file mode 100644 index 0000000..1e352a6 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/enums/general/CollectTypeEnum.java @@ -0,0 +1,45 @@ +package cn.lili.modules.lmk.enums.general; + +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +/** + * 瑙嗛鏍囩鏉ユ簮 + * + * @author锛歺p + * @date锛�2025/5/14 10:30 + */ +@Getter +public enum CollectTypeEnum { + + VIDEO("video", "瑙嗛"), + ; + + private final String value; + + + private final String desc; + + CollectTypeEnum(String value, String desc) { + this.value = value; + this.desc = desc; + } + + /** + * 鑾峰彇鍚箟 + * + * @param value + * @return + */ + public static String getDescByValue(String value) { + if (StringUtils.isBlank(value)) { + return null; + } + for (CollectTypeEnum e : CollectTypeEnum.values()){ + if (value.equals(e.getValue())) { + return e.getDesc(); + } + } + return null; + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java index c6e6eb1..a53ab46 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java @@ -2,10 +2,10 @@ import cn.lili.modules.lmk.domain.entity.MyCollect; import cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO; +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.lili.modules.lmk.domain.vo.MyCollectVO; -import cn.lili.modules.lmk.domain.form.MyCollectForm; import cn.lili.modules.lmk.domain.query.MyCollectQuery; import java.util.List; import org.apache.ibatis.annotations.Mapper; @@ -40,4 +40,12 @@ * @return */ List<SimpleMyCollectVO> getCollectsByVideoIds(@Param("videoIds") List<String> videoIds, @Param("userId") String currentUserId); + + /** + * 鏍规嵁鏌愭敹钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 + * + * @param type + * @return + */ + List<CollectTypeNumVO> countNumGroupByType(@Param("type") String type); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java index 648b106..c7b4551 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java @@ -2,6 +2,7 @@ import cn.lili.modules.lmk.domain.entity.Video; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.lili.modules.lmk.domain.vo.VideoVO; @@ -46,4 +47,11 @@ * @return */ IPage recommendVideo(IPage page); + + /** + * 鎵归噺鏇存柊瑙嗛鏀惰棌鏁伴噺 + * + * @param numList + */ + void updateCollectNumBatch(@Param("list") List<CollectTypeNumVO> numList); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java b/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java index 5ee9d89..3e4358e 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java @@ -2,11 +2,11 @@ import cn.lili.modules.lmk.domain.entity.MyCollect; import cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO; +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.extension.service.IService; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.form.MyCollectForm; import cn.lili.modules.lmk.domain.query.MyCollectQuery; -import org.springframework.beans.PropertyValues; import java.util.List; @@ -73,4 +73,11 @@ * @return */ List<SimpleMyCollectVO> getCollectsByVideoIds(List<String> videoIds); + + /** + * 鏍规嵁鏌愭敹钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 + * @param type + * @return + */ + List<CollectTypeNumVO> countNumGroupByType(String type); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java index d17750f..5f0ce49 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java @@ -6,6 +6,7 @@ import cn.lili.modules.lmk.domain.form.VideoDownForm; import cn.lili.modules.lmk.domain.form.VideoRecommendForm; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.extension.service.IService; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.form.VideoForm; @@ -122,4 +123,11 @@ * @return */ Result recommendVideo(AbsQuery query); + + /** + * 鎵归噺鏇存柊瑙嗛鏀惰棌鏁伴噺 + * + * @param numList + */ + void updateCollectNumBatch(List<CollectTypeNumVO> numList); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java index 2b513d9..8a3ada6 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java @@ -2,6 +2,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO; +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.core.metadata.IPage; import cn.lili.modules.lmk.domain.entity.MyCollect; import cn.lili.modules.lmk.mapper.MyCollectMapper; @@ -137,4 +138,9 @@ public List<SimpleMyCollectVO> getCollectsByVideoIds(List<String> videoIds) { return baseMapper.getCollectsByVideoIds(videoIds, UserContext.getCurrentUserId()); } + + @Override + public List<CollectTypeNumVO> countNumGroupByType(String type) { + return baseMapper.countNumGroupByType(type); + } } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java index 33388a9..053fbfc 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java @@ -24,6 +24,7 @@ import cn.lili.modules.lmk.domain.form.VideoForm; import cn.lili.modules.lmk.domain.query.VideoQuery; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -278,4 +279,14 @@ } return Result.ok().data(page.getRecords()); } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCollectNumBatch(List<CollectTypeNumVO> numList) { + // 鎸�500鏉℃暟鎹繘琛屾媶鍒� + List<List<CollectTypeNumVO>> chunks = ListUtils.partition(numList, 500); + for (List<CollectTypeNumVO> chunk : chunks) { + baseMapper.updateCollectNumBatch(chunk); + } + } } diff --git a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml index b3f1a43..3a2e4a4 100644 --- a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml +++ b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml @@ -54,4 +54,16 @@ AND ref_id IN <foreach collection="videoIds" open="(" item="videoId" close=")" separator=",">#{videoId}</foreach> </select> + <select id="countNumGroupByType" parameterType="string" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO"> + SELECT + ref_id as id, + count(id) as collectNum + FROM + lmk_my_collect + WHERE + collect_type = #{type} AND delete_flag = 0 + GROUP BY + ref_id + </select> + </mapper> diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml index 1621b0e..6259ce8 100644 --- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml +++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml @@ -162,4 +162,19 @@ LV.delete_flag = 0 AND LV.status = '1' </select> + + <update id="updateCollectNumBatch"> + UPDATE lmk_video + SET collect_num = CASE id + <foreach collection="list" item="video"> + WHEN #{video.id} THEN #{video.collectNum} + </foreach> + ELSE collect_num + END + WHERE id IN + <foreach collection="list" item="video" open="(" separator="," close=")"> + #{video.id} + </foreach> + </update> + </mapper> diff --git a/lmk-job/pom.xml b/lmk-job/pom.xml new file mode 100644 index 0000000..22cbc1a --- /dev/null +++ b/lmk-job/pom.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <artifactId>lmk-job</artifactId> + + <parent> + <groupId>cn.lili</groupId> + <artifactId>lili-shop-parent</artifactId> + <version>${revision}</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>cn.lili</groupId> + <artifactId>framework</artifactId> + <version>${revision}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/lmk-job/src/main/java/cn/lili/LmkJobApplication.java b/lmk-job/src/main/java/cn/lili/LmkJobApplication.java new file mode 100644 index 0000000..dfbeab0 --- /dev/null +++ b/lmk-job/src/main/java/cn/lili/LmkJobApplication.java @@ -0,0 +1,33 @@ +package cn.lili; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.core.task.TaskExecutor; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +/** + * @author锛歺p + * @date锛�2025/5/23 9:09 + */ +@SpringBootApplication +@EnableCaching +@EnableAsync +public class LmkJobApplication { + + + @Primary + @Bean + public TaskExecutor primaryTask() { + return new ThreadPoolTaskExecutor(); + } + + public static void main(String[] args) { + System.setProperty("es.set.netty.runtime.available.processors", "false"); + System.setProperty("rocketmq.client.logUseSlf4j","true"); + SpringApplication.run(LmkJobApplication.class, args); + } +} diff --git a/lmk-job/src/main/java/cn/lili/job/VideoJob.java b/lmk-job/src/main/java/cn/lili/job/VideoJob.java new file mode 100644 index 0000000..0afed57 --- /dev/null +++ b/lmk-job/src/main/java/cn/lili/job/VideoJob.java @@ -0,0 +1,42 @@ +package cn.lili.job; + +import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; +import cn.lili.modules.lmk.enums.general.CollectTypeEnum; +import cn.lili.modules.lmk.service.MyCollectService; +import cn.lili.modules.lmk.service.VideoService; +import com.xxl.job.core.context.XxlJobHelper; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 瑙嗛鐩稿叧鐨勫畾鏃朵换鍔� + * + * @author锛歺p + * @date锛�2025/5/23 9:13 + */ +@Component +@RequiredArgsConstructor +public class VideoJob { + + private final VideoService videoService; + private final MyCollectService myCollectService; + + /** + * 瑙嗛鏀惰棌鏁扮粺璁� + * + * @throws Exception + */ + @XxlJob("videoCollectNumJob") + public void videoCollectNumJob() throws Exception { + XxlJobHelper.log("寮�濮嬫墽琛岋細瑙嗛鏀惰棌鏁扮粺璁�"); + List<CollectTypeNumVO> numList = myCollectService.countNumGroupByType(CollectTypeEnum.VIDEO.getValue()); + if (CollectionUtils.isNotEmpty(numList)) { + videoService.updateCollectNumBatch(numList); + } + } + +} diff --git a/lmk-job/src/main/resources/application.yml b/lmk-job/src/main/resources/application.yml new file mode 100644 index 0000000..5c5246c --- /dev/null +++ b/lmk-job/src/main/resources/application.yml @@ -0,0 +1,266 @@ +server: + port: 10001 + + servlet: + context-path: / + + tomcat: + uri-encoding: UTF-8 + threads: + min-spare: 50 + max: 1000 + +spring: + application: + name: lmk-job + # 瑕佸湪鍏朵腑娉ㄥ唽鐨凷pring Boot Admin Server鐨刄RL銆� + boot: + admin: + client: + url: http://127.0.0.1:8000 + cache: + type: redis + # Redis + redis: + host: 127.0.0.1 + port: 6379 +# password: lilishop + lettuce: + pool: + # 杩炴帴姹犳渶澶ц繛鎺ユ暟锛堜娇鐢ㄨ礋鍊艰〃绀烘病鏈夐檺鍒讹級 榛樿 8 + max-active: 200 + # 杩炴帴姹犳渶澶ч樆濉炵瓑寰呮椂闂达紙浣跨敤璐熷�艰〃绀烘病鏈夐檺鍒讹級 榛樿 -1 + max-wait: 20 + # 杩炴帴姹犱腑鐨勬渶澶х┖闂茶繛鎺� 榛樿 8 + max-idle: 10 + # 杩炴帴姹犱腑鐨勬渶灏忕┖闂茶繛鎺� 榛樿 8 + min-idle: 8 + # 鏂囦欢澶у皬涓婁紶閰嶇疆 + servlet: + multipart: + max-file-size: 20MB + max-request-size: 20MB + jackson: + time-zone: GMT+8 + serialization: + #鍏抽棴jackson 瀵筳son鍋氳В鏋� + fail-on-empty-beans: false + + shardingsphere: + datasource: + # 鏁版嵁搴撳悕绉帮紝鍙嚜瀹氫箟锛屽彲浠ヤ负澶氫釜锛屼互閫楀彿闅斿紑锛屾瘡涓湪杩欓噷瀹氫箟鐨勫簱锛岄兘瑕佸湪涓嬮潰瀹氫箟杩炴帴灞炴�� + names: default-datasource + default-datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + username: root + password: 123456 + maxActive: 20 + initialSize: 5 + maxWait: 60000 + minIdle: 5 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + #鏄惁缂撳瓨preparedStatement锛屼篃灏辨槸PSCache銆傚湪mysql涓嬪缓璁叧闂�� PSCache瀵规敮鎸佹父鏍囩殑鏁版嵁搴撴�ц兘鎻愬崌宸ㄥぇ锛屾瘮濡傝oracle銆� + poolPreparedStatements: false + #瑕佸惎鐢≒SCache锛�-1涓哄叧闂� 蹇呴』閰嶇疆澶т簬0锛屽綋澶т簬0鏃讹紝poolPreparedStatements鑷姩瑙﹀彂淇敼涓簍rue 鍙互鎶婅繖涓暟鍊奸厤缃ぇ涓�浜涳紝姣斿璇�100 + maxOpenPreparedStatements: -1 + #閰嶇疆鐩戞帶缁熻鎷︽埅鐨刦ilters锛屽幓鎺夊悗鐩戞帶鐣岄潰sql鏃犳硶缁熻锛�'wall'鐢ㄤ簬闃茬伀澧� + filters: stat,wall,log4j2 + #閫氳繃connectProperties灞炴�ф潵鎵撳紑mergeSql鍔熻兘锛涙參SQL璁板綍 + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + #鍚堝苟澶氫釜DruidDataSource鐨勭洃鎺ф暟鎹� + useGlobalDataSourceStat: true + loginUsername: druid + loginPassword: druid + # sharding: + # default-data-source-name: default-datasource + # #闇�瑕佹媶鍒嗙殑琛紝鍙互璁剧疆澶氫釜 鍦� li_order 绾у埆鍗冲彲 + # tables: + # #闇�瑕佽繘琛屽垎琛ㄧ殑閫昏緫琛ㄥ悕 + # li_order: + # #瀹為檯鐨勮〃缁撶偣,涓嬮潰浠h〃鐨勬槸li_order_涓哄紑澶寸殑鎵�鏈夎〃锛屽鏋滆兘纭畾琛ㄧ殑鑼冨洿渚嬪鎸夋湀浠藉垎琛紝杩欓噷鐨勫啓娉曟槸data2020.li_order_$->{2020..2021}_$->{01..12} 琛ㄧず渚嬪 li_order_2020_01 li_order_2020_03 li_order_2021_01 + # actual-data-nodes: data2020.li_order_$->{2019..2021}_$->{01..12} + # table-strategy: + # # 鍒嗚〃绛栫暐锛屾牴鎹垱寤烘棩鏈� + # standard: + # sharding-column: create_time + # #鍒嗚〃绛栫暐 + # precise-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm + # #鑼冨洿鏌ヨ瀹炵幇 + # range-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm + props: + #鏄惁鎵撳嵃閫昏緫SQL璇彞鍜屽疄闄匰QL璇彞锛屽缓璁皟璇曟椂鎵撳嵃锛屽湪鐢熶骇鐜鍏抽棴 + sql: + show: false + +# 蹇界暐閴存潈url +ignored: + urls: + - /editor-app/** + - /actuator** + - /actuator/** + - /MP_verify_qSyvBPhDsPdxvOhC.txt + - /weixin/** + - /source/** + - /manager/passport/user/login + - /manager/passport/user/refresh/** + - /manager/other/elasticsearch + - /manager/other/customWords + - /druid/** + - /swagger-ui.html + - /doc.html + - /swagger-resources/** + - /swagger/** + - /webjars/** + - /v2/api-docs + - /configuration/ui + - /boot-admin + - /**/*.js + - /**/*.css + - /**/*.png + - /**/*.ico + +# Swagger鐣岄潰鍐呭閰嶇疆 +swagger: + title: lili API鎺ュ彛鏂囨。 + description: lili Api Documentation + version: 1.0.0 + termsOfServiceUrl: https://pickmall.cn + contact: + name: lili + url: https://pickmall.cn + email: admin@pickmall.com + +# Mybatis-plus +mybatis-plus: + mapper-locations: classpath*:mapper/*.xml + configuration: + #缂撳瓨寮�鍚� + cache-enabled: true + #鏃ュ織 +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +# 鏃ュ織 +logging: + config: classpath:logback-spring.xml + # 杈撳嚭绾у埆 + level: + cn.lili: info + # org.hibernate: debug + # org.springframework: debug + file: + # 鎸囧畾璺緞 + path: lili-logs + logback: + rollingpolicy: + # 鏈�澶т繚瀛樺ぉ鏁� + max-history: 7 + # 姣忎釜鏂囦欢鏈�澶уぇ灏� + max-file-size: 5MB +#鍔犲瘑鍙傛暟 +jasypt: + encryptor: + password: lili + +lili: + system: + isDemoSite: true + # 鑴辨晱绾у埆锛� + # 0锛氫笉鍋氳劚鏁忓鐞� + # 1锛氱鐞嗙鐢ㄦ埛鎵嬫満鍙风瓑淇℃伅鑴辨晱 + # 2锛氬晢瀹剁淇℃伅鑴辨晱锛堜负2鏃讹紝琛ㄧず绠$悊绔紝鍟嗗绔悓鏃惰劚鏁忥級 + sensitiveLevel: 1 + statistics: + # 鍦ㄧ嚎浜烘暟缁熻 X 灏忔椂銆傝繖閲岃缃�48锛屽嵆缁熻杩囧幓48灏忔椂姣忓皬鏃跺湪绾夸汉鏁� + onlineMember: 48 + # 褰撳墠鍦ㄧ嚎浜烘暟鍒锋柊鏃堕棿闂撮殧锛屽崟浣嶇锛岃缃负600锛屽垯姣�10鍒嗛挓鍒锋柊涓�娆� + currentOnlineUpdate: 600 + #qq lbs 鐢宠 + lbs: + key: 4BYBZ-7MT6S-PUAOA-6BNWL-FJUD7-UUFXT + sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6 + #鍩熷悕 + domain: + pc: https://pc.b2b2c.pickmall.cn + wap: https://m.b2b2c.pickmall.cn + store: https://store.b2b2c.pickmall.cn + admin: https://admin.b2b2c.pickmall.cn + #api鍦板潃 + api: + buyer: https://buyer-api.pickmall.cn + common: https://common-api.pickmall.cn + manager: https://admin-api.pickmall.cn + store: https://store-api.pickmall.cn + + # jwt 缁嗚妭璁惧畾 + jwt-setting: + # token杩囨湡鏃堕棿锛堝垎閽燂級 + tokenExpireTime: 60 + + # 浣跨敤Spring @Cacheable娉ㄨВ澶辨晥鏃堕棿 + cache: + # 杩囨湡鏃堕棿 鍗曚綅绉� 姘镐箙涓嶈繃鏈熻涓�-1 + timeout: 1500 + #澶氱嚎绋嬮厤缃� + thread: + corePoolSize: 5 + maxPoolSize: 50 + queueCapacity: 50 + data: + elasticsearch: + cluster-name: elasticsearch + cluster-nodes: 127.0.0.1:9200 + index: + number-of-replicas: 0 + number-of-shards: 3 + index-prefix: lili + schema: http + # account: + # username: elastic + # password: LiLiShopES +# logstash: +# server: 127.0.0.1:4560 + rocketmq: + promotion-topic: lili_promotion_topic + promotion-group: lili_promotion_group + msg-ext-topic: lili_msg_topic + msg-ext-group: lili_msg_group + goods-topic: lili_goods_topic + goods-group: lili_goods_group + order-topic: lili_order_topic + order-group: lili_order_group + member-topic: lili_member_topic + member-group: lili_member_group + store-topic: lili_store_topic + store-group: lili_store_group + other-topic: lili_other_topic + other-group: lili_other_group + notice-topic: lili_notice_topic + notice-group: lili_notice_group + notice-send-topic: lili_send_notice_topic + notice-send-group: lili_send_notice_group + after-sale-topic: lili_after_sale_topic + after-sale-group: lili_after_sale_group +rocketmq: + name-server: 127.0.0.1:9876 + producer: + group: lili_group + send-message-timeout: 30000 + +xxl: + job: + admin: + addresses: http://127.0.0.1:9001/xxl-job-admin + executor: + appname: xxl-job-executor-lilishop + address: + ip: + port: 8848 + logpath: ./xxl-job/executor + logretentiondays: 7 diff --git a/lmk-job/src/main/resources/logback-spring.xml b/lmk-job/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..76ecb0d --- /dev/null +++ b/lmk-job/src/main/resources/logback-spring.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE configuration> +<configuration> + <include resource="org/springframework/boot/logging/logback/defaults.xml"/> + <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> + <!--搴旂敤鍚嶇О--> + <springProperty scope="context" name="APP_NAME" source="spring.application.name"/> + <!--鏃ュ織鏂囦欢淇濆瓨璺緞--> + <springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/> + <springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/> + <contextName>${APP_NAME}</contextName> + + <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log</fileNamePattern> + <maxHistory>30</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${FILE_LOG_PATTERN}</pattern> + </encoder> + </appender> + + <appender name="RocketmqClientAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${LOG_FILE_PATH}/rocketmq.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${LOG_FILE_PATH}/rocketmq/rocketmq-%d{yyyy-MM-dd}.log</fileNamePattern> + <maxHistory>30</maxHistory> + <totalSizeCap>30MB</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern> + </encoder> + </appender> + <logger name="RocketmqClient" additivity="false"> + <level value="info" /> + <appender-ref ref="RocketmqClientAppender"/> + </logger> + +<!-- <!–杈撳嚭鍒癳lk鐨凩OGSTASH–>--> +<!-- <appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">--> +<!-- <!– 閰嶇疆elk鏃ュ織鏀堕泦 閰嶉グ鐨勬槸 LOGSTASH 鐨勫湴鍧�–>--> +<!-- <destination>${LOGSTASH_SERVER}</destination>--> +<!-- <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">--> +<!-- <providers>--> +<!-- <timestamp>--> +<!-- <timeZone>UTC</timeZone>--> +<!-- </timestamp>--> +<!-- </providers>--> +<!-- <!–鑷畾涔夊瓧娈� 鍖哄垎椤圭洰–>--> +<!-- <customFields>{"appName":"${APP_NAME}"}</customFields>--> +<!-- </encoder>--> +<!-- </appender>--> + <root level="INFO"> + <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> +<!-- <appender-ref ref="LOGSTASH"/>--> + </root> +</configuration> diff --git a/manager-api/src/main/java/cn/lili/controller/job/TestJob.java b/manager-api/src/main/java/cn/lili/controller/job/TestJob.java deleted file mode 100644 index 2cfab23..0000000 --- a/manager-api/src/main/java/cn/lili/controller/job/TestJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.lili.controller.job; - -import com.xxl.job.core.context.XxlJobHelper; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import java.util.concurrent.TimeUnit; - -/** - * @author锛歺p - * @date锛�2025/5/22 16:49 - */ -@Component -public class TestJob { - - // 绠�鍗曚换鍔$ず渚� - @XxlJob("demoJobHandler") - public void demoJobHandler() throws Exception { - XxlJobHelper.log("XXL-JOB, Hello World."); - - // 鎵ц浣犵殑涓氬姟閫昏緫 - for (int i = 0; i < 5; i++) { - XxlJobHelper.log("beat at:" + i); - TimeUnit.SECONDS.sleep(2); - } - - // 榛樿杩斿洖鎴愬姛缁撴灉 - } - -} diff --git a/pom.xml b/pom.xml index 3727158..87c45da 100644 --- a/pom.xml +++ b/pom.xml @@ -77,6 +77,7 @@ <module>consumer</module> <module>admin</module> <module>im-api</module> + <module>lmk-job</module> </modules> <build> -- Gitblit v1.8.0