From 8fc86bebff38fb7f12b04e70c213c84fa85e7ec4 Mon Sep 17 00:00:00 2001
From: Loki <654612@qq.com>
Date: Fri, 17 Jun 2022 21:00:22 +0800
Subject: [PATCH 1/3] dict
---
.../config/YudaoMybatisAutoConfiguration.java | 6 +-
.../resources/mapper/test/TestDemoMapper.xml | 6 +-
.../system/dal/mysql/dict/DictMapper.java | 15 +
.../yudao/module/system/dict/Dict.java | 43 +++
.../yudao/module/system/dict/DictAspect.java | 323 ++++++++++++++++++
.../yudao/module/system/dict/DictModel.java | 52 +++
.../system/service/dict/DictDataService.java | 3 +
.../service/dict/DictDataServiceImpl.java | 23 +-
.../java/resources/mapper/dict/DictMapper.xml | 17 +
.../resources/mapper/CpUser/CpUserMapper.xml | 12 +
.../main/resources/mapper/dict/DictMapper.xml | 17 +
.../admin/resource/vo/ResourceBaseVO.java | 2 +
.../dal/dataobject/resource/ResourceDO.java | 5 +
13 files changed, 516 insertions(+), 8 deletions(-)
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictMapper.java
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/Dict.java
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictModel.java
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/java/resources/mapper/dict/DictMapper.xml
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/CpUser/CpUserMapper.xml
create mode 100644 yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/dict/DictMapper.xml
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
index 68284d11..5d0508e2 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
@@ -111,9 +111,13 @@ public class YudaoMybatisAutoConfiguration {
GlobalConfig globalConfig = new GlobalConfig();
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
dbConfig.setIdType(IdType.AUTO);
- log.error("dbConfig:{}",dbConfig);
globalConfig.setDbConfig(dbConfig);
globalConfig.setMetaObjectHandler(defaultMetaObjectHandler());
+ Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath*:/mapper/*/*.xml");
+ Arrays.stream(resources).forEach(resource -> {
+ log.info("master mapper:{}",resource.getFilename());
+ });
+ factory.setMapperLocations(resources);
factory.setPlugins(mybatisPlusInterceptor());
factory.setGlobalConfig(globalConfig);
return factory.getObject();
diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/resources/mapper/test/TestDemoMapper.xml b/yudao-module-infra/yudao-module-infra-impl/src/main/resources/mapper/test/TestDemoMapper.xml
index d65f2136..35395d57 100644
--- a/yudao-module-infra/yudao-module-infra-impl/src/main/resources/mapper/test/TestDemoMapper.xml
+++ b/yudao-module-infra/yudao-module-infra-impl/src/main/resources/mapper/test/TestDemoMapper.xml
@@ -9,8 +9,8 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
-
+
+
+
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictMapper.java
new file mode 100644
index 00000000..3dd88f36
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictMapper.java
@@ -0,0 +1,15 @@
+package cn.iocoder.yudao.module.system.dal.mysql.dict;
+
+import cn.iocoder.yudao.module.system.dict.DictModel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface DictMapper extends BaseMapper {
+
+ List queryTableDictByKeysAndFilterSql(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql, @Param("codeValues") List codeValues);
+
+}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/Dict.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/Dict.java
new file mode 100644
index 00000000..348309b5
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/Dict.java
@@ -0,0 +1,43 @@
+package cn.iocoder.yudao.module.system.dict;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 字典注解
+ * @author: dangzhenghui
+ * @date: 2019年03月17日-下午9:37:16
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Dict {
+ /**
+ * 方法描述: 数据code
+ * 作 者: dangzhenghui
+ * 日 期: 2019年03月17日-下午9:37:16
+ *
+ * @return 返回类型: String
+ */
+ String dicCode();
+
+ /**
+ * 方法描述: 数据Text
+ * 作 者: dangzhenghui
+ * 日 期: 2019年03月17日-下午9:37:16
+ *
+ * @return 返回类型: String
+ */
+ String dicText() default "";
+
+ /**
+ * 方法描述: 数据字典表
+ * 作 者: dangzhenghui
+ * 日 期: 2019年03月17日-下午9:37:16
+ *
+ * @return 返回类型: String
+ */
+ String dictTable() default "";
+}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java
new file mode 100644
index 00000000..e4db1565
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java
@@ -0,0 +1,323 @@
+package cn.iocoder.yudao.module.system.dict;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.parser.Feature;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 字典aop类
+ * @Author: dangzhenghui
+ * @Date: 2019-3-17 21:50
+ * @Version: 1.0
+ */
+@Aspect
+@Component
+@Slf4j
+public class DictAspect {
+
+ @Autowired
+ private DictDataService dictDataService;
+ @Autowired
+ public RedisTemplate redisTemplate;
+
+ public static final String DICT_TEXT_SUFFIX = "_dictText";
+
+ /**
+ * 定义切点Pointcut
+ */
+ @Pointcut("execution(public * cn.iocoder.yudao.module.*.controller..*.*Controller.*(..))")
+ public void excudeService() {
+ }
+
+ @Around("excudeService()")
+ public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
+ long time1=System.currentTimeMillis();
+ Object result = pjp.proceed();
+ long time2=System.currentTimeMillis();
+ log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
+ long start=System.currentTimeMillis();
+ this.parseDictText(result);
+ long end=System.currentTimeMillis();
+ log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms");
+ return result;
+ }
+
+ /**
+ * 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
+ * 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 ,table字典 code table text配合使用与原来jeecg的用法相同
+ * 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text,已字段名称加_dictText形式返回到前端
+ * 例输入当前返回值的就会多出一个sex_dictText字段
+ * {
+ * sex:1,
+ * sex_dictText:"男"
+ * }
+ * 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
+ * customRender:function (text) {
+ * if(text==1){
+ * return "男";
+ * }else if(text==2){
+ * return "女";
+ * }else{
+ * return text;
+ * }
+ * }
+ * 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
+ * @param result
+ */
+ private void parseDictText(Object result) {
+ if (result instanceof CommonResult) {
+ if (((CommonResult) result).getData() instanceof PageResult) {
+ List items = new ArrayList<>();
+
+ //step.1 筛选出加了 Dict 注解的字段列表
+ List dictFieldList = new ArrayList<>();
+ // 字典数据列表, key = 字典code,value=数据列表
+ Map> dataListMap = new HashMap<>(5);
+
+ for (Object record : ((PageResult) ((CommonResult) result).getData()).getList()) {
+ ObjectMapper mapper = new ObjectMapper();
+ String json="{}";
+ try {
+ //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
+ json = mapper.writeValueAsString(record);
+ } catch (JsonProcessingException e) {
+ log.error("json解析失败"+e.getMessage(),e);
+ }
+ //update-begin--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 -----
+ JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
+ //update-end--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 -----
+
+ //update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
+ //for (Field field : record.getClass().getDeclaredFields()) {
+ // 遍历所有字段,把字典Code取出来,放到 map 里
+ for (Field field : getAllFields(record)) {
+ String value = item.getString(field.getName());
+ if (ObjectUtil.isEmpty(value)) {
+ continue;
+ }
+ //update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
+ if (field.getAnnotation(Dict.class) != null) {
+ if (!dictFieldList.contains(field)) {
+ dictFieldList.add(field);
+ }
+ String code = field.getAnnotation(Dict.class).dicCode();
+ String text = field.getAnnotation(Dict.class).dicText();
+ String table = field.getAnnotation(Dict.class).dictTable();
+
+ List dataList;
+ String dictCode = code;
+ if (!StringUtils.isEmpty(table)) {
+ dictCode = String.format("%s,%s,%s", table, text, code);
+ }
+ dataList = dataListMap.computeIfAbsent(dictCode, k -> new ArrayList<>());
+ this.listAddAllDeduplicate(dataList, Arrays.asList(value.split(",")));
+ }
+ //date类型默认转换string格式化日期
+// if (CommonConstant.JAVA_UTIL_DATE.equals(field.getType().getName())&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){
+// SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+// item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
+// }
+ }
+ items.add(item);
+ }
+
+ //step.2 调用翻译方法,一次性翻译
+ Map> translText = this.translateAllDict(dataListMap);
+
+ //step.3 将翻译结果填充到返回结果里
+ for (JSONObject record : items) {
+ for (Field field : dictFieldList) {
+ String code = field.getAnnotation(Dict.class).dicCode();
+ String text = field.getAnnotation(Dict.class).dicText();
+ String table = field.getAnnotation(Dict.class).dictTable();
+
+ String fieldDictCode = code;
+ if (!StringUtils.isEmpty(table)) {
+ fieldDictCode = String.format("%s,%s,%s", table, text, code);
+ }
+
+ String value = record.getString(field.getName());
+ if (ObjectUtil.isNotEmpty(value)) {
+ List dictModels = translText.get(fieldDictCode);
+ if(dictModels==null || dictModels.size()==0){
+ continue;
+ }
+
+ String textValue = this.translDictText(dictModels, value);
+ log.debug(" 字典Val : " + textValue);
+ log.debug(" __翻译字典字段__ " + field.getName() + DICT_TEXT_SUFFIX + ": " + textValue);
+
+ // TODO-sun 测试输出,待删
+ log.debug(" ---- dictCode: " + fieldDictCode);
+ log.debug(" ---- value: " + value);
+ log.debug(" ----- text: " + textValue);
+ log.debug(" ---- dictModels: " + JSON.toJSONString(dictModels));
+
+ record.put(field.getName() + DICT_TEXT_SUFFIX, textValue);
+ }
+ }
+ }
+
+ ((PageResult)((CommonResult) result).getData()).setList(items);
+ }
+
+ }
+ }
+
+ /**
+ * list 去重添加
+ */
+ private void listAddAllDeduplicate(List dataList, List addList) {
+ // 筛选出dataList中没有的数据
+ List filterList = addList.stream().filter(i -> !dataList.contains(i)).collect(Collectors.toList());
+ dataList.addAll(filterList);
+ }
+
+ /**
+ * 一次性把所有的字典都翻译了
+ * 1. 所有的普通数据字典的所有数据只执行一次SQL
+ * 2. 表字典相同的所有数据只执行一次SQL
+ * @param dataListMap
+ * @return
+ */
+ private Map> translateAllDict(Map> dataListMap) {
+ // 翻译后的字典文本,key=dictCode
+ Map> translText = new HashMap<>(5);
+ // 需要翻译的数据(有些可以从redis缓存中获取,就不走数据库查询)
+ List needTranslData = new ArrayList<>();
+ //step.1 先通过redis中获取缓存字典数据
+ for (String dictCode : dataListMap.keySet()) {
+ List dataList = dataListMap.get(dictCode);
+ if (dataList.size() == 0) {
+ continue;
+ }
+ // 表字典需要翻译的数据
+ List needTranslDataTable = new ArrayList<>();
+ for (String s : dataList) {
+ String data = s.trim();
+ if (data.length() == 0) {
+ continue; //跳过循环
+ }
+ if (dictCode.contains(",")) {
+ String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, data);
+ if (redisTemplate.hasKey(keyString)) {
+ try {
+ String text = redisTemplate.opsForValue().get(keyString).toString();
+ List list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
+ list.add(new DictModel(data, text));
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ }
+ } else if (!needTranslDataTable.contains(data)) {
+ // 去重添加
+ needTranslDataTable.add(data);
+ }
+ } else {
+ String keyString = String.format("sys:cache:dict::%s:%s", dictCode, data);
+ if (redisTemplate.hasKey(keyString)) {
+ try {
+ String text = redisTemplate.opsForValue().get(keyString).toString();
+ List list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
+ list.add(new DictModel(data, text));
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ }
+ } else if (!needTranslData.contains(data)) {
+ // 去重添加
+ needTranslData.add(data);
+ }
+ }
+
+ }
+ //step.2 调用数据库翻译表字典
+ if (needTranslDataTable.size() > 0) {
+ String[] arr = dictCode.split(",");
+ String table = arr[0], text = arr[1], code = arr[2];
+ String values = String.join(",", needTranslDataTable);
+ log.info("translateDictFromTableByKeys.dictCode:" + dictCode);
+ log.info("translateDictFromTableByKeys.values:" + values);
+ List texts = dictDataService.queryTableDictTextByKeys(table,text,code,needTranslDataTable);
+ log.info("translateDictFromTableByKeys.result:" + texts);
+ List list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
+ list.addAll(texts);
+
+ // 做 redis 缓存
+ for (DictModel dict : texts) {
+ String redisKey = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, dict.getValue());
+ try {
+ // update-begin-author:taoyan date:20211012 for: 字典表翻译注解缓存未更新 issues/3061
+ // 保留5分钟
+ redisTemplate.opsForValue().set(redisKey, dict.getText(), 300, TimeUnit.SECONDS);
+ // update-end-author:taoyan date:20211012 for: 字典表翻译注解缓存未更新 issues/3061
+ } catch (Exception e) {
+ log.warn(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ //step.3 调用数据库进行翻译普通字典
+ return translText;
+ }
+
+ /**
+ * 字典值替换文本
+ *
+ * @param dictModels
+ * @param values
+ * @return
+ */
+ private String translDictText(List dictModels, String values) {
+ List result = new ArrayList<>();
+
+ // 允许多个逗号分隔,允许传数组对象
+ String[] splitVal = values.split(",");
+ for (String val : splitVal) {
+ String dictText = val;
+ for (DictModel dict : dictModels) {
+ if (val.equals(dict.getValue())) {
+ dictText = dict.getText();
+ break;
+ }
+ }
+ result.add(dictText);
+ }
+ return String.join(",", result);
+ }
+
+
+
+ public static Field[] getAllFields(Object object) {
+ Class> clazz = object.getClass();
+ List fieldList = new ArrayList<>();
+ while (clazz != null) {
+ fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
+ clazz = clazz.getSuperclass();
+ }
+ Field[] fields = new Field[fieldList.size()];
+ fieldList.toArray(fields);
+ return fields;
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictModel.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictModel.java
new file mode 100644
index 00000000..202b38bb
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictModel.java
@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.system.dict;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 字典类
+ * @author: jeecg-boot
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DictModel implements Serializable{
+ private static final long serialVersionUID = 1L;
+
+ public DictModel() {
+ }
+
+ public DictModel(String value, String text) {
+ this.value = value;
+ this.text = text;
+ }
+
+ /**
+ * 字典value
+ */
+ private String value;
+ /**
+ * 字典文本
+ */
+ private String text;
+
+ /**
+ * 特殊用途: JgEditableTable
+ * @return
+ */
+ public String getTitle() {
+ return this.text;
+ }
+ /**
+ * 特殊用途: vue3 Select组件
+ */
+ public String getLabel() {
+ return this.text;
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java
index db1a1b62..fda471cb 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataCrea
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataUpdateReqVO;
+import cn.iocoder.yudao.module.system.dict.DictModel;
import java.util.Collection;
import java.util.List;
@@ -94,4 +95,6 @@ public interface DictDataService extends DictDataFrameworkService {
*/
void validDictDatas(String dictType, Collection values);
+ List queryTableDictTextByKeys(String table, String text, String code, List keys);
+
}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java
index abbd2db2..9932e6ff 100644
--- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java
@@ -13,20 +13,20 @@ import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
import cn.iocoder.yudao.module.system.dal.mysql.dict.DictDataMapper;
+import cn.iocoder.yudao.module.system.dal.mysql.dict.DictMapper;
+import cn.iocoder.yudao.module.system.dict.DictModel;
import cn.iocoder.yudao.module.system.mq.producer.dict.DictDataProducer;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableTable;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
@@ -40,6 +40,8 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
@Slf4j
public class DictDataServiceImpl implements DictDataService {
+ @Autowired
+ private DictMapper dictMapper;
/**
* 排序 dictType > sort
*/
@@ -277,4 +279,17 @@ public class DictDataServiceImpl implements DictDataService {
});
}
+ @Override
+ public List queryTableDictTextByKeys(String table, String text, String code, List keys) {
+ //update-begin-author:taoyan date:20220113 for: @dict注解支持 dicttable 设置where条件
+ String filterSql = null;
+ if(table.toLowerCase().indexOf("where")>0){
+ String[] arr = table.split(" (?i)where ");
+ table = arr[0];
+ filterSql = arr[1];
+ }
+ return dictMapper.queryTableDictByKeysAndFilterSql(table, text, code, filterSql, keys);
+ //update-end-author:taoyan date:20220113 for: @dict注解支持 dicttable 设置where条件
+ }
+
}
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/resources/mapper/dict/DictMapper.xml b/yudao-module-system/yudao-module-system-impl/src/main/java/resources/mapper/dict/DictMapper.xml
new file mode 100644
index 00000000..026ed23c
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/java/resources/mapper/dict/DictMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/CpUser/CpUserMapper.xml b/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/CpUser/CpUserMapper.xml
new file mode 100644
index 00000000..b3712bde
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/CpUser/CpUserMapper.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/dict/DictMapper.xml b/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/dict/DictMapper.xml
new file mode 100644
index 00000000..101c80c3
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-impl/src/main/resources/mapper/dict/DictMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java
index 54650eb4..5c51a36c 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.controller.admin.resource.vo;
+import cn.iocoder.yudao.module.system.dict.Dict;
import com.alibaba.fastjson.JSONArray;
import lombok.*;
import java.util.*;
@@ -17,6 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
public class ResourceBaseVO {
@ApiModelProperty(value = "")
+ @Dict(dictTable = "farm_resource_type",dicText = "name",dicCode = "id")
private Long resourceType;
@ApiModelProperty(value = "")
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java
index 0ccd7a4f..d52578d3 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java
@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.resource;
+import cn.iocoder.yudao.module.system.dict.Dict;
+import cn.iocoder.yudao.module.system.dict.DictAspect;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModelProperty;
@@ -60,4 +62,7 @@ public class ResourceDO extends BaseDO {
@ApiModelProperty("假装删除")
private Boolean pretendDelete;
+ public Boolean getSolo() {
+ return solo;
+ }
}
From f77d753264eadb564854179af40c63cbb9371c6d Mon Sep 17 00:00:00 2001
From: Loki <654612@qq.com>
Date: Mon, 20 Jun 2022 13:42:46 +0800
Subject: [PATCH 2/3] fix log
---
.../src/main/resources/application-local.yaml | 10 +++----
.../src/main/resources/logback-spring.xml | 6 ++++
.../src/main/resources/spy.properties | 29 ++++++++++---------
yudao-ui-admin | 2 +-
4 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml
index cd0e18ce..d0958be4 100644
--- a/yudao-server/src/main/resources/application-local.yaml
+++ b/yudao-server/src/main/resources/application-local.yaml
@@ -164,15 +164,13 @@ logging:
name: logs/${spring.application.name}.log # 日志文件名,全路径
level:
# 配置自己写的 MyBatis Mapper 打印日志
- cn.iocoder.yudao.module.bpm.dal.mysql: debug
- cn.iocoder.yudao.module.infra.dal.mysql: debug
- cn.iocoder.yudao.module.pay.dal.mysql: debug
- cn.iocoder.yudao.module.system.dal.mysql: debug
- cn.iocoder.yudao.module.tool.dal.mysql: debug
- cn.iocoder.yudao.module.member.dal.mysql: debug
+ cn.iocoder.yudao: info
co.yixiang: debug
org.quartz: error
+mybatis-plus:
+ configuration:
+ log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
--- #################### 微信公众号相关配置 ####################
wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
mp:
diff --git a/yudao-server/src/main/resources/logback-spring.xml b/yudao-server/src/main/resources/logback-spring.xml
index f4c061b3..e95be020 100644
--- a/yudao-server/src/main/resources/logback-spring.xml
+++ b/yudao-server/src/main/resources/logback-spring.xml
@@ -65,6 +65,12 @@
+
+
+
+
+
+
diff --git a/yudao-server/src/main/resources/spy.properties b/yudao-server/src/main/resources/spy.properties
index af0bb2a7..663dcda0 100644
--- a/yudao-server/src/main/resources/spy.properties
+++ b/yudao-server/src/main/resources/spy.properties
@@ -1,24 +1,27 @@
-#3.2.1以上使用
+#3.2.1????
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
-#3.2.1以下使用或者不配置
+#3.2.1?????????
#modulelist=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
-# 自定义日志打印
+# ???????
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
-#日志输出到控制台
+#????????
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
-# 使用日志系统记录 sql
+# ???????? sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
-# 设置 p6spy driver 代理
+# ?? p6spy driver ??
deregisterdrivers=true
-# 取消JDBC URL前缀
+# ??JDBC URL??
useprefix=true
-# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
+# ???? Log ??,????????error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories=info,debug,result,commit,resultset
-# 日期格式
+# ????
dateformat=yyyy-MM-dd HH:mm:ss
-# 实际驱动可多个
+# ???????
#driverlist=org.h2.Driver
-# 是否开启慢SQL记录
+# ?????SQL??
outagedetection=true
-# 慢SQL记录标准 2 秒
-outagedetectioninterval=2
\ No newline at end of file
+# ?SQL???? 2 ?
+outagedetectioninterval=2
+
+filter=true
+exclude=QRTZ_,ACT_,
\ No newline at end of file
diff --git a/yudao-ui-admin b/yudao-ui-admin
index 940f54e8..beb44f8a 160000
--- a/yudao-ui-admin
+++ b/yudao-ui-admin
@@ -1 +1 @@
-Subproject commit 940f54e876f1c6ccc6e239c5990d34e83fb02b78
+Subproject commit beb44f8aa54a4e20a48985d771a0353641df4787
From 5dd48e50a0895a364fab3f065ef5dbcd14f909e9 Mon Sep 17 00:00:00 2001
From: Loki <654612@qq.com>
Date: Mon, 20 Jun 2022 15:08:31 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9farmmsg=E6=B3=A8=E8=A7=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../yudao/module/farm/annotation/FarmMsg.java | 4 +-
.../module/farm/annotation/FarmMsgAspect.java | 239 +++++++++++-------
.../module/farm/annotation/FarmMsgType.java | 20 ++
.../admin/project/ProjectController.java | 7 +-
.../controller/admin/task/TaskController.java | 7 +-
.../service/WxCpServiceNoticeService.java | 9 +
6 files changed, 179 insertions(+), 107 deletions(-)
create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java
create mode 100644 zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/WxCpServiceNoticeService.java
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java
index 8aa2e0a7..c758a9b7 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java
@@ -11,9 +11,9 @@ import java.lang.annotation.*;
@Documented
public @interface FarmMsg {
- String type() default "";
+ FarmMsgType type() default FarmMsgType.NONE;
- String operation() default "";
+ FarmMsgType operation() default FarmMsgType.NONE;
String title() default "";
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
index d8af6c65..1a20159d 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
@@ -17,13 +17,15 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO;
import cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper;
+import cn.iocoder.yudao.module.farm.service.WxCpServiceNoticeService;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.AfterReturning;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Method;
@@ -45,117 +47,158 @@ public class FarmMsgAspect {
@Resource
private ProjectMapper projectMapper;
+ @Resource
+ private WxCpServiceNoticeService wxCpServiceNoticeService;
+
+ @Autowired
+ private WxCpService wxCpService;
/**
* 定义切入点 @PointCut
* 使用了@FarmMsg注解的地方切入
*
**/
- @Pointcut("@annotation(cn.iocoder.yudao.module.farm.annotation.FarmMsg)")
- public void farmMsgPointCut(){
+ @Pointcut("@annotation(farmMsg)")
+ public void farmMsgPointCut(FarmMsg farmMsg){}
+
+ @Around("farmMsgPointCut(farmMsg)")
+ public Object doAround(ProceedingJoinPoint pjp,FarmMsg farmMsg) throws Throwable {
+ Object object = pjp.proceed();
+ if (object instanceof CommonResult){
+ // 只处理接口正常result
+ if (farmMsg.type() == FarmMsgType.NONE
+ || farmMsg.operation() == FarmMsgType.NONE
+ || ((CommonResult>) object).getCode()!=0 ){
+ return object;
+ }
- }
+ // 构造一个企业推送消息
+ WxCpMessage message = new WxCpMessage();
+
+ if (farmMsg.type() == FarmMsgType.PROJECT){
+ if (farmMsg.operation() == FarmMsgType.CREATE){
+ Long id = (Long) ((CommonResult>) object).getData();
+ // 发企业微信
+ // 拼接全部的参与用户
+ message.setToUser("");
+ //把主题填充
+ message.setTitle("");
+ wxCpService.getMessageService().send(message);
+ }
+ // 跟新项目 删除项目 更新任务 删除任务。。。
- @Before(value = "farmMsgPointCut()")
- public void beforeSaveFarmMsg(JoinPoint joinPoint){
- MethodSignature signature = (MethodSignature) joinPoint.getSignature();
- Method method = signature.getMethod();
- FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
+ // 构造一个卡片消息 消息名称 : 回乡农场任务管理更新 , 小标题: xxx 创建了项目,请查看处理。
+ // appid 是小程序的appid
+ // touser 可以传多个。
+ // 这里处理完删除注释
+ }
- if (method.getName().startsWith("get")){
- if (farmMsg.type().equals("任务")){
- }else if (farmMsg.type().equals("项目")){
- }
}
-
+ return object;
}
+// @Before(value = "farmMsgPointCut()")
+// public void beforeSaveFarmMsg(JoinPoint joinPoint){
+// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+// Method method = signature.getMethod();
+// FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
+//
+// if (method.getName().startsWith("get")){
+// if (farmMsg.type().equals("任务")){
+//
+// }else if (farmMsg.type().equals("项目")){
+//
+// }
+// }
+//
+// }
+
/**
* 拦截用户操作日志, 连接点执行完成后记录, 如果连接点异常,则不会执行
* @param jointPoint 切入点
**/
- @AfterReturning(value = "farmMsgPointCut()", returning = "result")
- public void afterSaveFarmMsg(JoinPoint jointPoint, Object result){
- //从切入点通过反射获取切入点方法
- MethodSignature signature = (MethodSignature) jointPoint.getSignature();
- //获取切入点的方法
- Method method = signature.getMethod();
-
- FarmMsgDTO farmMsgDTO = this.assembleMsg(method, jointPoint.getArgs(), result);
-
- //插入农场日志信息
- LogMsgDO logMsg = LogMsgDO.builder()
- .type(farmMsgDTO.getType())
- .operation(farmMsgDTO.getOperation())
- .title(farmMsgDTO.getTitle())
- .msg(farmMsgDTO.getMsg())
- .userId(getLoginUserId())
- .build();
- logMsgMapper.insert(logMsg);
- }
-
- public FarmMsgDTO assembleMsg(Method method, Object[] objects, Object result){
- String title = "";
- String msg = "";
-
- FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
- if (method.getName().startsWith("get")){
- for (Object object : objects) {
- log.info("after用户{},{},{},{}",getLoginUserId(), farmMsg.type(), farmMsg.title(), object);
- if (farmMsg.type().equals("项目")){
- CommonResult projectDO = (CommonResult) result;
- title = projectDO.getData().getName();
- }
- if (farmMsg.type().equals("任务")){
- CommonResult taskDO = (CommonResult) result;
- ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getData().getProjectId());
- TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getData().getTaskCateId());
- title = project.getName();
- msg = taskCate.getName();
- }
- }
- }
-
- if (method.getName().startsWith("update")){
- for (Object object : objects) {
- if (farmMsg.type().equals("项目")){
- ProjectUpdateReqVO projectDO = (ProjectUpdateReqVO) object;
- title = projectDO.getName();
- }
- if (farmMsg.type().equals("任务")){
- TaskUpdateReqVO taskDO = (TaskUpdateReqVO) object;
- ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
- title = project.getName();
- TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
- msg = taskCate.getName();
- }
- }
- }
-
- if (method.getName().startsWith("create")){
- for (Object object : objects){
- if (farmMsg.type().equals("项目")){
- ProjectCreateReqVO projectDO = (ProjectCreateReqVO) object;
- title = projectDO.getName();
- }
- if (farmMsg.type().equals("任务")){
- TaskCreateReqVO taskDO = (TaskCreateReqVO) object;
- ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
- title = project.getName();
- TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
- msg = taskCate.getName();
- }
- }
- }
-
- FarmMsgDTO farmMsgDTO = FarmMsgDTO.builder()
- .type(farmMsg.type())
- .operation(farmMsg.operation())
- .title(title)
- .msg(msg).build();
- return farmMsgDTO;
- }
+// @AfterReturning(value = "farmMsgPointCut()", returning = "result")
+// public void afterSaveFarmMsg(JoinPoint jointPoint, Object result){
+// //从切入点通过反射获取切入点方法
+// MethodSignature signature = (MethodSignature) jointPoint.getSignature();
+// //获取切入点的方法
+// Method method = signature.getMethod();
+//
+// FarmMsgDTO farmMsgDTO = this.assembleMsg(method, jointPoint.getArgs(), result);
+//
+// //插入农场日志信息
+// LogMsgDO logMsg = LogMsgDO.builder()
+// .type(farmMsgDTO.getType())
+// .operation(farmMsgDTO.getOperation())
+// .title(farmMsgDTO.getTitle())
+// .msg(farmMsgDTO.getMsg())
+// .userId(getLoginUserId())
+// .build();
+// logMsgMapper.insert(logMsg);
+// }
+
+// public FarmMsgDTO assembleMsg(Method method, Object[] objects, Object result){
+// String title = "";
+// String msg = "";
+//
+// FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
+// if (method.getName().startsWith("get")){
+// for (Object object : objects) {
+// log.info("after用户{},{},{},{}",getLoginUserId(), farmMsg.type(), farmMsg.title(), object);
+// if (farmMsg.type().equals("项目")){
+// CommonResult projectDO = (CommonResult) result;
+// title = projectDO.getData().getName();
+// }
+// if (farmMsg.type().equals("任务")){
+// CommonResult taskDO = (CommonResult) result;
+// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getData().getProjectId());
+// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getData().getTaskCateId());
+// title = project.getName();
+// msg = taskCate.getName();
+// }
+// }
+// }
+//
+// if (method.getName().startsWith("update")){
+// for (Object object : objects) {
+// if (farmMsg.type().equals("项目")){
+// ProjectUpdateReqVO projectDO = (ProjectUpdateReqVO) object;
+// title = projectDO.getName();
+// }
+// if (farmMsg.type().equals("任务")){
+// TaskUpdateReqVO taskDO = (TaskUpdateReqVO) object;
+// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
+// title = project.getName();
+// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
+// msg = taskCate.getName();
+// }
+// }
+// }
+//
+// if (method.getName().startsWith("create")){
+// for (Object object : objects){
+// if (farmMsg.type().equals("项目")){
+// ProjectCreateReqVO projectDO = (ProjectCreateReqVO) object;
+// title = projectDO.getName();
+// }
+// if (farmMsg.type().equals("任务")){
+// TaskCreateReqVO taskDO = (TaskCreateReqVO) object;
+// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
+// title = project.getName();
+// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
+// msg = taskCate.getName();
+// }
+// }
+// }
+//
+// FarmMsgDTO farmMsgDTO = FarmMsgDTO.builder()
+// .type(farmMsg.type())
+// .operation(farmMsg.operation())
+// .title(title)
+// .msg(msg).build();
+// return farmMsgDTO;
+// }
}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java
new file mode 100644
index 00000000..b51ad2f7
--- /dev/null
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java
@@ -0,0 +1,20 @@
+package cn.iocoder.yudao.module.farm.annotation;
+
+import lombok.Getter;
+
+@Getter
+public enum FarmMsgType {
+
+ PROJECT,
+ TASK,
+ DISCUSS,
+
+
+ CREATE,
+ UPDATE,
+ SELECT,
+ EDIT,
+ DELETE,
+
+ NONE;
+}
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
index 6ae46294..44dabb84 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.project;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg;
+import cn.iocoder.yudao.module.farm.annotation.FarmMsgType;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import com.zsw.base.R;
@@ -39,7 +40,7 @@ public class ProjectController {
@Resource
private ProjectService projectService;
- @FarmMsg(type = "项目", operation = "创建")
+ @FarmMsg(type = FarmMsgType.PROJECT, operation = FarmMsgType.CREATE)
@PostMapping("/create")
@ApiOperation("创建农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:create')")
@@ -47,7 +48,7 @@ public class ProjectController {
return success(projectService.createProject(createReqVO));
}
- @FarmMsg(type = "项目", operation = "更新")
+ @FarmMsg(type = FarmMsgType.PROJECT, operation = FarmMsgType.UPDATE)
@PutMapping("/update")
@ApiOperation("更新农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:update')")
@@ -56,6 +57,7 @@ public class ProjectController {
return success(true);
}
+ @FarmMsg(type = FarmMsgType.PROJECT,operation = FarmMsgType.DELETE)
@DeleteMapping("/delete")
@ApiOperation("删除农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@@ -65,7 +67,6 @@ public class ProjectController {
return success(true);
}
- @FarmMsg(type = "项目", operation = "查看")
@GetMapping("/get")
@ApiOperation("获得农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
index ebb3a71c..6b4b580d 100644
--- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
@@ -42,7 +42,7 @@ public class TaskController {
@Resource
private TaskService taskService;
- @FarmMsg(type = "任务", operation = "创建")
+// @FarmMsg(type = "任务", operation = "创建")
@PostMapping("/create")
@ApiOperation("创建农场项目")
@PreAuthorize("@ss.hasPermission('farm:task:create')")
@@ -50,7 +50,7 @@ public class TaskController {
return success(taskService.createTask(createReqVO));
}
- @FarmMsg(type = "任务", operation = "更新")
+// @FarmMsg(type = "任务", operation = "更新")
@PutMapping("/update")
@ApiOperation("更新农场项目")
@PreAuthorize("@ss.hasPermission('farm:task:update')")
@@ -68,7 +68,7 @@ public class TaskController {
return success(true);
}
- @FarmMsg(type = "任务", operation = "查看")
+// @FarmMsg(type = "任务", operation = "查看")
@GetMapping("/get")
@ApiOperation("获得农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@@ -124,7 +124,6 @@ public class TaskController {
}
- @FarmMsg(type = "任务", title = "查看任务")
@GetMapping("/appGet")
@ApiOperation("APP查看农场任务详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/WxCpServiceNoticeService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/WxCpServiceNoticeService.java
new file mode 100644
index 00000000..84431a52
--- /dev/null
+++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/WxCpServiceNoticeService.java
@@ -0,0 +1,9 @@
+package cn.iocoder.yudao.module.farm.service;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class WxCpServiceNoticeService {
+
+
+}