Commit 122f107c authored by xiweicheng's avatar xiweicheng
Browse files

文件定位消息

Showing with 95 additions and 2 deletions
+95 -2
......@@ -68,6 +68,7 @@ import com.lhjz.portal.model.Mail;
import com.lhjz.portal.model.Poll;
import com.lhjz.portal.model.RespBody;
import com.lhjz.portal.model.ToastrPayload;
import com.lhjz.portal.model.UuidBody;
import com.lhjz.portal.pojo.Enum.Action;
import com.lhjz.portal.pojo.Enum.ChatLabelType;
import com.lhjz.portal.pojo.Enum.ChatMsgType;
......@@ -1844,4 +1845,32 @@ public class ChatChannelController extends BaseController {
return RespBody.succeed(id);
}
@GetMapping("get/by/uuid")
@ResponseBody
public RespBody getByUuid(@RequestParam("uuid") String uuid) {
ChatChannel chatChannel = chatChannelRepository.findTopByUuid(uuid);
if (chatChannel == null) {
ChatReply chatReply = chatReplyRepository.findTopByUuid(uuid);
if (chatReply == null) {
ChatDirect chatDirect = chatDirectRepository.findTopByUuid(uuid);
if (AuthUtil.hasChannelAuth(chatDirect)) {
return RespBody.succeed(UuidBody.builder().type("chatDirect").chatDirect(chatDirect).build());
}
} else if (AuthUtil.hasChannelAuth(chatReply)) {
return RespBody.succeed(UuidBody.builder().type("chatReply").chatReply(chatReply)
.chatChannel(chatReply.getChatChannel()).build());
}
} else if (AuthUtil.hasChannelAuth(chatChannel)) {
return RespBody.succeed(UuidBody.builder().type("chatChannel").chatChannel(chatChannel).build());
}
return RespBody.failed("您没有权限查看该消息内容!");
}
}
/**
* 版权所有 (TMS)
*/
package com.lhjz.portal.model;
import com.lhjz.portal.entity.ChatChannel;
import com.lhjz.portal.entity.ChatDirect;
import com.lhjz.portal.entity.ChatReply;
import lombok.Builder;
import lombok.Data;
/**
*
* @author xi
*
* @date 2016年5月20日 下午8:38:54
*
*/
@Data
@Builder
public class UuidBody {
private String type;
private ChatChannel chatChannel;
private ChatDirect chatDirect;
private ChatReply chatReply;
}
......@@ -96,4 +96,6 @@ public interface ChatChannelRepository extends JpaRepository<ChatChannel, Long>
ChatChannel findTopByChannelAndNoticeAndStatusNotOrderByUpdateDateDesc(Channel channel, Boolean notice, Status status);
ChatChannel findTopByUuid(String uuid);
}
......@@ -87,4 +87,6 @@ public interface ChatDirectRepository extends JpaRepository<ChatDirect, Long> {
@Query(value = "SELECT * FROM chat_direct WHERE creator = ?1 AND (upper(content) LIKE upper(?2))", nativeQuery = true)
List<ChatDirect> queryByCreatorAndContentLike(String creator, String contentLike);
ChatDirect findTopByUuid(String uuid);
}
......@@ -30,4 +30,6 @@ public interface ChatReplyRepository extends JpaRepository<ChatReply, Long> {
Page<ChatReply> findByChatChannelAndTypeAndStatusNot(ChatChannel chatChannel, ChatReplyType type, Status status,
Pageable pageable);
ChatReply findTopByUuid(String uuid);
}
......@@ -5,6 +5,8 @@ import java.util.Set;
import com.lhjz.portal.constant.SysConstant;
import com.lhjz.portal.entity.Channel;
import com.lhjz.portal.entity.ChatChannel;
import com.lhjz.portal.entity.ChatDirect;
import com.lhjz.portal.entity.ChatReply;
import com.lhjz.portal.entity.Space;
import com.lhjz.portal.entity.SpaceAuthority;
import com.lhjz.portal.entity.security.User;
......@@ -31,6 +33,15 @@ public class AuthUtil {
return isSuperOrCreator(creator.getUsername());
}
public static boolean hasChannelAuth(ChatReply cr) {
if (cr == null) {
return false;
}
return hasChannelAuth(cr.getChatChannel());
}
public static boolean hasChannelAuth(ChatChannel cc) {
if (cc == null) {
......@@ -57,7 +68,7 @@ public class AuthUtil {
User loginUser = new User(WebUtil.getUsername());
return c.getMembers().contains(loginUser);
}
public static boolean isChannelMember(Channel c) {
if (c == null) {
......@@ -67,7 +78,7 @@ public class AuthUtil {
User loginUser = new User(WebUtil.getUsername());
return c.getMembers().contains(loginUser);
}
public static boolean hasSpaceAuth(Space s) {
if (s == null) {
......@@ -117,4 +128,19 @@ public class AuthUtil {
return exists;
}
public static boolean hasChannelAuth(ChatDirect chatDirect) {
if (chatDirect == null) {
return false;
}
if (isSuperOrCreator(chatDirect.getCreator().getUsername())) {
return true;
}
User loginUser = new User(WebUtil.getUsername());
return chatDirect.getChatTo().equals(loginUser);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment