| | |
| | | package com.ycl.service.message.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.mail.javamail.JavaMailSenderImpl; |
| | | import org.springframework.mail.javamail.MimeMessageHelper; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | sendMessage.setTargetTo(receive); |
| | | sendMessage.setSendTime(new Date()); |
| | | sendMessage.setPhoneNumber(umsAdminMapper.selectById(receive).getMobile()); |
| | | if (ChannelCode.INNER.equals(message.getChannelCode())){ |
| | | if (ChannelCode.INNER.equals(message.getChannelCode())) { |
| | | sendMessage.setIsView(0); |
| | | } |
| | | this.save(sendMessage); |
| | |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | HttpEntity<String> stringHttpEntity = new HttpEntity<>(Base64Utils.encodeToString(objectMapper.writeValueAsBytes(mac)), httpHeaders); |
| | | |
| | | SendRes sendRes = objectMapper.readValue(restTemplate.postForEntity(url, stringHttpEntity, String.class).getBody(), SendRes.class); |
| | | ResponseEntity<String> response = restTemplate.postForEntity(url + "/sms/submit", sendReq, String.class); |
| | | SendRes sendRes = objectMapper.readValue(response.getBody(), SendRes.class); |
| | | if (sendRes.getRspcod().equals("success")) { |
| | | return 2; |
| | | } else { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Page<Message> queryMyMessage(Page<Message> page, Long userId) { |
| | | List<Message> list = list(); |
| | | ArrayList<Long> ids = new ArrayList<>(); |
| | | list.forEach(item -> { |
| | | String targetTo = item.getTargetTo(); |
| | | if (StringUtils.isNotBlank(targetTo)) { |
| | | String[] split = targetTo.split(","); |
| | | for (String s : split) { |
| | | if (userId.equals(Long.getLong(s))) { |
| | | ids.add(item.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return new Page<>(); |
| | | } |
| | | return baseMapper.selectPage(page, new QueryWrapper<Message>().lambda().in(Message::getId, ids)); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteMessages(List<Long> ids) { |
| | | LambdaQueryWrapper<Message> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(Message::getId, ids).or().in(Message::getParentId, ids); |