feat: 一些调整
This commit is contained in:
parent
b7f4aff07d
commit
507b2e085d
|
|
@ -455,13 +455,16 @@ public class TicketController extends ControllerBase {
|
|||
public ApiResult<Void> addChatMessage(@Valid @RequestBody AddChatMessageRequest request) {
|
||||
Ticket ticket = ticketService.getById(request.getTicketId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
|
||||
VUtils.trueThrowBusinessError(Byte.compare(ticket.getState(), TicketState.Processing.getState()) > 1)
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(ticket.getState(), TicketState.Processing.getState()))
|
||||
.throwMessage("当前工单状态不允许发送消息");
|
||||
VUtils.trueThrowBusinessError(Arrays.stream(ticket.getHandle().split(","))
|
||||
.noneMatch(uid -> StrUtil.equals(uid, AdminUserUtil.getUserId().toString())))
|
||||
.throwMessage("只有工单处理人能发送消息");
|
||||
ticket.setCurrentHandle(AdminUserUtil.getUserId());
|
||||
ticketService.updateById(ticket);
|
||||
AdminUser user = adminUserService.getById(AdminUserUtil.getUserId());
|
||||
ChatMessageDTO message = new ChatMessageDTO()
|
||||
.setId(cn.hutool.core.util.IdUtil.getSnowflakeNextId())
|
||||
.setId(cn.hutool.core.util.IdUtil.getSnowflakeNextIdStr())
|
||||
.setFrom("admin")
|
||||
.setTicketState(ticket.getState())
|
||||
.setSenderId(user.getId())
|
||||
|
|
|
|||
|
|
@ -290,9 +290,11 @@ public class TiketController extends ControllerBase {
|
|||
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
|
||||
VUtils.trueThrowBusinessError(Byte.compare(ticket.getState(), TicketState.Processing.getState()) > 1)
|
||||
.throwMessage("当前工单状态不允许发送消息");
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(ticket.getUserId(),AppUserUtil.getUserId()))
|
||||
.throwMessage("工单创建人才能发送消息");
|
||||
AppUser user = appUserService.getById(AppUserUtil.getUserId());
|
||||
ChatMessageDTO message = new ChatMessageDTO()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setId(IdUtil.getSnowflakeNextIdStr())
|
||||
.setFrom("app")
|
||||
.setTicketState(ticket.getState())
|
||||
.setSenderId(user.getId())
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class ChatMessageDTO {
|
||||
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
//来源
|
||||
private String from;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ public class UserDTO {
|
|||
//用户邮箱
|
||||
private String email;
|
||||
|
||||
//是否是主账号
|
||||
private Boolean isPrimary;
|
||||
|
||||
//公司id
|
||||
private List<Integer> companyIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ public class AddChatMessageRequest {
|
|||
private List<String> images;
|
||||
|
||||
// 引用的消息
|
||||
private Long quoteId;
|
||||
private String quoteId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
|
@ -12,4 +13,8 @@ public class AreaSearchRequest extends PageRequest {
|
|||
|
||||
//是否启用
|
||||
private Boolean enabled;
|
||||
|
||||
//区域创建人id
|
||||
@JsonIgnore
|
||||
private Integer createBy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class ChatMessageVO {
|
||||
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
//来源
|
||||
private String from;
|
||||
|
|
|
|||
|
|
@ -27,12 +27,18 @@ public class AppUserUtil {
|
|||
return (List<Integer>) SaTokenAppUtil.getExtra("companyIds");
|
||||
}
|
||||
|
||||
public static Boolean isPrimary() {
|
||||
VUtils.trueThrow(!SaTokenAppUtil.isLogin()).throwMessage(STATE.LoginError,"请重新登录");
|
||||
return (Boolean) SaTokenAppUtil.getExtra("isPrimary");
|
||||
}
|
||||
|
||||
public static UserDTO getUser() {
|
||||
UserDTO user = new UserDTO();
|
||||
user.setId(getUserId());
|
||||
user.setName(getUserName());
|
||||
user.setEmail(getEmail());
|
||||
user.setCompanyIds(getCompanyIds());
|
||||
user.setIsPrimary(isPrimary());
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户端-区域
|
||||
|
|
@ -48,6 +49,11 @@ public class AppArea implements Serializable {
|
|||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Integer createById;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.common.pojo.dto.ChatMessageDTO;
|
||||
import com.nflg.mobilebroken.common.pojo.dto.TicketChatDTO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ChatMessageVO;
|
||||
|
|
@ -69,13 +70,18 @@ public class TicketChatService {
|
|||
public void addMessage(Integer ticketId, ChatMessageDTO newMessage) {
|
||||
// 创建查询条件,查找 ticketId = ticketId 的 TicketChat
|
||||
Query query = new Query(Criteria.where("ticketId").is(ticketId));
|
||||
TicketChatDTO dto=mongoTemplate.findOne(query, TicketChatDTO.class);
|
||||
if (Objects.isNull(dto)){
|
||||
dto=new TicketChatDTO().setTicketId(ticketId);
|
||||
mongoTemplate.save(dto);
|
||||
}
|
||||
// 创建更新操作,向 messages 列表中添加新消息
|
||||
Update update = new Update().push("messages", newMessage);
|
||||
// 执行更新操作
|
||||
mongoTemplate.findAndModify(query, update, TicketChatDTO.class);
|
||||
}
|
||||
|
||||
public ChatMessageDTO getMessage(Integer ticketId, Long messageId) {
|
||||
public ChatMessageDTO getMessage(Integer ticketId, String messageId) {
|
||||
// 构建查询条件
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("ticketId").is(ticketId));
|
||||
|
|
@ -86,7 +92,7 @@ public class TicketChatService {
|
|||
// 从 TicketChatDTO 中提取 ChatMessageDTO
|
||||
if (ticketChat != null) {
|
||||
for (ChatMessageDTO message : ticketChat.getMessages()) {
|
||||
if (messageId.equals(message.getId())) {
|
||||
if (StrUtil.equals(messageId,message.getId())) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ import com.nflg.mobilebroken.common.util.AppUserUtil;
|
|||
import com.nflg.mobilebroken.repository.entity.AppArea;
|
||||
import com.nflg.mobilebroken.repository.mapper.AppAreaMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IAppAreaService;
|
||||
import com.nflg.mobilebroken.repository.service.IAppUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -35,10 +37,14 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class AppAreaServiceImpl extends ServiceImpl<AppAreaMapper, AppArea> implements IAppAreaService {
|
||||
|
||||
@Resource
|
||||
private IAppUserService appUserService;
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(AppArea entity) {
|
||||
if (Objects.isNull(entity.getId()) || entity.getId()<=0){
|
||||
entity.setCreateBy(AppUserUtil.getUserName());
|
||||
entity.setCreateById(AppUserUtil.getUserId());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
return save(entity);
|
||||
}else {
|
||||
|
|
@ -50,12 +56,18 @@ public class AppAreaServiceImpl extends ServiceImpl<AppAreaMapper, AppArea> impl
|
|||
|
||||
@Override
|
||||
public IPage<AreaVO> search(AreaSearchRequest request) {
|
||||
if (AppUserUtil.isPrimary()){
|
||||
request.setCreateBy(AppUserUtil.getUserId());
|
||||
}else {
|
||||
request.setCreateBy(appUserService.getPrimaryByCompanyId(String.valueOf(AppUserUtil.getCompanyIds().get(0))).getId());
|
||||
}
|
||||
if (StrUtil.isBlank(request.getName()) && Objects.isNull(request.getEnabled())) {
|
||||
return getPage(request);
|
||||
}else {
|
||||
LambdaQueryWrapper<AppArea> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(request.getName()),AppArea::getName, request.getName());
|
||||
queryWrapper.eq(AppArea::getCreateById, request.getCreateBy());
|
||||
queryWrapper.eq(Objects.nonNull(request.getEnabled()),AppArea::getEnable, request.getEnabled());
|
||||
queryWrapper.like(StrUtil.isNotBlank(request.getName()),AppArea::getName, request.getName());
|
||||
queryWrapper.orderByDesc(AppArea::getId);
|
||||
List<AppArea> list = baseMapper.selectList(queryWrapper);
|
||||
//找出非根节点
|
||||
|
|
@ -175,7 +187,9 @@ public class AppAreaServiceImpl extends ServiceImpl<AppAreaMapper, AppArea> impl
|
|||
IPage<AppArea> page = new Page<>();
|
||||
page.setCurrent(request.getPage());
|
||||
page.setSize(request.getPageSize());
|
||||
lambdaQuery().eq(AppArea::getParentId, 0)
|
||||
lambdaQuery()
|
||||
.eq(AppArea::getParentId, 0)
|
||||
.eq(AppArea::getCreateById,request.getCreateBy())
|
||||
.eq(Objects.nonNull(request.getEnabled()), AppArea::getEnable, request.getEnabled())
|
||||
.orderByAsc(AppArea::getId)
|
||||
.page(page);
|
||||
|
|
@ -190,7 +204,8 @@ public class AppAreaServiceImpl extends ServiceImpl<AppAreaMapper, AppArea> impl
|
|||
}
|
||||
|
||||
private List<AreaVO> getChildren(Integer parentId, Boolean enable) {
|
||||
List<AreaVO> datas=convert(lambdaQuery().eq(AppArea::getParentId,parentId)
|
||||
List<AreaVO> datas=convert(lambdaQuery()
|
||||
.eq(AppArea::getParentId,parentId)
|
||||
.eq(Objects.nonNull(enable), AppArea::getEnable, enable)
|
||||
.orderByAsc(AppArea::getId)
|
||||
.list());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.nflg.mobilebroken.starter.config;
|
||||
|
||||
import com.aliyun.oss.ClientBuilderConfiguration;
|
||||
import com.aliyun.oss.ClientConfiguration;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
|
||||
|
|
@ -30,13 +30,16 @@ public class AliyunOSSConfig {
|
|||
//@Resource
|
||||
//private OSS ossClient;
|
||||
|
||||
@Bean
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public OSS ossClient() {
|
||||
log.info("初始化阿里云OSS服务");
|
||||
ClientConfiguration config = new ClientConfiguration();
|
||||
config.setConnectionTimeout(10000); // 设置连接超时为 10 秒
|
||||
config.setSocketTimeout(600000); // 设置读取超时为 10 分钟
|
||||
return OSSClientBuilder.create()
|
||||
.endpoint(endpoint)
|
||||
.credentialsProvider(new DefaultCredentialProvider(accessKeyId, accessKeySecret))
|
||||
.clientConfiguration(new ClientBuilderConfiguration())
|
||||
.clientConfiguration(config)
|
||||
.region(region)
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue