feat: 问答库发消息
This commit is contained in:
@@ -208,3 +208,8 @@ ALTER TABLE `laws_overseas_standard`
|
||||
ADD COLUMN `associated_domestic_standards` varchar(1) NULL COMMENT '关联国内标准';
|
||||
|
||||
INSERT INTO `laws_tag` (`id`, `table_name`, `db_field_name`, `db_field_en_name`, `db_field_txt`, `order_num`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_show_form_create`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`, `show_area`, `is_show_laws_list`, `is_show_search`, `del_flag`, `is_model`, `dict_id`, `home_search_context_order`, `home_search_file_order`, `dict_field_search`, `dict_table_search`, `dict_text_search`, `usable_range`, `tree_first_href`) VALUES ('1722802933703528452', 'laws_overseas_standard', 'associated_domestic_standards', 'Associated domestic standards', '关联国内标准', 28, 'associated_domestic_standards', 0, 1, 'String', 1, NULL, NULL, NULL, NULL, NULL, '6', NULL, NULL, NULL, '0', NULL, NULL, 1, 0, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, '2023-11-10 10:26:42', 'zx-test', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '1694630711725498369', NULL, 1, 0, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- 2024-08-16 回答模板
|
||||
INSERT INTO sys_sms_template (id, template_code, template_name, template_content, template_type, create_by, create_time) VALUES ('1824272435207028738', 'laws_problem_library_answer', '【问答库】新回答', '您好,在 ${standardNumber} ${standardName} 的 ${title} 中有新回答,请前往标准法规管理系统或研发大前台标准法规管理模块问答库进行查看。', '5,4,6', 'admin', '2024-08-16 10:30:16')
|
||||
INSERT INTO sys_sms_template (id, template_code, template_name, template_content, template_type, create_by, create_time) VALUES ('1824275060971274242', 'laws_problem_library_answer_top', '【问答库】有新的回答被置顶', '您好,在 ${standardNumber} ${standardName} 的 ${title} 中,有新的回答已被置顶,请前往标准法规管理系统或研发大前台标准法规管理模块问答库进行查看。', '4,5,6', 'admin', '2024-08-16 10:40:42')
|
||||
|
||||
|
||||
+2
@@ -11,6 +11,8 @@ public class MessageTemplateCodeCommon {
|
||||
|
||||
public static final String LAWS_NEWS_FEED = "laws_news_feed"; // 【动态消息】通知
|
||||
public static final String LAWS_PROBLEM_LIBRARY = "laws_problem_library"; // 【问答库】回答已置顶
|
||||
public static final String LAWS_PROBLEM_LIBRARY_ANSWER = "laws_problem_library_answer"; // 【问答库】管理员后起草人回答
|
||||
public static final String LAWS_PROBLEM_LIBRARY_ANSWER_TOP = "laws_problem_library_answer_top"; // 【问答库】被置顶后提醒发帖人
|
||||
public static final String NEW_MODEL_IMPLEMENTATION = "new_model_implementation"; // 【新车型实施预警】
|
||||
public static final String ON_THE_PRODUCTION = "on_the_production"; // 【在产车实施预警】
|
||||
public static final String LAWS_STANDARD_SHARING = "laws_standard_sharing"; // 【分享】收到分享
|
||||
|
||||
+70
-16
@@ -4,11 +4,15 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.SendMessageAPI;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.laws.common.constant.DictCommon;
|
||||
import com.jero.common.api.vo.SendMessageAPI;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.laws.common.constant.MessageTemplateCodeCommon;
|
||||
import com.jero.modules.laws.common.service.ILawsCommonService;
|
||||
import com.jero.modules.laws.common.vo.ManyStandardSelectionBox;
|
||||
@@ -17,9 +21,10 @@ import com.jero.modules.laws.library.entity.LawsProblemLibrary;
|
||||
import com.jero.modules.laws.library.mapper.LawsProblemLibraryMapper;
|
||||
import com.jero.modules.laws.library.service.ILawsAnswerLibraryService;
|
||||
import com.jero.modules.laws.library.service.ILawsProblemLibraryService;
|
||||
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
||||
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
||||
import com.jero.modules.sys.utils.UserUtils;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
@@ -31,20 +36,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.management.relation.Role;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,6 +71,9 @@ public class LawsProblemLibraryServiceImpl extends ServiceImpl<LawsProblemLibrar
|
||||
@Value("${adminRoleCode}")
|
||||
private String adminRoleCode;
|
||||
|
||||
@Resource
|
||||
private ILawsEnterpriseStandardService esService;
|
||||
|
||||
@Override
|
||||
public IPage<LawsProblemLibrary> queryPage(LawsProblemLibrary lawsProblemLibrary, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
@@ -146,6 +145,18 @@ public class LawsProblemLibraryServiceImpl extends ServiceImpl<LawsProblemLibrar
|
||||
updateWrapper.set(LawsProblemLibrary::getIsAnswer, 1);
|
||||
updateWrapper.eq(LawsProblemLibrary::getId, lawsAnswerLibrary.getProblemId());
|
||||
update(updateWrapper);
|
||||
|
||||
// 判断回答的是否是标准管理员或者标准起草人 如果是的话发消息
|
||||
boolean sendMsg = loginUser.getRoleIds().contains("BZGLY");
|
||||
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||
esWrapper.eq(LawsEnterpriseStandard::getId, problem.getStandardId());
|
||||
List<LawsEnterpriseStandard> list = esService.list(esWrapper);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
sendMsg = true;
|
||||
}
|
||||
if (sendMsg) {
|
||||
sendMsgAnswer(lawsAnswerLibrary, problem.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,8 +264,8 @@ public class LawsProblemLibraryServiceImpl extends ServiceImpl<LawsProblemLibrar
|
||||
// 如果是管理员权限 则跳过验证
|
||||
List<String> adminRoleList = Arrays.asList(adminRoleCode.split(","));
|
||||
// 如果不是管理员权限 且不是问题创建者 且不是回答创建者 则没有权限
|
||||
LawsProblemLibrary problem = getById(lawsAnswerLibrary.getProblemId());
|
||||
if (adminRoleList.stream().noneMatch(userRoleList::contains)) {
|
||||
LawsProblemLibrary problem = getById(lawsAnswerLibrary.getProblemId());
|
||||
if (!currentUser.getUsername().equals(problem.getCreateBy())) {
|
||||
throw new JeroBootException(ResultCommon.NO_PERMISSION);
|
||||
}
|
||||
@@ -264,6 +275,9 @@ public class LawsProblemLibraryServiceImpl extends ServiceImpl<LawsProblemLibrar
|
||||
lawsAnswerLibrary.setIsTop(1);
|
||||
// 发送消息
|
||||
sendMsg(lawsAnswerLibrary);
|
||||
if (!currentUser.getUsername().equals(problem.getCreateBy())) {
|
||||
sendMsgTop(lawsAnswerLibrary, problem.getUserId());
|
||||
}
|
||||
} else {
|
||||
lawsAnswerLibrary.setIsTop(0);
|
||||
}
|
||||
@@ -291,4 +305,44 @@ public class LawsProblemLibraryServiceImpl extends ServiceImpl<LawsProblemLibrar
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/10 15:15
|
||||
* @Description: 发送消息
|
||||
**/
|
||||
private void sendMsgAnswer(LawsAnswerLibrary lawsAnswerLibrary, String userId) {
|
||||
log.info("lawsAnswerLibrary.getProblemId()的id为:{}", lawsAnswerLibrary.getProblemId());
|
||||
LawsProblemLibrary lawsProblemLibrary = getById(lawsAnswerLibrary.getProblemId());
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
sendMessageDTO.setTemplateCode(MessageTemplateCodeCommon.LAWS_PROBLEM_LIBRARY_ANSWER);
|
||||
sendMessageDTO.setToUserId(userId);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("standardNumber", lawsProblemLibrary.getStandardNumber());
|
||||
map.put("standardName", lawsProblemLibrary.getStandardName());
|
||||
map.put("title", lawsProblemLibrary.getTitle());
|
||||
map.put("openType", "url");
|
||||
log.info("openPage:{}", "/businessSupport/questionDetail?id=" + lawsAnswerLibrary.getProblemId() + "&canAnswer=1");
|
||||
map.put("openPage", "/businessSupport/questionDetail?id=" + lawsAnswerLibrary.getProblemId() + "&canAnswer=1");
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
}
|
||||
|
||||
|
||||
private void sendMsgTop(LawsAnswerLibrary lawsAnswerLibrary, String userId) {
|
||||
log.info("lawsAnswerLibrary.getProblemId()的id为:{}", lawsAnswerLibrary.getProblemId());
|
||||
LawsProblemLibrary lawsProblemLibrary = getById(lawsAnswerLibrary.getProblemId());
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
sendMessageDTO.setTemplateCode(MessageTemplateCodeCommon.LAWS_PROBLEM_LIBRARY_ANSWER_TOP);
|
||||
sendMessageDTO.setToUserId(userId);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("standardNumber", lawsProblemLibrary.getStandardNumber());
|
||||
map.put("standardName", lawsProblemLibrary.getStandardName());
|
||||
map.put("title", lawsProblemLibrary.getTitle());
|
||||
map.put("openType", "url");
|
||||
log.info("openPage:{}", "/businessSupport/questionDetail?id=" + lawsAnswerLibrary.getProblemId() + "&canAnswer=1");
|
||||
map.put("openPage", "/businessSupport/questionDetail?id=" + lawsAnswerLibrary.getProblemId() + "&canAnswer=1");
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user