Merge branch 'master' of http://192.168.0.105:10010/r/jfptht-publicSecurity
5 files modified
7 files added
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | |
| | | /** |
| | | * 生日 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | private Date birthday; |
| | | /** |
| | | * 性别 |
| | |
| | | @PostMapping("/AppSave") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入attendance") |
| | | public R AppSave(@Valid Attendance attendance) { |
| | | public R AppSave(@Valid Attendance attendance,HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | System.out.println("attendance = " + attendance); |
| | | Enclosure enclosure = new Enclosure(); |
| | | enclosure.setAnumber(attendance.getNumber()); |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.jfpt.chatrecords.entity.ChatRecords; |
| | | import org.springblade.jfpt.chatrecords.service.ChatRecordsService; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springblade.system.user.feign.IUserClient; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * @time 2021-06-18 |
| | | * 聊天消息控制层 |
| | | */ |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/chat-records") |
| | | public class ChatRecordsController { |
| | | |
| | | private final IUserClient iUserClient; |
| | | |
| | | private final ChatRecordsService chatRecordsService; |
| | | |
| | | /** |
| | | * 查询单聊消息记录 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param response 响应 |
| | | * @param query 查询条件,分页 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getSingleMessagePage") |
| | | public R getSingleMessagePage(@Valid ChatRecords chatRecords, HttpServletResponse response, Query query){ |
| | | //跨域设置 |
| | | crossDomain(response); |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | //查询单聊人的信息 |
| | | List<User> user = Arrays.asList(iUserClient.userInfoById(chatRecords.getSenderId()).getData(), iUserClient.userInfoById(chatRecords.getRecipientId()).getData()); |
| | | //查询单聊记录信息 |
| | | IPage<ChatRecords> chatRecordsIPage = chatRecordsService.selectChatRecordsPage(Condition.getPage(query), chatRecords); |
| | | //封装数据 |
| | | map.put("user",user); |
| | | map.put("chatRecordsIPage",chatRecordsIPage); |
| | | //返回数据 |
| | | return R.data(map); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询当前用户的聊天列表 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param response 响应 |
| | | * @param query 查询条件,分页 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getChatListPage") |
| | | public R getChatListPage(@Valid ChatRecords chatRecords, HttpServletResponse response, Query query){ |
| | | //跨域设置 |
| | | crossDomain(response); |
| | | //查询当前人员的聊天列表,并返回数据 |
| | | return R.data(chatRecordsService.getChatListPage(Condition.getPage(query), chatRecords)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 单聊消息插入 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param response 响应 |
| | | * @return |
| | | */ |
| | | @PostMapping("/insertSingleChat") |
| | | public R insertSingleChat(@Valid @RequestBody ChatRecords chatRecords, HttpServletResponse response){ |
| | | //跨域设置 |
| | | crossDomain(response); |
| | | //单聊消息插入 |
| | | return R.data(chatRecordsService.save(chatRecords)); |
| | | } |
| | | |
| | | /** |
| | | * 配置跨域设置 |
| | | * @param response |
| | | */ |
| | | private void crossDomain(HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * |
| | | * @author zhongrj |
| | | * @time 2021-06-18 |
| | | * @desc 聊天记录实体类 |
| | | * |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_chat_records") |
| | | public class ChatRecords implements Serializable { |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 发送消息内容 |
| | | */ |
| | | @TableField("post_message") |
| | | private String postMessage; |
| | | |
| | | /** |
| | | * 消息类型 0 文本 1 表情 2 图片 3 视频... |
| | | */ |
| | | @TableField("message_type") |
| | | private Integer messageType; |
| | | |
| | | /** |
| | | * 接收状态 0 已接收 1 未接收 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 发送时间 |
| | | */ |
| | | @TableField("post_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date postTime; |
| | | |
| | | /** |
| | | * 发送消息人id |
| | | * |
| | | */ |
| | | @NotNull(message = "发送消息人id不能为空") |
| | | @TableField("sender_id") |
| | | private Long senderId; |
| | | |
| | | /** |
| | | * 接收消息人id |
| | | * @NotNull(message = "接收消息人id不能为空") |
| | | */ |
| | | @TableField("recipient_id") |
| | | private Long recipientId; |
| | | |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.jfpt.article.entity.Article; |
| | | import org.springblade.jfpt.article.vo.ArticleVo; |
| | | import org.springblade.jfpt.chatrecords.entity.ChatRecords; |
| | | import org.springblade.jfpt.chatrecords.vo.ChatRecordsVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * mapper 映射层 |
| | | */ |
| | | public interface ChatRecordsMapper extends BaseMapper<ChatRecords> { |
| | | |
| | | /** |
| | | * 查询单聊消息记录分页信息 |
| | | * @param page |
| | | * @param chatRecords 聊天消息对象 |
| | | * @return |
| | | */ |
| | | List<ChatRecords> selectChatRecordsPage(IPage<ChatRecords> page, ChatRecords chatRecords); |
| | | |
| | | /** |
| | | * 查询当前用户的聊天列表 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param page |
| | | * @return |
| | | */ |
| | | List<ChatRecordsVo> getChatListPage(IPage<ChatRecordsVo> page, ChatRecords chatRecords); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.jfpt.chatrecords.mapper.ChatRecordsMapper"> |
| | | |
| | | <!--查询单聊的消息记录列表--> |
| | | <select id="selectChatRecordsPage" resultType="org.springblade.jfpt.chatrecords.entity.ChatRecords"> |
| | | select * from sys_chat_records where sender_id = #{chatRecords.senderId} and recipient_id = #{chatRecords.recipientId} |
| | | union |
| | | select * from sys_chat_records where sender_id = #{chatRecords.recipientId} and recipient_id = #{chatRecords.senderId} |
| | | order by post_time desc |
| | | </select> |
| | | |
| | | <!--聊天列表--> |
| | | <select id="getChatListPage" resultType="org.springblade.jfpt.chatrecords.vo.ChatRecordsVo"> |
| | | select scrss.*,name recipientNickName,real_name recipientName,avatar from jfpthpublicsecurity.blade_user bu |
| | | right join |
| | | ( |
| | | select scr.id,scrs.uid recipientId,post_time postTime,post_message postMessage from sys_chat_records scr |
| | | right join |
| | | ( |
| | | select max(max_id) id,uid from ( |
| | | select recipient_id as uid,max(id) as max_id from sys_chat_records where sender_id = #{chatRecords.senderId} group by recipient_id |
| | | union all |
| | | select sender_id as uid,max(id) as max_id from sys_chat_records where recipient_id = #{chatRecords.senderId} group by sender_id |
| | | )t group by uid |
| | | ) scrs |
| | | on |
| | | scr.id = scrs.id |
| | | ) scrss |
| | | on |
| | | bu.id = scrss.recipientId |
| | | order by postTime desc |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.jfpt.chatrecords.entity.ChatRecords; |
| | | import org.springblade.jfpt.chatrecords.vo.ChatRecordsVo; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * 聊天消息接口层 |
| | | */ |
| | | public interface ChatRecordsService extends IService<ChatRecords> { |
| | | |
| | | /** |
| | | * 查询聊天消息分页信息 |
| | | * @param page |
| | | * @param chatRecords 聊天消息对象 |
| | | * @return |
| | | */ |
| | | IPage<ChatRecords> selectChatRecordsPage(IPage<ChatRecords> page, ChatRecords chatRecords); |
| | | |
| | | /** |
| | | * 查询当前用户的聊天列表 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param page |
| | | * @return |
| | | */ |
| | | IPage<ChatRecordsVo> getChatListPage(IPage<ChatRecordsVo> page, ChatRecords chatRecords); |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.jfpt.chatrecords.entity.ChatRecords; |
| | | import org.springblade.jfpt.chatrecords.mapper.ChatRecordsMapper; |
| | | import org.springblade.jfpt.chatrecords.service.ChatRecordsService; |
| | | import org.springblade.jfpt.chatrecords.vo.ChatRecordsVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | */ |
| | | @Service |
| | | public class ChatRecordsServiceImpl extends ServiceImpl<ChatRecordsMapper, ChatRecords> implements ChatRecordsService { |
| | | |
| | | /** |
| | | * 查询聊天消息分页信息 |
| | | * @param page |
| | | * @param chatRecords 聊天消息对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<ChatRecords> selectChatRecordsPage(IPage<ChatRecords> page, ChatRecords chatRecords) { |
| | | return page.setRecords(baseMapper.selectChatRecordsPage(page,chatRecords)); |
| | | } |
| | | |
| | | /** |
| | | * 查询当前用户的聊天列表 |
| | | * @param chatRecords 消息记录对象 |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<ChatRecordsVo> getChatListPage(IPage<ChatRecordsVo> page, ChatRecords chatRecords) { |
| | | return page.setRecords(baseMapper.getChatListPage(page,chatRecords)); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.chatrecords.vo; |
| | | |
| | | import lombok.Data; |
| | | import org.springblade.jfpt.chatrecords.entity.ChatRecords; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * @time 2021-06-19 |
| | | * @desc 聊天列表vo |
| | | */ |
| | | @Data |
| | | public class ChatRecordsVo extends ChatRecords implements Serializable { |
| | | /** |
| | | * 接收或者发送的昵称 |
| | | */ |
| | | private String recipientNickName; |
| | | |
| | | /** |
| | | * 接收或者发送的姓名 |
| | | */ |
| | | private String recipientName; |
| | | |
| | | /** |
| | | * 接收或者发送的头像 url |
| | | */ |
| | | private String avatar; |
| | | |
| | | } |
| | |
| | | public R update(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | |
| | | if (user.getOnline_status().equals("") || user.getOnline_status() == null){ |
| | | if (user.getOnline_status() == null || user.getOnline_status().equals("")){ |
| | | user.setOnline_status("0"); |
| | | } |
| | | if (user.getWork_status().equals("") || user.getWork_status() == null){ |
| | | if (user.getWork_status() == null || user.getWork_status().equals("")){ |
| | | user.setWork_status("0"); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "修改基本信息", notes = "传入User") |
| | | public R updateInfo(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | String avatar = user.getAvatar(); |
| | | String substring = avatar.substring(25, avatar.length()); |
| | | String url="https://web.byisf.com/minio"+substring; |
| | | user.setAvatar(url); |
| | | if (null!= user.getAvatar() && user.getAvatar()!="") { |
| | | String avatar = user.getAvatar(); |
| | | String substring = avatar.substring(25, avatar.length()); |
| | | String url = "https://web.byisf.com/minio" + substring; |
| | | user.setAvatar(url); |
| | | } |
| | | return R.status(userService.updateUserInfo(user)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改用户基本信息,不修改用户密码 |
| | | * @param user 用户信息 |
| | | * @autor zhongrj |
| | | * @time 2021-06-16 |
| | | */ |
| | | @PostMapping("/updateUserInfo") |
| | | public R updateUserInfo(@Valid @RequestBody User user) { |
| | | CacheUtil.clear(USER_CACHE); |
| | | return R.status(userService.updateUserInfos(user)); |
| | | } |
| | | |
| | | /** |
| | | * 用户列表 |
| | | */ |
| | |
| | | * @return |
| | | */ |
| | | User selUserByCode(String code); |
| | | |
| | | /** |
| | | * 修改用户基本信息,不修改用户密码 |
| | | * @param user 用户信息 |
| | | * @autor zhongrj |
| | | * @time 2021-06-16 |
| | | */ |
| | | boolean updateUserInfos(User user); |
| | | } |
| | |
| | | public User selUserByCode(String code) { |
| | | return baseMapper.selUserByCode(code); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户基本信息,不修改用户密码 |
| | | * @param user 用户信息 |
| | | * @autor zhongrj |
| | | * @time 2021-06-16 |
| | | */ |
| | | @Override |
| | | public boolean updateUserInfos(User user) { |
| | | return updateById(user); |
| | | } |
| | | } |