提交 2b73c982 编写于 作者: 孙喜旺

Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev

package com.linkwechat.web.controller.system;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.UserConstants;
import com.linkwechat.common.core.controller.BaseController;
......@@ -17,19 +18,23 @@ import com.linkwechat.framework.web.service.TokenService;
import com.linkwechat.system.service.ISysPostService;
import com.linkwechat.system.service.ISysRoleService;
import com.linkwechat.system.service.ISysUserService;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.service.IWeUserService;
import io.swagger.annotations.ApiOperation;
import io.vertx.ext.auth.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户信息
*
*
* @author ruoyi
*/
@RestController
......@@ -48,6 +53,10 @@ public class SysUserController extends BaseController
@Autowired
private TokenService tokenService;
@Autowired
private IWeUserService iWeUserService;
/**
* 获取用户列表
*/
......@@ -56,6 +65,7 @@ public class SysUserController extends BaseController
public TableDataInfo list(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
......@@ -193,4 +203,27 @@ public class SysUserController extends BaseController
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUserStatus(user));
}
@GetMapping("/findCurrentLoginUser")
public AjaxResult findCurrentLoginUser(HttpServletRequest request){
String userId="";
LoginUser loginUser = tokenService.getLoginUser(request);
if(null != loginUser){
SysUser user = loginUser.getUser();
if(null != user){
List<WeUser> weUsers = iWeUserService.selectWeUserList(WeUser.builder()
.mobile(user.getPhonenumber())
.build());
if(CollectionUtil.isNotEmpty(weUsers)){
userId=weUsers.get(0).getUserId();
}
}
}
return AjaxResult.success(userId);
}
}
......@@ -53,9 +53,9 @@ public class WeChatCollectionController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('chat:collection:list')")
@GetMapping("/list")
public TableDataInfo list(@RequestParam(value = "userId") Long userId) {
public TableDataInfo list(@RequestParam(value = "userId") Long userId,@RequestParam(value = "keyword",required = false) String keyword) {
startPage();
List<WeChatSideVo> collections = weChatCollectionService.collections(userId);
List<WeChatSideVo> collections = weChatCollectionService.collections(userId,keyword);
return getDataTable(collections);
}
......
......@@ -16,6 +16,7 @@ import java.util.List;
/**
* 聊天工具侧边栏
*
* @author kewen
*/
@RequestMapping(value = "/wecom/chat/item")
......@@ -41,9 +42,10 @@ public class WeChatItemController extends BaseController {
*/
//@PreAuthorize("@ss.hasPermi('chat:item:list')")
@GetMapping("/list")
public TableDataInfo list(@RequestParam(value = "sideId") Long sideId) {
public TableDataInfo list(@RequestParam(value = "sideId") Long sideId
, @RequestParam(value = "keyword", required = false) String keyword) {
startPage();
List<WeChatSideVo> weChatSideVos = weChatItemService.chatItems(sideId);
List<WeChatSideVo> weChatSideVos = weChatItemService.chatItems(sideId,keyword);
return getDataTable(weChatSideVos);
}
......
......@@ -15,6 +15,7 @@ import java.util.List;
/**
* 聊天工具侧边栏
*
* @author kewen
*/
@RequestMapping(value = "/wecom/chat/side")
......@@ -28,11 +29,11 @@ public class WeChatSideController extends BaseController {
/**
* 群发侧边栏列表
*/
// @PreAuthorize("@ss.hasPermi('chat:side:list')")
@PreAuthorize("@ss.hasPermi('chat:side:list')")
@GetMapping("/list")
public TableDataInfo list(@RequestParam(value = "h5") String h5) {
public TableDataInfo list() {
startPage();
List<WeChatSide> weChatSides = weChatSideService.chatSides(h5);
List<WeChatSide> weChatSides = weChatSideService.chatSides("0");
return getDataTable(weChatSides);
}
......@@ -46,4 +47,14 @@ public class WeChatSideController extends BaseController {
return toAjax(weChatSideService.updateWeChatSide(weChatSide));
}
/**
* 群发侧边栏列表
*/
@GetMapping("/h5List")
public TableDataInfo h5List() {
startPage();
List<WeChatSide> weChatSides = weChatSideService.chatSides("1");
return getDataTable(weChatSides);
}
}
......@@ -87,10 +87,21 @@ public class WeCustomerMessagePushController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('customerMessagePush:push:pushResults')")
@GetMapping(value = "/pushResults")
public TableDataInfo customerMessagePushResult(@RequestParam(value = "messageId") Long messageId,@RequestParam(value = "status") String status){
public TableDataInfo customerMessagePushResult(@RequestParam(value = "messageId") Long messageId, @RequestParam(value = "status") String status) {
startPage();
List<WeCustomerMessageResultVo> weCustomerMessageResuls = weCustomerMessgaeResultService.customerMessagePushs(messageId, status);
return getDataTable(weCustomerMessageResuls);
}
/**
* 同步消息发送结果
*/
@PreAuthorize("@ss.hasPermi('customerMessagePush:push:asyncResult')")
@PostMapping(value = "asyncResult")
public AjaxResult asyncResult(@RequestParam(value = "msgid") String msgid, @RequestParam(value = "messageId") Long messageId) {
weCustomerMessageOriginalService.asyncResult(msgid, messageId);
return AjaxResult.success();
}
}
......@@ -145,7 +145,7 @@ xss:
# elasticsearch配置
elasticsearch:
schema: http
address: ${ES_ADDRESS:localhost}
address: ${ES_ADDRESS:localhost:9200}
connectTimeout: 10000
socketTimeout: 10000
connectionRequestTimeout: 10000
......
......@@ -120,7 +120,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/wecom/chat/collection/list").anonymous()
.antMatchers("/wecom/chat/collection/cancleCollection").anonymous()
.antMatchers("/wecom/chat/collection/addCollection").anonymous()
.antMatchers("/wecom/chat/side/list").anonymous()
.antMatchers("/wecom/chat/side/h5List").anonymous()
.antMatchers("/wecom/ticket/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证
......
......@@ -46,6 +46,6 @@ public interface WeChatCollectionMapper extends BaseMapper<WeChatCollection> {
* @param userId 用户id
* @return {@link WeChatSideVo}s
*/
public List<WeChatSideVo> findCollections(Long userId);
public List<WeChatSideVo> findCollections(@Param("userId") Long userId,@Param("keyword") String keyword);
}
......@@ -10,12 +10,14 @@ import java.util.List;
/**
* 聊天工具侧边栏
*
* @author kewen
*/
public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/**
* 批量添加侧边栏素材
*
* @param items 侧边栏素材列表
* @return 结果
*/
......@@ -23,6 +25,7 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/**
* 删除侧边栏素材
*
* @param sideId 侧边栏id
* @return 结果
*/
......@@ -32,8 +35,9 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/**
* h5素材列表
*
* @param sideId 侧边栏id
* @param sideId 侧边栏id
* @param keyword 关键词
* @return
*/
public List<WeChatSideVo> findChatItems(@Param("sideId") Long sideId);
public List<WeChatSideVo> findChatItems(@Param("sideId") Long sideId, @Param("keyword") String keyword);
}
......@@ -37,6 +37,6 @@ public interface IWeChatCollectionService extends IService<WeChatCollection> {
* @param userId 用户id
* @return {@link WeChatSideVo}s
*/
public List<WeChatSideVo> collections(Long userId);
public List<WeChatSideVo> collections(Long userId,String keyword);
}
......@@ -27,6 +27,6 @@ public interface IWeChatItemService extends IService<WeChatItem> {
* @param sideId 侧边栏id
* @return
*/
public List<WeChatSideVo> chatItems(Long sideId);
public List<WeChatSideVo> chatItems(Long sideId,String keyword);
}
......@@ -40,4 +40,12 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
*/
CustomerMessagePushVo CustomerMessagePushDetail(Long messageId);
/**
* 同步发送结果
*
* @param msgid 可以用于获取发送结果
*/
void asyncResult(String msgid, Long messageId);
}
......@@ -38,8 +38,8 @@ public class WeChatCollectionServiceImpl extends ServiceImpl<WeChatCollectionMap
}
@Override
public List<WeChatSideVo> collections(Long userId) {
return weChatCollectionMapper.findCollections(userId);
public List<WeChatSideVo> collections(Long userId,String keyword) {
return weChatCollectionMapper.findCollections(userId,keyword);
}
}
......@@ -96,8 +96,8 @@ public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatI
}
@Override
public List<WeChatSideVo> chatItems(Long sideId) {
return weChatItemMapper.findChatItems(sideId);
public List<WeChatSideVo> chatItems(Long sideId,String keyword) {
return weChatItemMapper.findChatItems(sideId,keyword);
}
/**
......
......@@ -59,73 +59,80 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
}
@Override
public CustomerMessagePushVo CustomerMessagePushDetail(Long messageId) {
public CustomerMessagePushVo CustomerMessagePushDetail(Long messageId) {
CustomerMessagePushVo customerMessagePushDetail = weCustomerMessageOriginalMapper.findCustomerMessagePushDetail(messageId);
AtomicInteger atomicInteger=new AtomicInteger();
//拉取消息发送结果
CompletableFuture.runAsync(()->{
CompletableFuture.runAsync(() -> syncSendResult(customerMessagePushDetail.getMsgid(), messageId));
return customerMessagePushDetail;
}
@Override
public void asyncResult(String msgid, Long messageId) {
syncSendResult(msgid, messageId);
}
String msgid = customerMessagePushDetail.getMsgid();
public void syncSendResult(String msgid, Long messageId) {
if(StringUtils.isNotEmpty(msgid)){
AtomicInteger atomicInteger = new AtomicInteger();
List<String> msgIds = null;
if (StringUtils.isNotEmpty(msgid)) {
try {
List<String> msgIds = null;
msgIds = objectMapper.readValue(msgid,new TypeReference<List<String>>() { });
try {
} catch (JsonProcessingException e) {
msgIds = objectMapper.readValue(msgid, new TypeReference<List<String>>() {
});
e.printStackTrace();
} catch (JsonProcessingException e) {
}
e.printStackTrace();
if(CollectionUtils.isNotEmpty(msgIds)){
}
msgIds.forEach(m->{
if (CollectionUtils.isNotEmpty(msgIds)) {
QueryCustomerMessageStatusResultDataObjectDto dataObjectDto=new QueryCustomerMessageStatusResultDataObjectDto();
msgIds.forEach(m -> {
dataObjectDto.setMsgid(m);
QueryCustomerMessageStatusResultDataObjectDto dataObjectDto = new QueryCustomerMessageStatusResultDataObjectDto();
//拉取发送结果
QueryCustomerMessageStatusResultDto queryCustomerMessageStatusResultDto = weCustomerMessagePushClient.queryCustomerMessageStatus(dataObjectDto);
dataObjectDto.setMsgid(m);
if (WeConstans.WE_SUCCESS_CODE.equals(queryCustomerMessageStatusResultDto.getErrcode())) {
//拉取发送结果
QueryCustomerMessageStatusResultDto queryCustomerMessageStatusResultDto = weCustomerMessagePushClient.queryCustomerMessageStatus(dataObjectDto);
if (WeConstans.WE_SUCCESS_CODE.equals(queryCustomerMessageStatusResultDto.getErrcode())) {
List<DetailMessageStatusResultDto> detailList = queryCustomerMessageStatusResultDto.getDetail_list();
detailList.forEach(d-> {
List<DetailMessageStatusResultDto> detailList = queryCustomerMessageStatusResultDto.getDetail_list();
if(d.getStatus().equals("1")){
detailList.forEach(d -> {
atomicInteger.incrementAndGet();
if (d.getStatus().equals("1")) {
}
atomicInteger.incrementAndGet();
weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId,d.getChat_id(),d.getExternal_userid(),d.getStatus(),d.getSend_time());
}
});
weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId, d.getChat_id(), d.getExternal_userid(), d.getStatus(), d.getSend_time());
}
});
});
}
}
});
}
//更新微信实际发送条数
weCustomerMessageService.updateWeCustomerMessageActualSend(messageId,atomicInteger.get());
}
});
return customerMessagePushDetail;
//更新微信实际发送条数
weCustomerMessageService.updateWeCustomerMessageActualSend(messageId, atomicInteger.get());
}
}
......@@ -61,7 +61,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
// 上传并返回新文件名称
fileName = FileUploadUtils.upload(filePath, file);
}
String url = serverConfig.getUrl() + fileName;
String url = fileName;
//上传临时素材
Optional<com.linkwechat.common.enums.MediaType > mediaType = com.linkwechat.common.enums.MediaType .of(type);
if (!mediaType.isPresent()) {
......
......@@ -36,6 +36,9 @@
LEFT JOIN we_category wc ON wm.category_id = wc.id
<where>
wcc.user_id=#{userId}
<if test="keyword!=null and keyword!=''">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
</where>
</select>
......
......@@ -5,7 +5,7 @@
<mapper namespace="com.linkwechat.wecom.mapper.WeChatItemMapper">
<insert id="addItem">
INSERT INTO
we_chat_item(item_id,side_id,material_id,create_by,create_time,update_by,update_time)
we_chat_item(item_id,side_id,material_id,create_by,create_time,update_by,update_time)
VALUES
<if test="items!=null and items.size()>0">
<foreach collection="items" open="(" separator="," item="item" close=")">
......@@ -14,11 +14,11 @@
</if>
</insert>
<delete id="dropItem">
DELETE FROM
we_chat_item
<where>
side_id=#{sideId}
</where>
DELETE FROM
we_chat_item
<where>
side_id=#{sideId}
</where>
</delete>
<select id="findChatItems" resultType="com.linkwechat.wecom.domain.vo.WeChatSideVo">
......@@ -34,6 +34,9 @@
LEFT JOIN we_category wc ON wm.category_id = wc.id
<where>
wci.side_id=#{sideId}
<if test="keyword!=null and keyword!=''">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册