Commit 2b73c982 by 孙喜旺

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

2 parents 2866442a e46a8d64
Showing 18 changed files with 142 additions and 60 deletions
package com.linkwechat.web.controller.system; package com.linkwechat.web.controller.system;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.UserConstants; import com.linkwechat.common.constant.UserConstants;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
...@@ -17,19 +18,23 @@ import com.linkwechat.framework.web.service.TokenService; ...@@ -17,19 +18,23 @@ import com.linkwechat.framework.web.service.TokenService;
import com.linkwechat.system.service.ISysPostService; import com.linkwechat.system.service.ISysPostService;
import com.linkwechat.system.service.ISysRoleService; import com.linkwechat.system.service.ISysRoleService;
import com.linkwechat.system.service.ISysUserService; 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.swagger.annotations.ApiOperation;
import io.vertx.ext.auth.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* 用户信息 * 用户信息
* *
* @author ruoyi * @author ruoyi
*/ */
@RestController @RestController
...@@ -48,6 +53,10 @@ public class SysUserController extends BaseController ...@@ -48,6 +53,10 @@ public class SysUserController extends BaseController
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired
private IWeUserService iWeUserService;
/** /**
* 获取用户列表 * 获取用户列表
*/ */
...@@ -56,6 +65,7 @@ public class SysUserController extends BaseController ...@@ -56,6 +65,7 @@ public class SysUserController extends BaseController
public TableDataInfo list(SysUser user) public TableDataInfo list(SysUser user)
{ {
startPage(); startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);
} }
...@@ -193,4 +203,27 @@ public class SysUserController extends BaseController ...@@ -193,4 +203,27 @@ public class SysUserController extends BaseController
user.setUpdateBy(SecurityUtils.getUsername()); user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUserStatus(user)); 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 { ...@@ -53,9 +53,9 @@ public class WeChatCollectionController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('chat:collection:list')") // @PreAuthorize("@ss.hasPermi('chat:collection:list')")
@GetMapping("/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(); startPage();
List<WeChatSideVo> collections = weChatCollectionService.collections(userId); List<WeChatSideVo> collections = weChatCollectionService.collections(userId,keyword);
return getDataTable(collections); return getDataTable(collections);
} }
......
...@@ -16,6 +16,7 @@ import java.util.List; ...@@ -16,6 +16,7 @@ import java.util.List;
/** /**
* 聊天工具侧边栏 * 聊天工具侧边栏
*
* @author kewen * @author kewen
*/ */
@RequestMapping(value = "/wecom/chat/item") @RequestMapping(value = "/wecom/chat/item")
...@@ -41,9 +42,10 @@ public class WeChatItemController extends BaseController { ...@@ -41,9 +42,10 @@ public class WeChatItemController extends BaseController {
*/ */
//@PreAuthorize("@ss.hasPermi('chat:item:list')") //@PreAuthorize("@ss.hasPermi('chat:item:list')")
@GetMapping("/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(); startPage();
List<WeChatSideVo> weChatSideVos = weChatItemService.chatItems(sideId); List<WeChatSideVo> weChatSideVos = weChatItemService.chatItems(sideId,keyword);
return getDataTable(weChatSideVos); return getDataTable(weChatSideVos);
} }
......
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
/** /**
* 聊天工具侧边栏 * 聊天工具侧边栏
*
* @author kewen * @author kewen
*/ */
@RequestMapping(value = "/wecom/chat/side") @RequestMapping(value = "/wecom/chat/side")
...@@ -28,11 +29,11 @@ public class WeChatSideController extends BaseController { ...@@ -28,11 +29,11 @@ public class WeChatSideController extends BaseController {
/** /**
* 群发侧边栏列表 * 群发侧边栏列表
*/ */
// @PreAuthorize("@ss.hasPermi('chat:side:list')") @PreAuthorize("@ss.hasPermi('chat:side:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(@RequestParam(value = "h5") String h5) { public TableDataInfo list() {
startPage(); startPage();
List<WeChatSide> weChatSides = weChatSideService.chatSides(h5); List<WeChatSide> weChatSides = weChatSideService.chatSides("0");
return getDataTable(weChatSides); return getDataTable(weChatSides);
} }
...@@ -46,4 +47,14 @@ public class WeChatSideController extends BaseController { ...@@ -46,4 +47,14 @@ public class WeChatSideController extends BaseController {
return toAjax(weChatSideService.updateWeChatSide(weChatSide)); 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 { ...@@ -87,10 +87,21 @@ public class WeCustomerMessagePushController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('customerMessagePush:push:pushResults')") @PreAuthorize("@ss.hasPermi('customerMessagePush:push:pushResults')")
@GetMapping(value = "/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(); startPage();
List<WeCustomerMessageResultVo> weCustomerMessageResuls = weCustomerMessgaeResultService.customerMessagePushs(messageId, status); List<WeCustomerMessageResultVo> weCustomerMessageResuls = weCustomerMessgaeResultService.customerMessagePushs(messageId, status);
return getDataTable(weCustomerMessageResuls); 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: ...@@ -145,7 +145,7 @@ xss:
# elasticsearch配置 # elasticsearch配置
elasticsearch: elasticsearch:
schema: http schema: http
address: ${ES_ADDRESS:localhost} address: ${ES_ADDRESS:localhost:9200}
connectTimeout: 10000 connectTimeout: 10000
socketTimeout: 10000 socketTimeout: 10000
connectionRequestTimeout: 10000 connectionRequestTimeout: 10000
......
...@@ -120,7 +120,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -120,7 +120,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/wecom/chat/collection/list").anonymous() .antMatchers("/wecom/chat/collection/list").anonymous()
.antMatchers("/wecom/chat/collection/cancleCollection").anonymous() .antMatchers("/wecom/chat/collection/cancleCollection").anonymous()
.antMatchers("/wecom/chat/collection/addCollection").anonymous() .antMatchers("/wecom/chat/collection/addCollection").anonymous()
.antMatchers("/wecom/chat/side/list").anonymous() .antMatchers("/wecom/chat/side/h5List").anonymous()
.antMatchers("/wecom/ticket/**").anonymous() .antMatchers("/wecom/ticket/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
......
...@@ -46,6 +46,6 @@ public interface WeChatCollectionMapper extends BaseMapper<WeChatCollection> { ...@@ -46,6 +46,6 @@ public interface WeChatCollectionMapper extends BaseMapper<WeChatCollection> {
* @param userId 用户id * @param userId 用户id
* @return {@link WeChatSideVo}s * @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; ...@@ -10,12 +10,14 @@ import java.util.List;
/** /**
* 聊天工具侧边栏 * 聊天工具侧边栏
*
* @author kewen * @author kewen
*/ */
public interface WeChatItemMapper extends BaseMapper<WeChatItem> { public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/** /**
* 批量添加侧边栏素材 * 批量添加侧边栏素材
*
* @param items 侧边栏素材列表 * @param items 侧边栏素材列表
* @return 结果 * @return 结果
*/ */
...@@ -23,6 +25,7 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> { ...@@ -23,6 +25,7 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/** /**
* 删除侧边栏素材 * 删除侧边栏素材
*
* @param sideId 侧边栏id * @param sideId 侧边栏id
* @return 结果 * @return 结果
*/ */
...@@ -32,8 +35,9 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> { ...@@ -32,8 +35,9 @@ public interface WeChatItemMapper extends BaseMapper<WeChatItem> {
/** /**
* h5素材列表 * h5素材列表
* *
* @param sideId 侧边栏id * @param sideId 侧边栏id
* @param keyword 关键词
* @return * @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> { ...@@ -37,6 +37,6 @@ public interface IWeChatCollectionService extends IService<WeChatCollection> {
* @param userId 用户id * @param userId 用户id
* @return {@link WeChatSideVo}s * @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> { ...@@ -27,6 +27,6 @@ public interface IWeChatItemService extends IService<WeChatItem> {
* @param sideId 侧边栏id * @param sideId 侧边栏id
* @return * @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 ...@@ -40,4 +40,12 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
*/ */
CustomerMessagePushVo CustomerMessagePushDetail(Long messageId); CustomerMessagePushVo CustomerMessagePushDetail(Long messageId);
/**
* 同步发送结果
*
* @param msgid 可以用于获取发送结果
*/
void asyncResult(String msgid, Long messageId);
} }
...@@ -38,8 +38,8 @@ public class WeChatCollectionServiceImpl extends ServiceImpl<WeChatCollectionMap ...@@ -38,8 +38,8 @@ public class WeChatCollectionServiceImpl extends ServiceImpl<WeChatCollectionMap
} }
@Override @Override
public List<WeChatSideVo> collections(Long userId) { public List<WeChatSideVo> collections(Long userId,String keyword) {
return weChatCollectionMapper.findCollections(userId); return weChatCollectionMapper.findCollections(userId,keyword);
} }
} }
...@@ -96,8 +96,8 @@ public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatI ...@@ -96,8 +96,8 @@ public class WeChatItemServiceImpl extends ServiceImpl<WeChatItemMapper, WeChatI
} }
@Override @Override
public List<WeChatSideVo> chatItems(Long sideId) { public List<WeChatSideVo> chatItems(Long sideId,String keyword) {
return weChatItemMapper.findChatItems(sideId); return weChatItemMapper.findChatItems(sideId,keyword);
} }
/** /**
......
...@@ -59,73 +59,80 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer ...@@ -59,73 +59,80 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
} }
@Override @Override
public CustomerMessagePushVo CustomerMessagePushDetail(Long messageId) { public CustomerMessagePushVo CustomerMessagePushDetail(Long messageId) {
CustomerMessagePushVo customerMessagePushDetail = weCustomerMessageOriginalMapper.findCustomerMessagePushDetail(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();
//拉取发送结果 dataObjectDto.setMsgid(m);
QueryCustomerMessageStatusResultDto queryCustomerMessageStatusResultDto = weCustomerMessagePushClient.queryCustomerMessageStatus(dataObjectDto);
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());
}); //更新微信实际发送条数
weCustomerMessageService.updateWeCustomerMessageActualSend(messageId, atomicInteger.get());
return customerMessagePushDetail;
} }
} }
...@@ -61,7 +61,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -61,7 +61,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
// 上传并返回新文件名称 // 上传并返回新文件名称
fileName = FileUploadUtils.upload(filePath, file); 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); Optional<com.linkwechat.common.enums.MediaType > mediaType = com.linkwechat.common.enums.MediaType .of(type);
if (!mediaType.isPresent()) { if (!mediaType.isPresent()) {
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
LEFT JOIN we_category wc ON wm.category_id = wc.id LEFT JOIN we_category wc ON wm.category_id = wc.id
<where> <where>
wcc.user_id=#{userId} wcc.user_id=#{userId}
<if test="keyword!=null and keyword!=''">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
</where> </where>
</select> </select>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<mapper namespace="com.linkwechat.wecom.mapper.WeChatItemMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeChatItemMapper">
<insert id="addItem"> <insert id="addItem">
INSERT INTO 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 VALUES
<if test="items!=null and items.size()>0"> <if test="items!=null and items.size()>0">
<foreach collection="items" open="(" separator="," item="item" close=")"> <foreach collection="items" open="(" separator="," item="item" close=")">
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
</if> </if>
</insert> </insert>
<delete id="dropItem"> <delete id="dropItem">
DELETE FROM DELETE FROM
we_chat_item we_chat_item
<where> <where>
side_id=#{sideId} side_id=#{sideId}
</where> </where>
</delete> </delete>
<select id="findChatItems" resultType="com.linkwechat.wecom.domain.vo.WeChatSideVo"> <select id="findChatItems" resultType="com.linkwechat.wecom.domain.vo.WeChatSideVo">
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
LEFT JOIN we_category wc ON wm.category_id = wc.id LEFT JOIN we_category wc ON wm.category_id = wc.id
<where> <where>
wci.side_id=#{sideId} wci.side_id=#{sideId}
<if test="keyword!=null and keyword!=''">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!