diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/common/CommonController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/common/CommonController.java index 07f42e14685ef38a2ce2cda23ddf3d4a9b4ec871..c0deb36aa6a68d1c5fe7550b19408d156ceb9e26 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/common/CommonController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/common/CommonController.java @@ -1,5 +1,6 @@ package com.linkwechat.web.controller.common; +import com.linkwechat.common.config.CosConfig; import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.ServerConfig; import com.linkwechat.common.constant.Constants; @@ -30,6 +31,9 @@ public class CommonController { @Autowired private ServerConfig serverConfig; + @Autowired + private CosConfig cosConfig; + /** * 通用下载请求 * @@ -104,4 +108,29 @@ public class CommonController { public void webResourceDownload(String url, HttpServletRequest request, HttpServletResponse response) throws Exception { FileUtils.downloadFile(url, response.getOutputStream()); } + + + /** + * 通用上传请求 + */ + @PostMapping("/common/uploadFile2Cos") + public AjaxResult uploadFile2Cos(MultipartFile file) throws Exception { + try { + + String fileName = FileUploadUtils.upload2Cos(file, cosConfig); + + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + ajax.put("url", url(fileName)); + return ajax; + } catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } + } + + + public String url(String fileName){ + return "https://link-wechat-1251309172.cos.ap-nanjing.myqcloud.com/"+fileName; + } + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java index b9bdd43d137ede96b711235a4fe2bdd3b985daa2..53304c6bcc75851323efb0cd9097830a4068af71 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java @@ -52,6 +52,8 @@ public class SysLoginController @Autowired private WeAccessTokenClient weAccessTokenClient; +// @Autowired +// private IWeGroupCodeService weGroupCodeService; /** @@ -157,5 +159,32 @@ public class SysLoginController } +// /** +// * 从群活码获取第一个可用的实际码 +// */ +// @GetMapping("/getChatQRCode") +// public AjaxResult getActual(Long weGroupCodeId) { +// WeGroupCode weGroupCode = weGroupCodeService.selectWeGroupCodeById(weGroupCodeId); +// List weGroupCodeActualList = weGroupCodeService.selectActualListByGroupCodeId(weGroupCodeId); +// WeGroupCodeActual weGroupCodeActual = null; +// for (WeGroupCodeActual item : weGroupCodeActualList) { +// // 获取第一个可用的实际码 +// if (item.getStatus().intValue() == WeConstans.WE_GROUP_CODE_ENABLE) { +// weGroupCodeActual = item; +// break; +// } +// } +// if (StringUtils.isNotNull(weGroupCodeActual)) { +// AjaxResult ajax = AjaxResult.success(); +// ajax.put("tipMsg", weGroupCode.getTipMsg()); +// ajax.put("activityName", weGroupCode.getActivityName()); +// ajax.put("groupName", weGroupCodeActual.getChatGroupName()); +// ajax.put("actualQRCode", weGroupCodeActual.getActualGroupQrCode()); +// return ajax; +// } else { +// return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); +// } +// } + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysUserController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysUserController.java index 41c2c59c94c06d845bad23cd6e3706937a615769..5c982aa01239c3267becb8b0a87f56c68a69db77 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysUserController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysUserController.java @@ -1,5 +1,6 @@ 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 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 weUsers = iWeUserService.selectWeUserList(WeUser.builder() + .mobile(user.getPhonenumber()) + .build()); + if(CollectionUtil.isNotEmpty(weUsers)){ + userId=weUsers.get(0).getUserId(); + + } + } + + } + return AjaxResult.success(userId); + } + + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java index 88ab9acf9d73b150f28381148cd3be977cf29c29..9118d14f2bb47be529eebd00e79bfb8f4eb5d406 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java @@ -1,6 +1,7 @@ package com.linkwechat.web.controller.wecom; import com.alibaba.fastjson.JSONObject; +import com.linkwechat.common.utils.Threads; import com.linkwechat.common.utils.wecom.WxCryptUtil; import com.linkwechat.web.controller.common.CommonController; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; @@ -36,7 +37,7 @@ public class WeCallBackController extends CommonController { @Value("${wecome.callBack.encodingAesKey}") private String encodingAesKey; - @PostMapping(value = "/recive", produces = {"application/xml;charset=UTF-8"}) + @PostMapping(value = "/recive") public String recive(@RequestBody String msg, @RequestParam(name = "msg_signature") String signature, String timestamp, String nonce) { WxCryptUtil wxCryptUtil = new WxCryptUtil(token, encodingAesKey, appIdOrCorpId); @@ -47,7 +48,7 @@ public class WeCallBackController extends CommonController { try { WeCallBackEventFactory factory = weEventHandle.factory(wxCpXmlMessage.getEvent()); if (factory !=null){ - factory.eventHandle(wxCpXmlMessage); + Threads.SINGLE_THREAD_POOL.submit(() -> factory.eventHandle(wxCpXmlMessage)); } } catch (Exception e) { e.printStackTrace(); @@ -60,7 +61,7 @@ public class WeCallBackController extends CommonController { } } - @GetMapping(value = "/recive", produces = {"application/xml;charset=UTF-8"}) + @GetMapping(value = "/recive") public String recive(HttpServletRequest request) { // 微信加密签名 String sVerifyMsgSig = request.getParameter("msg_signature"); diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatCollectionController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatCollectionController.java index a7881640b30f3c06e71f1de765fe6e51ac647849..293cb70bbbaf6b4538bd76e10cc7bf4370045c73 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatCollectionController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatCollectionController.java @@ -5,6 +5,7 @@ import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.wecom.domain.dto.WeChatCollectionDto; import com.linkwechat.wecom.domain.vo.WeChatSideVo; import com.linkwechat.wecom.service.IWeChatCollectionService; import org.springframework.beans.factory.annotation.Autowired; @@ -30,32 +31,32 @@ public class WeChatCollectionController extends BaseController { /** * 添加收藏 */ - @PreAuthorize("@ss.hasPermi('chat:collection:add')") + //@PreAuthorize("@ss.hasPermi('chat:collection:add')") @Log(title = "添加收藏", businessType = BusinessType.INSERT) - @PutMapping("addCollection") - public AjaxResult addCollection(@RequestParam(value = "materialId") Long materialId,@RequestParam(value = "userId") Long userId) { - return toAjax(weChatCollectionService.addCollection(materialId, userId)); + @PostMapping("addCollection") + public AjaxResult addCollection(@RequestBody WeChatCollectionDto chatCollectionDto) { + return toAjax(weChatCollectionService.addCollection(chatCollectionDto.getMaterialId(), chatCollectionDto.getUserId())); } /** * 取消收藏 */ - @PreAuthorize("@ss.hasPermi('chat:collection:delete')") - @Log(title = "取消收藏", businessType = BusinessType.UPDATE) + // @PreAuthorize("@ss.hasPermi('chat:collection:delete')") + // @Log(title = "取消收藏", businessType = BusinessType.UPDATE) @PostMapping(value = "cancleCollection") - public AjaxResult cancleCollection(@RequestParam(value = "materialId") Long materialId,@RequestParam(value = "userId") Long userId) { - return toAjax(weChatCollectionService.cancleCollection(materialId, userId)); + public AjaxResult cancleCollection(@RequestBody WeChatCollectionDto chatCollectionDto) { + return toAjax(weChatCollectionService.cancleCollection(chatCollectionDto.getMaterialId(), chatCollectionDto.getUserId())); } /** * 收藏列表 */ - @PreAuthorize("@ss.hasPermi('chat:collection:list')") + // @PreAuthorize("@ss.hasPermi('chat:collection:list')") @GetMapping("/list") - public TableDataInfo list(@RequestParam(value = "userId") Long userId) { + public TableDataInfo list(@RequestParam(value = "userId") String userId,@RequestParam(value = "keyword",required = false) String keyword) { startPage(); - List collections = weChatCollectionService.collections(userId); + List collections = weChatCollectionService.collections(userId,keyword); return getDataTable(collections); } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatItemController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatItemController.java index 16054e37e3519d3a81dcf2986a583bd6883e6385..48ce25946ccd5d1479ad89957014317502b77458 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatItemController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatItemController.java @@ -16,6 +16,7 @@ import java.util.List; /** * 聊天工具侧边栏 + * * @author kewen */ @RequestMapping(value = "/wecom/chat/item") @@ -30,7 +31,7 @@ public class WeChatItemController extends BaseController { * 侧边栏抓取素材 */ @PreAuthorize("@ss.hasPermi('chat:item:add')") - @Log(title = "侧边栏抓取素材", businessType = BusinessType.INSERT) + // @Log(title = "侧边栏抓取素材", businessType = BusinessType.INSERT) @PutMapping public AjaxResult add(@RequestBody WeChatItemDto chatItemDto) { return toAjax(weChatItemService.checkItems(chatItemDto)); @@ -39,11 +40,12 @@ public class WeChatItemController extends BaseController { /** * h5素材列表 */ - @PreAuthorize("@ss.hasPermi('chat:item:list')") + //@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,@RequestParam(value = "mediaType") String mediaType,@RequestParam(value = "userId") String userId) { startPage(); - List weChatSideVos = weChatItemService.chatItems(sideId); + List weChatSideVos = weChatItemService.chatItems(sideId,keyword,mediaType,userId); return getDataTable(weChatSideVos); } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatSideController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatSideController.java index 0c37fff9f0fc7ba8e9238aeb304b249b48e73b1d..db41bb0fae480d7b34bbcde14de7217121ac176e 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatSideController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeChatSideController.java @@ -15,6 +15,7 @@ import java.util.List; /** * 聊天工具侧边栏 + * * @author kewen */ @RequestMapping(value = "/wecom/chat/side") @@ -30,9 +31,9 @@ public class WeChatSideController extends BaseController { */ @PreAuthorize("@ss.hasPermi('chat:side:list')") @GetMapping("/list") - public TableDataInfo list(@RequestParam(value = "h5") String h5) { + public TableDataInfo list() { startPage(); - List weChatSides = weChatSideService.chatSides(h5); + List 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 weChatSides = weChatSideService.chatSides("1"); + return getDataTable(weChatSides); + } + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCommunityNewGroupController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCommunityNewGroupController.java new file mode 100644 index 0000000000000000000000000000000000000000..b6a88c0061cdcf514f19f631105fe868fb56f981 --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCommunityNewGroupController.java @@ -0,0 +1,104 @@ +package com.linkwechat.web.controller.wecom; + +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.exception.wecom.WeComException; +import com.linkwechat.common.utils.StringUtils; +import com.linkwechat.wecom.domain.WeCommunityNewGroup; +import com.linkwechat.wecom.domain.WeEmpleCode; +import com.linkwechat.wecom.domain.dto.WeCommunityNewGroupDto; +import com.linkwechat.wecom.domain.vo.WeCommunityNewGroupVo; +import com.linkwechat.wecom.service.IWeCommunityNewGroupService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 社群运营 新客自动拉群 Controller + * + * @author kewen + * @date 2021-02-19 + */ +@Controller +@RequestMapping(value = "communityNewGroup") +public class WeCommunityNewGroupController extends BaseController { + + @Autowired + private IWeCommunityNewGroupService weCommunityNewGroupService; + + /** + * 查询新客自动拉群列表 + */ + @PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:list')") + @GetMapping("/list") + public TableDataInfo list(WeCommunityNewGroup communityNewGroup) { + startPage(); + List communityNewGroupVos = weCommunityNewGroupService.selectWeCommunityNewGroupList(communityNewGroup); + return getDataTable(communityNewGroupVos); + } + + /** + * 获取新客自动拉群详细信息 + */ + @PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("newGroupId") Long newGroupId) { + return AjaxResult.success(weCommunityNewGroupService.selectWeCommunityNewGroupById(newGroupId)); + } + + /** + * 修改新客自动拉群 + */ + @PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:edit')") + @Log(title = "新客自动拉群", businessType = BusinessType.UPDATE) + @PutMapping("/update") + public AjaxResult edit(@RequestBody @Validated WeCommunityNewGroupDto communityNewGroupDto) { + weCommunityNewGroupService.updateWeCommunityNewGroup(communityNewGroupDto); + + return AjaxResult.success(); + } + + /** + * 删除新客自动拉群 + */ + @PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:remove')") + @Log(title = "新客自动拉群", businessType = BusinessType.DELETE) + @DeleteMapping("/delete/{ids}") + public AjaxResult remove(@PathVariable String ids) { + List idList = Arrays.stream(StringUtils.split(ids, ",")).collect(Collectors.toList()); + return toAjax(weCommunityNewGroupService.batchRemoveWeCommunityNewGroupIds(idList)); + } + + + /** + * 新增新客自动拉群 + */ + @PreAuthorize("@ss.hasPermi('wecom:communityNewGroup:add')") + @Log(title = "新客自动拉群", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody @Validated WeCommunityNewGroupDto communityNewGroupDto) { + try { + weCommunityNewGroupService.add(communityNewGroupDto); + return AjaxResult.success(); + } catch (Exception e) { + e.printStackTrace(); + if (e instanceof WeComException){ + return AjaxResult.error(e.getMessage()); + }else { + return AjaxResult.error("请求接口异常!"); + } + } + + } + + +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java index be966d2c8e5cc6df038edf026b9608c1772a1096..17369c3443709150666770f6018c1daff81adb05 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeConversationArchiveController.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** - * @author sxw + * @author danmo * @description 会话存档controller * @date 2020/12/19 13:51 **/ diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java index 588fba812c127ffaca26e0a706b59a5e45a3c821..0b30ae7b632fb3ded51fa9c82c8f84a72b64a5c6 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerMessagePushController.java @@ -6,6 +6,7 @@ import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.wecom.domain.dto.message.AsyncResultDto; import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo; import com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo; @@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; import java.util.List; /** @@ -49,7 +51,7 @@ public class WeCustomerMessagePushController extends BaseController { public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) { try { weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto); - } catch (JsonProcessingException e) { + } catch (JsonProcessingException | ParseException e) { e.printStackTrace(); return AjaxResult.error("群发失败"); } @@ -87,10 +89,20 @@ 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 weCustomerMessageResuls = weCustomerMessgaeResultService.customerMessagePushs(messageId, status); return getDataTable(weCustomerMessageResuls); } + /** + * 同步消息发送结果 + */ + @PreAuthorize("@ss.hasPermi('customerMessagePush:push:asyncResult')") + @PostMapping(value = "asyncResult") + public AjaxResult asyncResult(@RequestBody AsyncResultDto asyncResultDto) throws JsonProcessingException { + weCustomerMessageOriginalService.asyncResult(asyncResultDto); + return AjaxResult.success(); + } + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeActualController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeActualController.java index 0398f284b5eccba744ce413d2472891dadfe17cf..d0cb07bf03e9bb603c82ffb5d9e917ca76ca57d6 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeActualController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeActualController.java @@ -1,39 +1,43 @@ package com.linkwechat.web.controller.wecom; import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.constant.HttpStatus; import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.StringUtils; import com.linkwechat.wecom.domain.WeGroupCodeActual; import com.linkwechat.wecom.service.IWeGroupCodeActualService; 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 java.util.List; + /** * 实际群码Controller - * + * * @author ruoyi * @date 2020-10-07 */ @RestController @RequestMapping("/wecom/actual") -public class WeGroupCodeActualController extends BaseController -{ +public class WeGroupCodeActualController extends BaseController { @Autowired private IWeGroupCodeActualService weGroupCodeActualService; -// /** -// * 查询实际群码列表 -// */ -// @PreAuthorize("@ss.hasPermi('wecom:actual:list')") -// @GetMapping("/list") -// public TableDataInfo list(WeGroupCodeActual weGroupCodeActual) -// { -// startPage(); -// List list = weGroupCodeActualService.selectWeGroupCodeActualList(weGroupCodeActual); -// return getDataTable(list); -// } + /** + * 查询实际群码列表 + */ + @PreAuthorize("@ss.hasPermi('wecom:actual:list')") + @GetMapping("/list") + public TableDataInfo list(WeGroupCodeActual weGroupCodeActual) { + startPage(); + List list = weGroupCodeActualService.selectWeGroupCodeActualList(weGroupCodeActual); + return getDataTable(list); + } // // /** // * 导出实际群码列表 @@ -47,27 +51,32 @@ public class WeGroupCodeActualController extends BaseController // ExcelUtil util = new ExcelUtil(WeGroupCodeActual.class); // return util.exportExcel(list, "actual"); // } -// -// /** -// * 获取实际群码详细信息 -// */ -// @PreAuthorize("@ss.hasPermi('wecom:actual:query')") -// @GetMapping(value = "/{id}") -// public AjaxResult getInfo(@PathVariable("id") Long id) -// { -// return AjaxResult.success(weGroupCodeActualService.selectWeGroupCodeActualById(id)); -// } /** - * 新增实际群码 + * 获取实际群码详细信息 + */ + @PreAuthorize("@ss.hasPermi('wecom:actual:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + WeGroupCodeActual weGroupCodeActual = weGroupCodeActualService.selectWeGroupCodeActualById(id); + if (StringUtils.isNull(weGroupCodeActual)) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + return AjaxResult.success(weGroupCodeActual); + } + + /** + * 新增实际群码查询 */ @PreAuthorize("@ss.hasPermi('wecom:actual:add')") @Log(title = "实际群码", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody WeGroupCodeActual weGroupCodeActual) - { - weGroupCodeActualService.save(weGroupCodeActual); - return AjaxResult.success(); + public AjaxResult add(@Validated @RequestBody WeGroupCodeActual weGroupCodeActual) { + // 唯一性检查 + if (!weGroupCodeActualService.checkChatIdUnique(weGroupCodeActual)) { + return AjaxResult.error("新增实际群码失败, 该群聊二维码已存在"); + } + return toAjax(weGroupCodeActualService.insertWeGroupCodeActual(weGroupCodeActual)); } /** @@ -76,20 +85,26 @@ public class WeGroupCodeActualController extends BaseController @PreAuthorize("@ss.hasPermi('wecom:actual:edit')") @Log(title = "实际群码", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody WeGroupCodeActual weGroupCodeActual) - { - weGroupCodeActualService.updateById(weGroupCodeActual); - return AjaxResult.success(); + public AjaxResult edit(@RequestBody WeGroupCodeActual weGroupCodeActual) { + WeGroupCodeActual original = weGroupCodeActualService.selectWeGroupCodeActualById(weGroupCodeActual.getId()); + if (StringUtils.isNull(original)) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + // 实际码对应客户群变化时,检查其唯一性 + if (!original.getChatId().equals(weGroupCodeActual.getChatId()) && + !weGroupCodeActualService.checkChatIdUnique(weGroupCodeActual)) { + return AjaxResult.error("修改实际群码失败, 该群聊二维码已存在"); + } + return toAjax(weGroupCodeActualService.updateWeGroupCodeActual(weGroupCodeActual)); } -// /** -// * 删除实际群码 -// */ -// @PreAuthorize("@ss.hasPermi('wecom:actual:remove')") -// @Log(title = "实际群码", businessType = BusinessType.DELETE) -// @DeleteMapping("/{ids}") -// public AjaxResult remove(@PathVariable Long[] ids) -// { -// return toAjax(weGroupCodeActualService.deleteWeGroupCodeActualByIds(ids)); -// } + /** + * 删除实际群码 + */ + @PreAuthorize("@ss.hasPermi('wecom:actual:remove')") + @Log(title = "实际群码", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(weGroupCodeActualService.deleteWeGroupCodeActualByIds(ids)); + } } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeController.java index 76bd2742893b0bd3d52681924ac35548c4e0224c..2f77bd264bdb3be20f7a2a9f9abca39fd79195d5 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupCodeController.java @@ -1,41 +1,109 @@ package com.linkwechat.web.controller.wecom; +import cn.hutool.core.collection.CollectionUtil; import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.constant.HttpStatus; import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.SecurityUtils; +import com.linkwechat.common.utils.StringUtils; +import com.linkwechat.common.utils.file.FileUtils; import com.linkwechat.wecom.domain.WeGroupCode; +import com.linkwechat.wecom.domain.WeGroupCodeActual; import com.linkwechat.wecom.service.IWeGroupCodeService; 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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + /** * 客户群活码Controller - * + * * @author ruoyi * @date 2020-10-07 */ @RestController @RequestMapping("/wecom/groupCode") -public class WeGroupCodeController extends BaseController -{ +public class WeGroupCodeController extends BaseController { @Autowired private IWeGroupCodeService weGroupCodeService; -// /** -// * 查询客户群活码列表 -// */ -// @PreAuthorize("@ss.hasPermi('wecom:code:list')") -// @GetMapping("/list") -// public TableDataInfo list(WeGroupCode weGroupCode) -// { -// startPage(); -// List list = weGroupCodeService.selectWeGroupCodeList(weGroupCode); -// return getDataTable(list); -// } -// + /** + * 查询客户群活码列表 + */ + @PreAuthorize("@ss.hasPermi('wecom:groupCode:list')") + @GetMapping("/list") + public TableDataInfo list(WeGroupCode weGroupCode) { + startPage(); + List list = weGroupCodeService.selectWeGroupCodeList(weGroupCode); + return getDataTable(list); + } + + /** + * 批量下载群活码 + */ + @PreAuthorize("@ss.hasPermi('wecom:groupCode:downloadBatch')") + @Log(title = "群活码批量下载", businessType = BusinessType.OTHER) + @GetMapping("/downloadBatch") + public void downloadBatch(String ids, HttpServletRequest request, HttpServletResponse response) { + List idList = Arrays.stream(Optional.ofNullable(ids).orElse("").split(",")) + .filter(StringUtils::isNotEmpty).collect(Collectors.toList()); + try { + List weGroupCodeList = weGroupCodeService.selectWeGroupCodeListByIds(idList); + ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); + if (CollectionUtil.isNotEmpty(weGroupCodeList)) { + for (WeGroupCode weGroupCode : weGroupCodeList) { + String codeUrl = weGroupCode.getCodeUrl(); + if (StringUtils.isEmpty(codeUrl)) { + continue; + } + URL url = new URL(codeUrl); + String fileName = weGroupCode.getActivityName() + ".png"; + zos.putNextEntry(new ZipEntry(fileName)); + InputStream fis = url.openConnection().getInputStream(); + byte[] buffer = new byte[1024]; + int r = 0; + while ((r = fis.read(buffer)) != -1) { + zos.write(buffer, 0, r); + } + fis.close(); + } + } + //关闭zip输出流 + zos.flush(); + zos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @PreAuthorize("@ss.hasPermi('wecom:groupCode:download')") + @Log(title = "群活码下载", businessType = BusinessType.OTHER) + @GetMapping("/download") + public void download(String id, HttpServletRequest request, HttpServletResponse response) { + WeGroupCode weGroupCode = weGroupCodeService.selectWeGroupCodeById(Long.valueOf(id)); + try { + FileUtils.downloadFile(weGroupCode.getCodeUrl(), response.getOutputStream()); + } catch (IOException e) { + e.printStackTrace(); + } + } + // /** // * 导出客户群活码列表 // */ @@ -49,39 +117,68 @@ public class WeGroupCodeController extends BaseController // return util.exportExcel(list, "code"); // } -// /** -// * 获取客户群活码详细信息 -// */ -// @PreAuthorize("@ss.hasPermi('wecom:code:query')") -// @GetMapping(value = "/{id}") -// public AjaxResult getInfo(@PathVariable("id") Long id) -// { -// return AjaxResult.success(weGroupCodeService.selectWeGroupCodeById(id)); -// } + /** + * 获取客户群活码详细信息 + */ + @PreAuthorize("@ss.hasPermi('wecom:groupCode:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + WeGroupCode weGroupCode = weGroupCodeService.selectWeGroupCodeById(id); + if (StringUtils.isNull(weGroupCode)) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + List weGroupCodeActualList = weGroupCodeService.selectActualListByGroupCodeId(weGroupCode.getId()); + weGroupCode.setActualList(weGroupCodeActualList); + return AjaxResult.success(weGroupCode); + } /** * 新增客户群活码 */ - @PreAuthorize("@ss.hasPermi('wecom:code:add')") + @PreAuthorize("@ss.hasPermi('wecom:groupCode:add')") @Log(title = "客户群活码", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody WeGroupCode weGroupCode) - { + public AjaxResult add(@Validated @RequestBody WeGroupCode weGroupCode) { + // 唯一性检查 + if (!weGroupCodeService.checkActivityNameUnique(weGroupCode)) { + return AjaxResult.error("添加群活码失败,活码名称 " + weGroupCode.getActivityName() + " 已存在"); + } + AjaxResult ajax = AjaxResult.success(); + weGroupCode.setCreateBy(SecurityUtils.getUsername()); weGroupCodeService.insertWeGroupCode(weGroupCode); - return AjaxResult.success(); + ajax.put("id", weGroupCode.getId()); + return ajax; } /** * 修改客户群活码 */ - @PreAuthorize("@ss.hasPermi('wecom:code:edit')") + @PreAuthorize("@ss.hasPermi('wecom:groupCode:edit')") @Log(title = "客户群活码", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody WeGroupCode weGroupCode) - { - weGroupCodeService.updateWeGroupCode(weGroupCode); + @PutMapping(value = "/{id}") + public AjaxResult edit(@PathVariable("id") Long id, @RequestBody WeGroupCode weGroupCode) { + WeGroupCode originalCode = weGroupCodeService.selectWeGroupCodeById(id); + if (StringUtils.isNull(originalCode)) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + // 唯一性检查 + if (!originalCode.getActivityName().equals(weGroupCode.getActivityName()) && + !weGroupCodeService.checkActivityNameUnique(weGroupCode)) { + return AjaxResult.error("修改群活码失败,活码名称 " + weGroupCode.getActivityName() + " 已存在"); + } + weGroupCode.setId(id); + weGroupCode.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(weGroupCodeService.updateWeGroupCode(weGroupCode)); + } - return AjaxResult.success(); + /** + * 删除客户群活码 + */ + @PreAuthorize("@ss.hasPermi('wecom:groupCode:remove')") + @Log(title = "客户群活码", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult batchRemove(@PathVariable Long[] ids) { + return toAjax(weGroupCodeService.deleteWeGroupCodeByIds(ids)); } // /** @@ -94,4 +191,6 @@ public class WeGroupCodeController extends BaseController // { // return toAjax(weGroupCodeService.deleteWeGroupCodeByIds(ids)); // } + + } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java index 65e996854b00aa73e679b6f6d7f4f1a811e6b72c..26caddcbc7614d1a8da35b33ff54f13af816060d 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMaterialController.java @@ -55,6 +55,7 @@ public class WeMaterialController extends BaseController { WeMaterial weMaterial = new WeMaterial(); weMaterial.setMaterialName(wePoster.getTitle()); weMaterial.setMaterialUrl(wePoster.getSampleImgPath()); + weMaterial.setCategoryId(wePoster.getCategoryId()); weMaterial.setId(wePoster.getId()); return weMaterial; }).collect(Collectors.toList()); @@ -132,9 +133,9 @@ public class WeMaterialController extends BaseController { return AjaxResult.success(); } - @PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')") + //@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')") @Log(title = "获取素材media_id", businessType = BusinessType.OTHER) - @PostMapping("/temporaryMaterialMediaId") + @GetMapping("/temporaryMaterialMediaId") @ApiOperation("获取素材media_id") public AjaxResult temporaryMaterialMediaId(@RequestParam(value = "url") String url, @RequestParam(value = "type") String type,@RequestParam(value = "name") String name){ WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url, type,name); diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java index 13022c407a8b837a9c6e26ae52058c5d9615a204..63ae5c518a097f956667b6c50c7013ff3ab77376 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterController.java @@ -1,5 +1,6 @@ package com.linkwechat.web.controller.wecom; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.enums.MediaType; @@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -54,12 +56,14 @@ public class WePosterController extends BaseController { return AjaxResult.error("请选择海报分类"); }*/ wePosterService.saveOrUpdate(poster); - poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> { - wePosterSubassembly.setDelFlag(0); - wePosterSubassembly.setId(SnowFlakeUtil.nextId()); - wePosterSubassembly.setPosterId(poster.getId()); - }); - wePosterSubassemblyService.saveBatch(poster.getPosterSubassemblyList()); + if(!CollectionUtils.isEmpty(poster.getPosterSubassemblyList())) { + poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> { + wePosterSubassembly.setDelFlag(0); + wePosterSubassembly.setId(SnowFlakeUtil.nextId()); + wePosterSubassembly.setPosterId(poster.getId()); + }); + wePosterSubassemblyService.saveBatch(poster.getPosterSubassemblyList()); + } return AjaxResult.success("创建成功"); } @@ -77,24 +81,26 @@ public class WePosterController extends BaseController { wePosterService.saveOrUpdate(poster); List posterSubassemblyList = wePosterSubassemblyService.lambdaQuery().eq(WePosterSubassembly::getPosterId, poster.getId()).eq(WePosterSubassembly::getDelFlag, 1).list(); Map posterSubassemblyMap = posterSubassemblyList.stream().collect(Collectors.toMap(WePosterSubassembly::getId, p -> p)); - List insertList = new ArrayList<>(); - List updateList = new ArrayList<>(); - poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> { - if (wePosterSubassembly.getId() == null) { - wePosterSubassembly.setId(SnowFlakeUtil.nextId()); - wePosterSubassembly.setPosterId(poster.getId()); - wePosterSubassembly.setDelFlag(0); - insertList.add(wePosterSubassembly); - } else { - posterSubassemblyMap.remove(wePosterSubassembly.getId()); - updateList.add(wePosterSubassembly); + if(!CollectionUtils.isEmpty(poster.getPosterSubassemblyList())) { + List insertList = new ArrayList<>(); + List updateList = new ArrayList<>(); + poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> { + if (wePosterSubassembly.getId() == null) { + wePosterSubassembly.setId(SnowFlakeUtil.nextId()); + wePosterSubassembly.setPosterId(poster.getId()); + wePosterSubassembly.setDelFlag(0); + insertList.add(wePosterSubassembly); + } else { + posterSubassemblyMap.remove(wePosterSubassembly.getId()); + updateList.add(wePosterSubassembly); + } + }); + if (!CollectionUtils.isEmpty(insertList)) { + wePosterSubassemblyService.saveBatch(insertList); + } + if (!CollectionUtils.isEmpty(updateList)) { + wePosterSubassemblyService.updateBatchById(updateList); } - }); - if (!CollectionUtils.isEmpty(insertList)) { - wePosterSubassemblyService.saveBatch(insertList); - } - if (!CollectionUtils.isEmpty(updateList)) { - wePosterSubassemblyService.updateBatchById(updateList); } List deleteList = new ArrayList<>(posterSubassemblyMap.values()); if (!CollectionUtils.isEmpty(deleteList)) { @@ -143,9 +149,10 @@ public class WePosterController extends BaseController { @Transactional(rollbackFor = RuntimeException.class) public AjaxResult deletePosterFont(@PathVariable Long id) { wePosterService.update( - wePosterService.lambdaUpdate().set(WePoster::getDelFlag, 1).eq(WePoster::getId, id)); + Wrappers.lambdaUpdate(WePoster.class).set(WePoster::getDelFlag, 1).eq(WePoster::getId, id)); wePosterSubassemblyService.update( - wePosterSubassemblyService.lambdaUpdate().set(WePosterSubassembly::getDelFlag, 1).eq(WePosterSubassembly::getPosterId, id)); + Wrappers.lambdaUpdate(WePosterSubassembly.class).set(WePosterSubassembly::getDelFlag, 1).eq(WePosterSubassembly::getPosterId, id) + ); return AjaxResult.success("删除成功"); } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java index 28d691e5e075680fa411c9743b1bf925823008db..9348579cefdd04724188abed2d7326093d60de9c 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WePosterFontController.java @@ -1,5 +1,6 @@ package com.linkwechat.web.controller.wecom; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.enums.MediaType; @@ -78,7 +79,8 @@ public class WePosterFontController extends BaseController { @Transactional(rollbackFor = RuntimeException.class) public AjaxResult deletePosterFont(@PathVariable Long id) { wePosterFontService.update( - wePosterFontService.lambdaUpdate().set(WePosterFont::getDelFlag, 1).eq(WePosterFont::getId, id)); + Wrappers.lambdaUpdate(WePosterFont.class).set(WePosterFont::getDelFlag, 1).eq(WePosterFont::getId, id) + ); return AjaxResult.success("删除成功"); } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeSensitiveActController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeSensitiveActController.java new file mode 100644 index 0000000000000000000000000000000000000000..64b3cdb7ceb083f3ef7198911599ad298329b40c --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeSensitiveActController.java @@ -0,0 +1,118 @@ +package com.linkwechat.web.controller.wecom; + +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.constant.HttpStatus; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.poi.ExcelUtil; +import com.linkwechat.wecom.domain.WeSensitiveAct; +import com.linkwechat.wecom.domain.WeSensitiveActHit; +import com.linkwechat.wecom.service.IWeSensitiveActHitService; +import com.linkwechat.wecom.service.IWeSensitiveActService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 敏感行为管理接口 + * + * @author leejoker <1056650571@qq.com> + * @version 1.0 + * @date 2021/1/12 18:07 + */ +@RestController +@RequestMapping("/wecom/sensitive/act") +public class WeSensitiveActController extends BaseController { + @Autowired + private IWeSensitiveActService weSensitiveActService; + + @Autowired + private IWeSensitiveActHitService weSensitiveActHitService; + + /** + * 查询敏感行为列表 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveact:list')") + @GetMapping("/list") + public TableDataInfo list(WeSensitiveAct weSensitiveAct) { + startPage(); + List list = weSensitiveActService.selectWeSensitiveActList(weSensitiveAct); + return getDataTable(list); + } + + /** + * 获取敏感行为详细信息 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveact:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(weSensitiveActService.selectWeSensitiveActById(id)); + } + + /** + * 新增敏感行为设置 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveact:add')") + @Log(title = "新增敏感行为", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Valid @RequestBody WeSensitiveAct weSensitiveAct) { + return weSensitiveActService.insertWeSensitiveAct(weSensitiveAct) ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 修改敏感词设置 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveact:edit')") + @Log(title = "修改敏感行为", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WeSensitiveAct weSensitiveAct) { + Long id = weSensitiveAct.getId(); + WeSensitiveAct originData = weSensitiveActService.selectWeSensitiveActById(id); + if (originData == null) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + return weSensitiveActService.updateWeSensitiveAct(weSensitiveAct) ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 删除敏感词设置 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveact:remove')") + @Log(title = "删除敏感行为", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable("ids") String ids) { + String[] id = ids.split(","); + Long[] idArray = new Long[id.length]; + Arrays.stream(id).map(Long::parseLong).collect(Collectors.toList()).toArray(idArray); + return weSensitiveActService.deleteWeSensitiveActByIds(idArray) ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 敏感词命中查询 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveacthit:list')") + @GetMapping("/hit/list") + public TableDataInfo hitList() { + startPage(); + List list = weSensitiveActHitService.list(); + return getDataTable(list); + } + + /** + * 导出敏感行为记录 + */ + @PreAuthorize("@ss.hasPermi('wecom:sensitiveacthit:export')") + @PostMapping("/hit/export") + public AjaxResult export() { + List list = weSensitiveActHitService.list(); + ExcelUtil util = new ExcelUtil<>(WeSensitiveActHit.class); + return util.exportExcel(list, "敏感行为记录"); + } +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java index 4ffd2a13897fa113b092b1dff25f7a948ea57f5b..941fbf2d473907546669020865067572f934daf4 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java @@ -1,6 +1,8 @@ package com.linkwechat.web.controller.wecom; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.linkwechat.common.annotation.Log; import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.core.controller.BaseController; @@ -8,6 +10,7 @@ import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.utils.Threads; +import com.linkwechat.wecom.domain.WeTag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContext; @@ -23,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController; import com.linkwechat.wecom.domain.WeTagGroup; import com.linkwechat.wecom.service.IWeTagGroupService; +import java.util.List; + /** * 标签组Controller * @@ -44,7 +49,7 @@ public class WeTagGroupController extends BaseController public TableDataInfo list(WeTagGroup weTagGroup) { startPage(); - synchWeTags(); + //synchWeTags(); return getDataTable( weTagGroupService.selectWeTagGroupList(weTagGroup) ); @@ -60,6 +65,18 @@ public class WeTagGroupController extends BaseController @PostMapping public AjaxResult add(@RequestBody WeTagGroup weTagGroup) { + + //校验标签组名称与标签名称是否相同 + if(StrUtil.isNotBlank(weTagGroup.getGourpName())){ + List weTags = weTagGroup.getWeTags(); + if(CollectionUtil.isNotEmpty(weTags)){ + + if(weTags.stream().filter(m -> m.getName().equals(weTagGroup.getGourpName())).findAny().isPresent()){ + return AjaxResult.error("标签组名称与标签名不可重复"); + } + + } + } weTagGroupService.insertWeTagGroup(weTagGroup); return AjaxResult.success(); diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionController.java new file mode 100644 index 0000000000000000000000000000000000000000..83246a1c4aa6e57cdb6661af7f5116e2f1359ada --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionController.java @@ -0,0 +1,157 @@ +package com.linkwechat.web.controller.wecom; + +import com.alibaba.fastjson.JSONObject; +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.config.CosConfig; +import com.linkwechat.common.constant.HttpStatus; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.file.FileUploadUtils; +import com.linkwechat.common.utils.poi.ExcelUtil; +import com.linkwechat.wecom.domain.WeTaskFission; +import com.linkwechat.wecom.domain.dto.WeChatUserDTO; +import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO; +import com.linkwechat.wecom.service.IWeTaskFissionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + + +/** + * 任务宝Controller + * + * @author leejoker + * @date 2021-01-20 + */ +@Api("任务宝Controller") +@RestController +@RequestMapping("/wecom/fission") +public class WeTaskFissionController extends BaseController { + @Autowired + private IWeTaskFissionService weTaskFissionService; + @Autowired + private CosConfig cosConfig; + + /** + * 查询任务宝列表 + */ + @ApiOperation(value = "查询任务宝列表", httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:fission:list')") + @GetMapping("/list") + public TableDataInfo list(WeTaskFission weTaskFission) { + startPage(); + List list = weTaskFissionService.selectWeTaskFissionList(weTaskFission); + return getDataTable(list); + } + + /** + * 导出任务宝列表 + */ + @ApiOperation(value = "导出任务宝列表", httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:fission:export')") + @Log(title = "任务宝", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WeTaskFission weTaskFission) { + List list = weTaskFissionService.selectWeTaskFissionList(weTaskFission); + ExcelUtil util = new ExcelUtil(WeTaskFission.class); + return util.exportExcel(list, "fission"); + } + + /** + * 获取任务宝详细信息 + */ + @ApiOperation(value = "获取任务宝详细信息", httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:fission:query')") + @GetMapping(value = "/getInfo/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(weTaskFissionService.selectWeTaskFissionById(id)); + } + + /** + * 新增任务宝 + */ + @ApiOperation(value = "新增任务宝", httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:fission:add')") + @Log(title = "任务宝", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody WeTaskFission weTaskFission) { + return toAjax(weTaskFissionService.insertWeTaskFission(weTaskFission)); + } + + /** + * 删除任务宝 + */ + @ApiOperation(value = "删除任务宝", httpMethod = "DELETE") + @PreAuthorize("@ss.hasPermi('wecom:fission:remove')") + @Log(title = "任务宝", businessType = BusinessType.DELETE) + @DeleteMapping("/delete/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(weTaskFissionService.deleteWeTaskFissionByIds(ids)); + } + + /** + * 发送裂变任务 + */ + @ApiOperation(value = "发送裂变任务", httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:fission:send')") + @Log(title = "发送裂变任务", businessType = BusinessType.OTHER) + @GetMapping("/send/{id}") + public AjaxResult send(@PathVariable Long id) { + weTaskFissionService.sendWeTaskFission(id); + return AjaxResult.success(); + } + + /** + * 添加群裂变完成记录 + */ + @ApiOperation(value = "添加群裂变完成记录", httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:fission:complete')") + @Log(title = "添加群裂变完成记录", businessType = BusinessType.OTHER) + @PostMapping("/complete/{id}/records/{recordId}") + public AjaxResult completeRecord(@PathVariable("id") Long id, + @PathVariable("recordId") Long recordId, + @RequestBody WeChatUserDTO weChatUserDTO) { + WeTaskFission taskFission = weTaskFissionService.selectWeTaskFissionById(id); + if (taskFission == null) { + return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在"); + } + weTaskFissionService.completeFissionRecord(id, recordId, weChatUserDTO); + return AjaxResult.success(taskFission.getFissQrcode()); + } + + /** + * 生成带二维码的海报 + */ + @ApiOperation(value = "生成带二维码的海报", httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:fission:poster')") + @Log(title = "生成带二维码的海报", businessType = BusinessType.OTHER) + @PostMapping("/poster") + public AjaxResult posterGenerate(@RequestBody WeTaskFissionPosterDTO weTaskFissionPosterDTO) { + String posterUrl = weTaskFissionService.fissionPosterGenerate(weTaskFissionPosterDTO); + JSONObject json = new JSONObject(); + json.put("posterUrl", posterUrl); + return AjaxResult.success(json); + } + + /** + * 上传兑奖图片 + */ + @PreAuthorize("@ss.hasPermi('wechat:fission:upload')") + @Log(title = "上传兑奖图片", businessType = BusinessType.OTHER) + @PostMapping("/upload") + @ApiOperation(value = "上传兑奖图片", httpMethod = "POST") + public AjaxResult upload(@RequestParam(value = "file") MultipartFile file) throws IOException { + String url = FileUploadUtils.upload2Cos(file, cosConfig); + JSONObject json = new JSONObject(); + json.put("rewardImageUrl", url); + return AjaxResult.success(json); + } +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRecordController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRecordController.java new file mode 100644 index 0000000000000000000000000000000000000000..00e4ac469aad7580e2d23ce165b894efec8826e0 --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRecordController.java @@ -0,0 +1,99 @@ +package com.linkwechat.web.controller.wecom; + +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.poi.ExcelUtil; +import com.linkwechat.wecom.domain.WeTaskFissionRecord; +import com.linkwechat.wecom.service.IWeTaskFissionRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 裂变任务完成记录Controller + * + * @author leejoker + * @date 2021-01-20 + */ +@Api(description = "裂变任务完成记录Controller") +@RestController +@RequestMapping("/wecom/record") +public class WeTaskFissionRecordController extends BaseController { + @Autowired + private IWeTaskFissionRecordService weTaskFissionRecordService; + + /** + * 查询裂变任务完成记录列表 + */ + @ApiOperation(value = "查询裂变任务完成记录列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:record:list')") + @GetMapping("/list") + public TableDataInfo list(WeTaskFissionRecord weTaskFissionRecord) { + startPage(); + List list = weTaskFissionRecordService.selectWeTaskFissionRecordList(weTaskFissionRecord); + return getDataTable(list); + } + + /** + * 导出裂变任务完成记录列表 + */ + @ApiOperation(value = "导出裂变任务完成记录列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:record:export')") + @Log(title = "裂变任务完成记录", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WeTaskFissionRecord weTaskFissionRecord) { + List list = weTaskFissionRecordService.selectWeTaskFissionRecordList(weTaskFissionRecord); + ExcelUtil util = new ExcelUtil(WeTaskFissionRecord.class); + return util.exportExcel(list, "record"); + } + + /** + * 获取裂变任务完成记录详细信息 + */ + @ApiOperation(value = "获取裂变任务完成记录详细信息",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:record:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(weTaskFissionRecordService.selectWeTaskFissionRecordById(id)); + } + + /** + * 新增裂变任务完成记录 + */ + @ApiOperation(value = "新增裂变任务完成记录",httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:record:add')") + @Log(title = "裂变任务完成记录", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody WeTaskFissionRecord weTaskFissionRecord) { + return toAjax(weTaskFissionRecordService.insertWeTaskFissionRecord(weTaskFissionRecord)); + } + + /** + * 修改裂变任务完成记录 + */ + @ApiOperation(value = "修改裂变任务完成记录",httpMethod = "PUT") + @PreAuthorize("@ss.hasPermi('wecom:record:edit')") + @Log(title = "裂变任务完成记录", businessType = BusinessType.UPDATE) + @PutMapping("/edit") + public AjaxResult edit(@RequestBody WeTaskFissionRecord weTaskFissionRecord) { + return toAjax(weTaskFissionRecordService.updateWeTaskFissionRecord(weTaskFissionRecord)); + } + + /** + * 删除裂变任务完成记录 + */ + @ApiOperation(value = "删除裂变任务完成记录",httpMethod = "DELETE") + @PreAuthorize("@ss.hasPermi('wecom:record:remove')") + @Log(title = "裂变任务完成记录", businessType = BusinessType.DELETE) + @DeleteMapping("/delete/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(weTaskFissionRecordService.deleteWeTaskFissionRecordByIds(ids)); + } +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRewardController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRewardController.java new file mode 100644 index 0000000000000000000000000000000000000000..22f3ada963aefeb9af6276086296072c394e2b02 --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionRewardController.java @@ -0,0 +1,100 @@ +package com.linkwechat.web.controller.wecom; + +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.poi.ExcelUtil; +import com.linkwechat.wecom.domain.WeTaskFissionReward; +import com.linkwechat.wecom.service.IWeTaskFissionRewardService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + + +/** + * 任务裂变奖励Controller + * + * @author leejoker + * @date 2021-01-20 + */ +@Api(description = "任务裂变奖励Controller") +@RestController +@RequestMapping("/wecom/reward") +public class WeTaskFissionRewardController extends BaseController { + @Autowired + private IWeTaskFissionRewardService weTaskFissionRewardService; + + /** + * 查询任务裂变奖励列表 + */ + @ApiOperation(value = "查询任务裂变奖励列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:reward:list')") + @GetMapping("/list") + public TableDataInfo list(WeTaskFissionReward weTaskFissionReward) { + startPage(); + List list = weTaskFissionRewardService.selectWeTaskFissionRewardList(weTaskFissionReward); + return getDataTable(list); + } + + /** + * 导出任务裂变奖励列表 + */ + @ApiOperation(value = "导出任务裂变奖励列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:reward:export')") + @Log(title = "任务裂变奖励", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WeTaskFissionReward weTaskFissionReward) { + List list = weTaskFissionRewardService.selectWeTaskFissionRewardList(weTaskFissionReward); + ExcelUtil util = new ExcelUtil(WeTaskFissionReward.class); + return util.exportExcel(list, "reward"); + } + + /** + * 获取任务裂变奖励详细信息 + */ + @ApiOperation(value = "获取任务裂变奖励详细信息",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:reward:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(weTaskFissionRewardService.selectWeTaskFissionRewardById(id)); + } + + /** + * 新增任务裂变奖励 + */ + @ApiOperation(value = "新增任务裂变奖励",httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:reward:add')") + @Log(title = "任务裂变奖励", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody WeTaskFissionReward weTaskFissionReward) { + return toAjax(weTaskFissionRewardService.insertWeTaskFissionReward(weTaskFissionReward)); + } + + /** + * 修改任务裂变奖励 + */ + @ApiOperation(value = "修改任务裂变奖励",httpMethod = "PUT") + @PreAuthorize("@ss.hasPermi('wecom:reward:edit')") + @Log(title = "任务裂变奖励", businessType = BusinessType.UPDATE) + @PutMapping("edit") + public AjaxResult edit(@RequestBody WeTaskFissionReward weTaskFissionReward) { + return toAjax(weTaskFissionRewardService.updateWeTaskFissionReward(weTaskFissionReward)); + } + + /** + * 删除任务裂变奖励 + */ + @ApiOperation(value = "删除任务裂变奖励",httpMethod = "DELETE") + @PreAuthorize("@ss.hasPermi('wecom:reward:remove')") + @Log(title = "任务裂变奖励", businessType = BusinessType.DELETE) + @DeleteMapping("/delete/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(weTaskFissionRewardService.deleteWeTaskFissionRewardByIds(ids)); + } +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionStaffController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionStaffController.java new file mode 100644 index 0000000000000000000000000000000000000000..9eed7dcf7caa08722e7192a3e4e33b630cb56df3 --- /dev/null +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTaskFissionStaffController.java @@ -0,0 +1,99 @@ +package com.linkwechat.web.controller.wecom; + +import com.linkwechat.common.annotation.Log; +import com.linkwechat.common.core.controller.BaseController; +import com.linkwechat.common.core.domain.AjaxResult; +import com.linkwechat.common.core.page.TableDataInfo; +import com.linkwechat.common.enums.BusinessType; +import com.linkwechat.common.utils.poi.ExcelUtil; +import com.linkwechat.wecom.domain.WeTaskFissionStaff; +import com.linkwechat.wecom.service.IWeTaskFissionStaffService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 裂变任务员工列Controller + * + * @author leejoker + * @date 2021-01-20 + */ +@Api(description = "裂变任务员工列Controller") +@RestController +@RequestMapping("/wecom/staff") +public class WeTaskFissionStaffController extends BaseController { + @Autowired + private IWeTaskFissionStaffService weTaskFissionStaffService; + + /** + * 查询裂变任务员工列列表 + */ + @ApiOperation(value = "查询裂变任务员工列列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:staff:list')") + @GetMapping("/list") + public TableDataInfo list(WeTaskFissionStaff weTaskFissionStaff) { + startPage(); + List list = weTaskFissionStaffService.selectWeTaskFissionStaffList(weTaskFissionStaff); + return getDataTable(list); + } + + /** + * 导出裂变任务员工列列表 + */ + @ApiOperation(value = "导出裂变任务员工列列表",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:staff:export')") + @Log(title = "裂变任务员工列", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(WeTaskFissionStaff weTaskFissionStaff) { + List list = weTaskFissionStaffService.selectWeTaskFissionStaffList(weTaskFissionStaff); + ExcelUtil util = new ExcelUtil(WeTaskFissionStaff.class); + return util.exportExcel(list, "staff"); + } + + /** + * 获取裂变任务员工列详细信息 + */ + @ApiOperation(value = "获取裂变任务员工列详细信息",httpMethod = "GET") + @PreAuthorize("@ss.hasPermi('wecom:staff:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(weTaskFissionStaffService.selectWeTaskFissionStaffById(id)); + } + + /** + * 新增裂变任务员工列 + */ + @ApiOperation(value = "新增裂变任务员工列",httpMethod = "POST") + @PreAuthorize("@ss.hasPermi('wecom:staff:add')") + @Log(title = "裂变任务员工列", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody WeTaskFissionStaff weTaskFissionStaff) { + return toAjax(weTaskFissionStaffService.insertWeTaskFissionStaff(weTaskFissionStaff)); + } + + /** + * 修改裂变任务员工列 + */ + @ApiOperation(value = "修改裂变任务员工列",httpMethod = "PUT") + @PreAuthorize("@ss.hasPermi('wecom:staff:edit')") + @Log(title = "裂变任务员工列", businessType = BusinessType.UPDATE) + @PutMapping("/edit") + public AjaxResult edit(@RequestBody WeTaskFissionStaff weTaskFissionStaff) { + return toAjax(weTaskFissionStaffService.updateWeTaskFissionStaff(weTaskFissionStaff)); + } + + /** + * 删除裂变任务员工列 + */ + @ApiOperation(value = "删除裂变任务员工列",httpMethod = "DELETE") + @PreAuthorize("@ss.hasPermi('wecom:staff:remove')") + @Log(title = "裂变任务员工列", businessType = BusinessType.DELETE) + @DeleteMapping("/delete/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(weTaskFissionStaffService.deleteWeTaskFissionStaffByIds(ids)); + } +} diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTicketController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTicketController.java index b44b8cb02acca276e3a0dcfa1f920d09b92401f3..4ed4425069ee2d517b2e8e629504bfa5504ecc4f 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTicketController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTicketController.java @@ -41,10 +41,10 @@ public class WeTicketController extends BaseController { */ @Log(title = "获取企业的jsapi_ticket", businessType = BusinessType.OTHER) @GetMapping("/getAppTicket") - public AjaxResult getAppTicket(String url) { + public AjaxResult getAppTicket(String url,String agentId) { String ticketVaule = redisCache.getCacheObject(WeConstans.AppTicketKey); if (StringUtils.isEmpty(ticketVaule)) { - WeH5TicketDto ticketRes = weTicketClient.getJsapiTicket(); + WeH5TicketDto ticketRes = weTicketClient.getJsapiTicket(agentId); if (ticketRes != null && StringUtils.isNotEmpty(ticketRes.getTicket())) { redisCache.setCacheObject(WeConstans.AppTicketKey, ticketRes.getTicket(), ticketRes.getExpiresIn(), TimeUnit.SECONDS); } @@ -61,10 +61,10 @@ public class WeTicketController extends BaseController { */ @Log(title = "获取应用的jsapi_ticket", businessType = BusinessType.OTHER) @GetMapping("/getAgentTicket") - public AjaxResult getAgentTicket(String url) { + public AjaxResult getAgentTicket(String url,String agentId) { String ticketVaule = redisCache.getCacheObject(WeConstans.AgentTicketKey); if (StringUtils.isEmpty(ticketVaule)) { - WeH5TicketDto ticketRes = weTicketClient.getTicket(); + WeH5TicketDto ticketRes = weTicketClient.getTicket(agentId); if (ticketRes != null && StringUtils.isNotEmpty(ticketRes.getTicket())) { redisCache.setCacheObject(WeConstans.AgentTicketKey, ticketRes.getTicket(), ticketRes.getExpiresIn(), TimeUnit.SECONDS); } diff --git a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeUserController.java b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeUserController.java index fecfc0ddd0f66a2fa2b63283473aa12984898732..515dc79a2aa8b4b44b7dbe5dd7fba6ff22490412 100644 --- a/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeUserController.java +++ b/linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeUserController.java @@ -58,10 +58,10 @@ public class WeUserController extends BaseController { * 获取通讯录相关客户详细信息 */ @PreAuthorize("@ss.hasPermi('contacts:organization:view')") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) + @GetMapping(value = "/{userId}") + public AjaxResult getInfo(@PathVariable("userId") String userId) { - return AjaxResult.success(weUserService.selectWeUserById(id)); + return AjaxResult.success(weUserService.selectWeUserById(userId)); } /** @@ -215,6 +215,20 @@ public class WeUserController extends BaseController { } + /** + * 内部应用获取用户userId + * @param code + * @return + */ + @GetMapping("/getUserInfo") + public AjaxResult getUserInfo(String code,String agentId) + { + + return AjaxResult.success( + weUserService.getUserInfo(code,agentId) + ); + } + diff --git a/linkwe-admin/src/main/resources/application-druid.yml b/linkwe-admin/src/main/resources/application-druid.yml index 2c4e2e4e4e05097d246fd61e751f0df6e5dd0776..3d173be1e163448670129613c21752f9628bee50 100644 --- a/linkwe-admin/src/main/resources/application-druid.yml +++ b/linkwe-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://127.0.0.1:3306/link-wechat?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: root + url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/link-wechat-prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ${DB_USER:root} + password: ${DB_PASS:root} # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/linkwe-admin/src/main/resources/application.yml b/linkwe-admin/src/main/resources/application.yml index 0c39c8f24e6e753ec8fd290682b2a7cfe7aab266..5f60dbcf91d1d6c9eab8f74ce6927e275b41bd12 100644 --- a/linkwe-admin/src/main/resources/application.yml +++ b/linkwe-admin/src/main/resources/application.yml @@ -8,8 +8,8 @@ ruoyi: copyrightYear: 2019 # 实例演示开关 demoEnabled: true - # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: /home/ruoyi/uploadPath + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /app/project/pic) + profile: /app/project/pic # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 @@ -19,8 +19,8 @@ ruoyi: # 开发环境配置 server: - # 服务器的HTTP端口,默认为8080 - port: 8080 + # 服务器的HTTP端口,默认为8090 + port: 8090 servlet: # 应用的访问路径 context-path: / @@ -41,6 +41,10 @@ logging: path: log: ./logs +#H5地址路径 +H5: + url: www.baidu.com + # Spring配置 spring: # 资源信息 @@ -69,9 +73,9 @@ spring: # redis 配置 redis: # 地址 - host: localhost + host: ${REDIS_HOST:localhost} # 端口,默认为6379 - port: 6379 + port: ${REDIS_PORT:6379} # 密码 password: # 连接超时时间 @@ -101,9 +105,14 @@ token: mybatis-plus: mapper-locations: classpath*:mapper/**/*Mapper.xml type-aliases-package: com.linkwechat.**.domain - type-handlers-package: com.linkwechat.framework.handler.** + type-handlers-package: com.linkwechat.framework.handler.GenericTypeHandler,com.linkwechat.framework.handler.StringArrayJoinTypeHandler configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + logic-delete-field: delFlag + logic-delete-value: 1 + logic-not-delete-value: 0 ## MyBatis配置 #mybatis: @@ -140,7 +149,7 @@ xss: # elasticsearch配置 elasticsearch: schema: http - address: localhost + address: ${ES_ADDRESS:localhost} connectTimeout: 10000 socketTimeout: 10000 connectionRequestTimeout: 10000 @@ -151,6 +160,10 @@ elasticsearch: forest: interceptors: com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor backend: httpclient + retry-count: 1 # 请求失败后重试次数,默认为0次不重试 + max-retry-interval: 1000 #重试间隔时间 + connect-timeout: 3000 #链接超时时间 + timeout: 3000 # 请求超时时间 wecome: @@ -159,6 +172,11 @@ wecome: noAccessTokenUrl: - /gettoken - /service/get_provider_token + - /wecom/chat/side/list + - /wecom/chat/item/list + - /wecom/chat/collection/addCollection + - /wecom/chat/collection/cancleCollection + - /wecom/chat/collection/list needContactTokenUrl: - /externalcontact/get_follow_user_list - /externalcontact/add_contact_way @@ -180,8 +198,6 @@ wecome: - /externalcontact/unionid_to_external_userid - /externalcontact/add_msg_template - /externalcontact/get_group_msg_result - - /get_jsapi_ticket - - /ticket/get fileUplodUrl: /media/upload,/media/uploadimg needProviderTokenUrl: - /service/get_login_info @@ -190,8 +206,21 @@ wecome: - /msgaudit/check_single_agree - /msgaudit/check_room_agree - /msgaudit/groupchat/get + thirdAppUrl: + - /user/getuserinfo + - /get_jsapi_ticket + - /ticket/get + - /message/send #企微回调通知配置 callBack: - appIdOrCorpId: - token: - encodingAesKey: \ No newline at end of file + appIdOrCorpId: ww24262ce93851488f + token: jtQ1aGHgSmH2UHNBIndUtUe6B6EwfR + encodingAesKey: Vga4HWv7nFbRDYK8iAaQbxmkuecpo2BAfmXAyWwcXMO +#腾讯云对象存储 +cos: + secretId: AKIDQRCizIeUGl13vakkDQMH0VkjhPr1rBBv + secretKey: e3D8oFetseC0f8OX9XeV7UcTDiyyQ8cr + #link-wechat-1251309172.cos.ap-nanjing.myqcloud.com + region: ap-nanjing + bucketName: link-wechat-1251309172 + imgUrlPrefix: https://link-wechat-1251309172.cos.ap-nanjing.myqcloud.com/ \ No newline at end of file diff --git a/linkwe-admin/src/main/resources/mybatis/mybatis-config.xml b/linkwe-admin/src/main/resources/mybatis/mybatis-config.xml index 783df7ad0e8c31f73c14bd7f482bc1d8720ee663..f49bd17f2f9e8ac35bdf9db47d16844aea37d528 100644 --- a/linkwe-admin/src/main/resources/mybatis/mybatis-config.xml +++ b/linkwe-admin/src/main/resources/mybatis/mybatis-config.xml @@ -14,6 +14,8 @@ + + diff --git a/linkwe-common/pom.xml b/linkwe-common/pom.xml index be89c5c796e0a3b5d38821e32a4b29c874aa7f6e..0d9c26b2b6d77312028d1e7a50a64bb5a3422bbc 100644 --- a/linkwe-common/pom.xml +++ b/linkwe-common/pom.xml @@ -69,6 +69,7 @@ com.alibaba fastjson + 1.2.56 @@ -239,6 +240,11 @@ elasticsearch 7.6.0 + + com.qcloud + cos_api + 5.6.24 + \ No newline at end of file diff --git a/linkwe-common/src/main/java/com/linkwechat/common/config/CosConfig.java b/linkwe-common/src/main/java/com/linkwechat/common/config/CosConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..ba15b5f88a83379a9ce73871cd408f6a352c240a --- /dev/null +++ b/linkwe-common/src/main/java/com/linkwechat/common/config/CosConfig.java @@ -0,0 +1,25 @@ +package com.linkwechat.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @author Kewen + */ +@Component +@ConfigurationProperties(prefix = "cos") +@Data +public class CosConfig { + + private String secretId; + + private String secretKey; + + private String region; + + private String bucketName; + + private String imgUrlPrefix; + +} diff --git a/linkwe-common/src/main/java/com/linkwechat/common/config/ElasticSearchConfig.java b/linkwe-common/src/main/java/com/linkwechat/common/config/ElasticSearchConfig.java index 09d3c16370820e180e2933834015abf86de4a5ef..61754cb57f5fed7b8bb4ec90c6896329a1fcfdac 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/config/ElasticSearchConfig.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/config/ElasticSearchConfig.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; /** - * @author sxw + * @author danmo * @description ElasticSearch 配置 * @date 2020/12/4 9:59 **/ diff --git a/linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java b/linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java index aeb7fc238cd999b9172dd2412a079dc8d8686bc4..aad15899d68ca51453f23ac2c74169aadde4d090 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/config/WeComeConfig.java @@ -33,4 +33,7 @@ public class WeComeConfig { /** 会话存档所需token 的url */ private String[] needChatTokenUrl; + + /** 第三方自建应用得url*/ + private String[] thirdAppUrl; } diff --git a/linkwe-common/src/main/java/com/linkwechat/common/constant/GenConstants.java b/linkwe-common/src/main/java/com/linkwechat/common/constant/GenConstants.java index 06b031ff398e8a3c3486fd4d63c681fecfe6fe7d..03ef1137b79def9b1816c66ba86069b74a015299 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/constant/GenConstants.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/constant/GenConstants.java @@ -13,6 +13,9 @@ public class GenConstants /** 树表(增删改查) */ public static final String TPL_TREE = "tree"; + /** 主子表(增删改查) */ + public static final String TPL_SUB = "sub"; + /** 树编码字段 */ public static final String TREE_CODE = "treeCode"; @@ -32,6 +35,8 @@ public class GenConstants public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text", "mediumtext", "longtext" }; + /** 数据库文本类型 */ + public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; /** 数据库时间类型 */ public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; @@ -74,6 +79,15 @@ public class GenConstants /** 日期控件 */ public static final String HTML_DATETIME = "datetime"; + /** 图片上传控件 */ + public static final String HTML_IMAGE_UPLOAD = "imageUpload"; + + /** 文件上传控件 */ + public static final String HTML_FILE_UPLOAD = "fileUpload"; + + /** 富文本控件 */ + public static final String HTML_EDITOR = "editor"; + /** 字符串类型 */ public static final String TYPE_STRING = "String"; diff --git a/linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java b/linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java index 594b6c8988ad838710df7630dbe5e2567d4dada6..75f3a0232cd120342469ea2d4e037ff568c4360e 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java @@ -17,6 +17,12 @@ public class WeConstans { public static final String WE_COMMON_ACCESS_TOKEN = "we_common_access_token"; + /** + * 自建应用token + */ + public static final String WE_THIRD_APP_TOKEN = "we_third_app_token"; + + /** * 获取外部联系人相关 token */ @@ -33,6 +39,15 @@ public class WeConstans { */ public static final String WE_CHAT_ACCESS_TOKEN = "we_chat_access_token"; + /** + * 应用相关token + */ + public static final String WE_AGENT_ACCESS_TOKEN = "we_agent_access_token"; + + + public static final String WE_EMPLE_CODE_KEY = "we_emple_code_key"; + + /** * 企业微信接口返回成功code @@ -105,6 +120,16 @@ public class WeConstans { */ public static final Integer WE_ROOT_CATEGORY_ID = 0; + /** + * 实际群活码正在使用中 + */ + public static final Integer WE_GROUP_CODE_ENABLE = 0; + + /** + * 群活码已禁用/达到扫码次数上限 + */ + public static final Integer WE_GROUP_CODE_DISABLE = 2; + /** * 单人活码 @@ -204,6 +229,7 @@ public class WeConstans { */ public static final Integer USE_SCOP_BUSINESSID_TYPE_USER = 2; public static final Integer USE_SCOP_BUSINESSID_TYPE_ORG = 1; + public static final Integer USE_SCOP_BUSINESSID_TYPE_ALL = 3; /** * 客户流失通知开关 0:关闭 1:开启 @@ -225,6 +251,15 @@ public class WeConstans { */ public static final long LIMIT = 1_000L; + /** + * 敏感词过滤查询用户分片 + */ + public static final Integer SENSITIVE_USER_PIECE = 50; + + /** + * 任务裂变用户活码state前缀 + */ + public static final String FISSION_PREFIX = "fis-"; public static final String AppTicketKey = "ticket:AppGet"; public static final String AgentTicketKey = "ticket:AgentGet"; @@ -240,6 +275,10 @@ public class WeConstans { put("batch_job_result", "weEventBatchJobResultImpl"); //外部联系人事件 put("change_external_contact", "weEventChangeExternalContactImpl"); + //客户群事件 + put("change_external_chat", "weEventChangeExternalChatImpl"); + //客户标签事件 + put("change_external_tag", "weEventChangeExternalTagImpl"); } }; @@ -291,7 +330,49 @@ public class WeConstans { } - public static final String WECOM_FINANCE_INDEX = "finance"; + public static enum sendMessageStatusEnum { + + NOT_SEND("0", "未发送"), + SEND("1", "已发送"), + NOT_FRIEND_SEND("2", "因客户不是好友导致发送失败"), + RECEIVE_OTHER_MESSAGE("3", "-因客户已经收到其他群发消息导致发送失败"), + ; + + private String status; + private String desc; + + /** + * 构造方法 + * + * @param status + * @param desc + */ + sendMessageStatusEnum(String status, String desc) { + this.setStatus(status); + this.setDesc(desc); + } + + public String getStatus() { + return status; + } + + public void setStatus(String key) { + this.status = status; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + } + + + //public static final String WECOM_FINANCE_INDEX = "finance"; + public static final String WECOM_FINANCE_INDEX = "finance_new"; public static final String WECOM_SENSITIVE_HIT_INDEX = "sensitive"; @@ -299,4 +380,33 @@ public class WeConstans { * 开启会话存档成员列表 **/ public static final String weMsgAuditKey = "wecom_msg_audit:user:ids"; + + + /** + * 第三方应用ID,参数标实 + */ + public static final String THIRD_APP_PARAM_TIP = "agentId"; + + public static final String WECUSTOMERS_KEY="weCustomer"; + + /** + * 发给客户 + */ + public static final String SEND_MESSAGE_CUSTOMER = "0"; + + /** + * 发给客户群 + */ + public static final String SEND_MESSAGE_GROUP="1"; + + /** + * 消息范围 1 指定客户 + */ + public static final String SEND_MESSAGE_CUSTOMER_ALL = "0"; + + /** + * 消息范围 1 指定客户 + */ + public static final String SEND_MESSAGE_CUSTOMER_PART="1"; + } diff --git a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/ConversationArchiveQuery.java b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/ConversationArchiveQuery.java index a5a4bf4508a78c9a2c3e35b87b138720eb9d02b2..af9e1d6c72a338ac7aaa3ae37bd06924b6039b4e 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/ConversationArchiveQuery.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/ConversationArchiveQuery.java @@ -3,7 +3,7 @@ package com.linkwechat.common.core.domain; import lombok.Data; /** - * @author sxw + * @author danmo * @description 会话存档接口入参实体 * @date 2020/12/29 14:23 **/ @@ -29,4 +29,7 @@ public class ConversationArchiveQuery extends BaseEntity { /** 关键词 **/ private String keyWord; + + /** 消息动作 */ + private String action; } diff --git a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchDataVo.java b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchDataVo.java index 58a88113e542a74ace7e474c9117a387883e0499..62eab96c7b93a3c1558d93dc08da1e40c2a54787 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchDataVo.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchDataVo.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * @author sxw + * @author danmo * @description http交互Vo对象 * @date 2020/12/9 14:14 **/ diff --git a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchEntity.java b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchEntity.java index 323a976f1674a1909be07c614ffdbb9b2ab0395c..a62bd908958e030456921651cb92fbf563a6c3b8 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchEntity.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchEntity.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; import java.util.Map; /** - * @author sxw + * @author danmo * @description * @date 2020/12/9 14:11 **/ diff --git a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchQueryVo.java b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchQueryVo.java index c4d1b437da7b0d84e92208ebd5e9b17ac6fe464c..959b4f28eeed6b3d7b413f5202caeabcdade50af 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchQueryVo.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/core/domain/elastic/ElasticSearchQueryVo.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; import java.util.Map; /** - * @author sxw + * @author danmo * @description * @date 2020/12/9 14:18 **/ diff --git a/linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java b/linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java index 523d0738ca73dab3e0712cb40dcd7db89a2151b9..7aa5bafd934241af715cdf3ae2d3187266903057 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java @@ -40,7 +40,7 @@ import java.util.Map; import java.util.function.Consumer; /** - * @author sxw + * @author danmo * @description es工具类 * @date 2020/12/9 14:02 **/ diff --git a/linkwe-common/src/main/java/com/linkwechat/common/enums/GroupMessageType.java b/linkwe-common/src/main/java/com/linkwechat/common/enums/GroupMessageType.java new file mode 100644 index 0000000000000000000000000000000000000000..421aeec753bd7d7f60c61a3249e20dd1c1405e19 --- /dev/null +++ b/linkwe-common/src/main/java/com/linkwechat/common/enums/GroupMessageType.java @@ -0,0 +1,56 @@ +package com.linkwechat.common.enums; + +import lombok.Getter; + +import java.util.Optional; +import java.util.stream.Stream; + +/** + * 群发消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 4 图文消息 + */ +@SuppressWarnings("all") +@Getter +public enum GroupMessageType { + + /** + * 文本消息 + */ + TEXT("0", "text"), + /** + * 图片消息 + */ + IMAGE("1", "image"), + /** + * 链接消息 + */ + LINK("2", "link"), + /** + * 小程序消息 + */ + MINIPROGRAM("3", "miniprogram"), + /** + * 图文消息 + */ + TEXT_IMAGE("4", "text_image"), + + ; + /** + * 媒体类型 + */ + String messageType; + + /** + * 数据值 + */ + String type; + + GroupMessageType(String type, String messageType) { + this.type = type; + this.messageType = messageType; + } + + public static Optional of(String type) { + return Stream.of(values()).filter(s -> s.type.equals(type)).findFirst(); + } + +} diff --git a/linkwe-common/src/main/java/com/linkwechat/common/enums/TaskFissionType.java b/linkwe-common/src/main/java/com/linkwechat/common/enums/TaskFissionType.java new file mode 100644 index 0000000000000000000000000000000000000000..cffa9774efb49a4db71c1cf46cd00dc55e3a7f70 --- /dev/null +++ b/linkwe-common/src/main/java/com/linkwechat/common/enums/TaskFissionType.java @@ -0,0 +1,30 @@ +package com.linkwechat.common.enums; + +import lombok.Getter; + +/** + * @author leejoker <1056650571@qq.com> + * @version 1.0 + * @date 2021/2/9 10:31 + */ +@Getter +public enum TaskFissionType { + /** + * 任务宝 + */ + USER_FISSION(1, "任务宝"), + + /** + * 群裂变 + */ + GROUP_FISSION(2, "群裂变"); + + private String value; + + private Integer code; + + TaskFissionType(Integer code, String value) { + this.code = code; + this.value = value; + } +} diff --git a/linkwe-common/src/main/java/com/linkwechat/common/enums/TransferFailReason.java b/linkwe-common/src/main/java/com/linkwechat/common/enums/TransferFailReason.java new file mode 100644 index 0000000000000000000000000000000000000000..3df367fca06d9dc992ff6777ac406f75b0e2bb12 --- /dev/null +++ b/linkwe-common/src/main/java/com/linkwechat/common/enums/TransferFailReason.java @@ -0,0 +1,55 @@ +package com.linkwechat.common.enums; + +import lombok.Getter; + +/** + * @author danmo + * @description 接替失败的原因 + * @date 2021/1/20 0:14 + **/ +@Getter +public enum TransferFailReason { + /** + * 客户拒绝 + */ + CUSTOMER_REFUSED(3,"customer_refused", "客户拒绝"), + + /** + * 接替成员的客户数达到上限 + */ + CUSTOMER_LIMIT_EXCEED(4,"customer_limit_exceed", "接替成员的客户数达到上限"); + + private int num; + + private String name; + + private String reason; + + TransferFailReason(int num, String name, String reason) { + this.num = num; + this.name = name; + this.reason = reason; + } + + public static String getReason(String name){ + TransferFailReason[] values = TransferFailReason.values(); + + for(TransferFailReason transferFailReason:values){ + if(transferFailReason.getName().equals(name)){ + return transferFailReason.getReason(); + } + } + throw new RuntimeException("无对应原因"); + } + + public static int getNum(String name){ + TransferFailReason[] values = TransferFailReason.values(); + + for(TransferFailReason transferFailReason:values){ + if(transferFailReason.getName().equals(name)){ + return transferFailReason.getNum(); + } + } + throw new RuntimeException("无对应类型"); + } +} diff --git a/linkwe-common/src/main/java/com/linkwechat/common/utils/DateUtils.java b/linkwe-common/src/main/java/com/linkwechat/common/utils/DateUtils.java index 305efe9e2f76c03424159e2f47df0255d2d05deb..9392254719b9b5e05f6202de4ef3dec770dd55c4 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/utils/DateUtils.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/utils/DateUtils.java @@ -189,4 +189,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils } return lDate; } + + public static long getMillionSceondsBydate(String date) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS); + long millionSeconds = sdf.parse(date).getTime();//毫秒 + return millionSeconds; + } } diff --git a/linkwe-common/src/main/java/com/linkwechat/common/utils/QREncode.java b/linkwe-common/src/main/java/com/linkwechat/common/utils/QREncode.java index 571fa32a20471341fad49ebf67fc3760142e0825..c7161b4a50a1f8a5648896b5ae171216fce489a0 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/utils/QREncode.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/utils/QREncode.java @@ -1,66 +1,201 @@ package com.linkwechat.common.utils; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; +import java.net.URL; +import java.util.HashMap; import java.util.Hashtable; import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.QRCodeWriter; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import com.linkwechat.common.constant.Constants; public class QREncode { - - private static final int BLACK = 0xFF000000; - private static final int WHITE = 0xFFFFFFFF; - - private QREncode() {} - - - public static BufferedImage toBufferedImage(BitMatrix matrix) { - int width = matrix.getWidth(); - int height = matrix.getHeight(); - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE); - } - } - return image; - } - - - public static void writeToFile(BitMatrix matrix, String format, File file) - throws IOException { - BufferedImage image = toBufferedImage(matrix); - if (!ImageIO.write(image, format, file)) { - throw new IOException("Could not write an image of format " + format + " to " + file); - } - } - - - public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) - throws IOException { - BufferedImage image = toBufferedImage(matrix); - if (!ImageIO.write(image, format, stream)) { - throw new IOException("Could not write an image of format " + format); - } - } - @SuppressWarnings({ "unchecked", "rawtypes" }) -public static void main(String[] args) throws Exception { - String text = "http://open.weixin.qq.com/qr/code/?username=LinkWeChat2021"; - int width = 300; - int height = 300; - String format = "png"; - Hashtable hints = new Hashtable(); - hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); - BitMatrix bitMatrix = new MultiFormatWriter().encode(text, - BarcodeFormat.QR_CODE, width, height, hints); - File outputFile = new File("d:"+File.separator+"qr.png"); - QREncode.writeToFile(bitMatrix, format, outputFile); - } + + private static final int BLACK = 0xFF000000; + private static final int WHITE = 0xFFFFFFFF; + /** + * 默认宽度 + */ + private static final Integer WIDTH = 140; + /** + * 默认高度 + */ + private static final Integer HEIGHT = 140; + + /** + * LOGO 默认宽度 + */ + private static final Integer LOGO_WIDTH = 22; + /** + * LOGO 默认高度 + */ + private static final Integer LOGO_HEIGHT = 22; + + /** + * 图片格式 + */ + private static final String IMAGE_FORMAT = "png"; + + + private QREncode() { + } + + + public static BufferedImage toBufferedImage(BitMatrix matrix) { + int width = matrix.getWidth(); + int height = matrix.getHeight(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE); + } + } + return image; + } + + public static void writeToFile(BitMatrix matrix, String format, File file) + throws IOException { + BufferedImage image = toBufferedImage(matrix); + if (!ImageIO.write(image, format, file)) { + throw new IOException("Could not write an image of format " + format + " to " + file); + } + } + + public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) + throws IOException { + BufferedImage image = toBufferedImage(matrix); + if (!ImageIO.write(image, format, stream)) { + throw new IOException("Could not write an image of format " + format); + } + } + + /** + * 生成带头像的二维码 + * + * @param content 内容 + * @param logoUrl logo在线地址 + * @return + */ + public static BufferedImage crateQRCode(String content, String logoUrl) { + if (StringUtils.isNotBlank(content)) { + ServletOutputStream stream = null; + HashMap hints = new HashMap<>(4); + // 指定字符编码为utf-8 + hints.put(EncodeHintType.CHARACTER_SET, Constants.UTF8); + // 指定二维码的纠错等级为中级 + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M); + // 设置图片的边距 + hints.put(EncodeHintType.MARGIN, 2); + try { + QRCodeWriter writer = new QRCodeWriter(); + BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, WIDTH, HEIGHT, hints); + BufferedImage bufferedImage = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < WIDTH; x++) { + for (int y = 0; y < HEIGHT; y++) { + bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF); + } + } + if (StringUtils.isNotBlank(logoUrl)) { + insertLogo(bufferedImage, logoUrl); + } + return bufferedImage; + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stream != null) { + try { + stream.flush(); + stream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + return null; + } + + /** + * 二维码插入logo + * + * @param source 二维码 + * @param logoUrl logo 在线地址 + * @throws Exception + */ + private static void insertLogo(BufferedImage source, String logoUrl) throws Exception { + // logo 源可为 File/InputStream/URL + Image src = ImageIO.read(new URL(logoUrl)); + // 插入LOGO + Graphics2D graph = source.createGraphics(); + int x = (WIDTH - LOGO_WIDTH) / 2; + int y = (HEIGHT - LOGO_HEIGHT) / 2; + graph.drawImage(src, x, y, LOGO_WIDTH, LOGO_HEIGHT, null); + Shape shape = new RoundRectangle2D.Float(x, y, LOGO_WIDTH, LOGO_HEIGHT, 6, 6); + graph.setStroke(new BasicStroke(3f)); + graph.draw(shape); + graph.dispose(); + } + + /** + * 生成带二维码并生成流文件进行传输 + * + * @param content 内容 + * @param output 输出流 + * @throws Exception + */ + public void getQRCode(String content, OutputStream output) throws Exception { + BufferedImage image = crateQRCode(content, null); + if (StringUtils.isNotNull(image)) { + ImageIO.write(image, IMAGE_FORMAT, output); + } + } + + /** + * 生成带logo的二维码并生成流文件进行传输 + * + * @param content 内容 + * @param logoUrl logo资源 + * @param output 输出流 + * @throws Exception + */ + public void getQRCode(String content, String logoUrl, OutputStream output) throws Exception { + BufferedImage image = crateQRCode(content, logoUrl); + if (StringUtils.isNotNull(image)) { + ImageIO.write(image, IMAGE_FORMAT, output); + } + } + + public static InputStream writeToInputStream(BufferedImage bufferedImage) throws IOException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try { + ImageIO.write(bufferedImage, IMAGE_FORMAT, os); + return new ByteArrayInputStream(os.toByteArray()); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public static void main(String[] args) throws Exception { + String text = "http://open.weixin.qq.com/qr/code/?username=LinkWeChat2021"; + int width = 300; + int height = 300; + String format = "png"; + Hashtable hints = new Hashtable<>(); + hints.put(EncodeHintType.CHARACTER_SET, Constants.UTF8); + BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height, hints); + File outputFile = new File("d:" + File.separator + "qr.png"); + QREncode.writeToFile(bitMatrix, format, outputFile); + } } diff --git a/linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java b/linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java index 438ea456df9a419a5d59cefeaf34dcd08dde6269..38ef677c1e0ccb76fca1c8ab843405b2e5860c67 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/utils/file/FileUploadUtils.java @@ -2,7 +2,10 @@ package com.linkwechat.common.utils.file; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.linkwechat.common.config.CosConfig; import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.constant.Constants; import com.linkwechat.common.exception.file.FileNameLengthLimitExceededException; @@ -11,6 +14,15 @@ import com.linkwechat.common.exception.file.InvalidExtensionException; import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.uuid.IdUtils; +import com.qcloud.cos.COSClient; +import com.qcloud.cos.ClientConfig; +import com.qcloud.cos.auth.BasicCOSCredentials; +import com.qcloud.cos.auth.COSCredentials; +import com.qcloud.cos.model.ObjectMetadata; +import com.qcloud.cos.model.PutObjectRequest; +import com.qcloud.cos.model.PutObjectResult; +import com.qcloud.cos.region.Region; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FilenameUtils; import org.springframework.web.multipart.MultipartFile; @@ -19,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile; * * @author ruoyi */ +@Slf4j public class FileUploadUtils { /** * 默认大小 50M @@ -120,6 +133,103 @@ public class FileUploadUtils { return pathFileName; } + /** + * 上传到腾讯对象云存储中 + * + * @param file 上传的文件 + * @return 访问路径 + * @throws IOException + */ + public static final String upload2Cos(MultipartFile file , CosConfig cosConfig) throws IOException { + try { + return upload2Cos( file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION,cosConfig); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 通过流进行文件上传 + * @param in 流 + * @throws IOException + */ + public static String upload2Cos(InputStream in, String fileExtension, CosConfig cosConfig) throws IOException { + try { + return upload2Cos( in, fileExtension, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, cosConfig); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } + + + /** + * 文件上传 + * + * @param file 上传的文件 + * @param allowedExtension 上传文件类型 + * @return 返回上传成功的文件名 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final String upload2Cos( MultipartFile file, String[] allowedExtension, CosConfig cosConfig) + throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, + InvalidExtensionException { + int fileNamelength = file.getOriginalFilename().length(); + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + // 1 初始化用户身份信息(secretId, secretKey)。 + COSCredentials cred = new BasicCOSCredentials(cosConfig.getSecretId(), cosConfig.getSecretKey()); + // 2 设置 bucket 的区域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224 + // clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。 + Region region = new Region(cosConfig.getRegion()); + ClientConfig clientConfig = new ClientConfig(region); + // 3 生成 cos 客户端。 + COSClient cosClient = new COSClient(cred, clientConfig); + + // 指定要上传到 COS 上对象键 + String key = "exampleobject"; + ObjectMetadata objectMetadata = new ObjectMetadata(); + PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName,file.getInputStream(),objectMetadata); + PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); + log.info("{}","https://link-wechat-1251309172.cos.ap-nanjing.myqcloud.com/"+fileName); + log.info("腾讯cos上传信息:{}",new ObjectMapper().writeValueAsString(putObjectResult)); + cosClient.shutdown(); + + return fileName; + } + + /** + * 将流中的文件传到腾讯云 + * @param inputStream 输入流 + * @param fileExtension 被写入流的文件的后缀名 + * @param allowedExtension 允许的后缀名 + * @throws FileSizeLimitExceededException 文件大小超过上限 + * @throws InvalidExtensionException 文件后缀名非法 + */ + public static String upload2Cos(InputStream inputStream, String fileExtension, String[] allowedExtension, CosConfig cosConfig) throws FileSizeLimitExceededException, InvalidExtensionException { + String fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + fileExtension; + if (!isAllowedExtension(fileExtension, allowedExtension)) + { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, fileExtension, fileName); + } + COSCredentials cred = new BasicCOSCredentials(cosConfig.getSecretId(), cosConfig.getSecretKey()); + Region region = new Region(cosConfig.getRegion()); + ClientConfig clientConfig = new ClientConfig(region); + COSClient cosClient = new COSClient(cred, clientConfig); + ObjectMetadata objectMetadata = new ObjectMetadata(); + PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName ,inputStream ,objectMetadata); + cosClient.putObject(putObjectRequest); + cosClient.shutdown(); + return fileName; + } + public static final String uploadFile(String baseDir, MultipartFile file) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException { @@ -158,7 +268,7 @@ public class FileUploadUtils { return desc; } - private static final String getPathFileName(String uploadDir, String fileName) throws IOException { + public static final String getPathFileName(String uploadDir, String fileName) throws IOException { int dirLastIndex = RuoYiConfig.getProfile().length() + 1; String currentDir = StringUtils.substring(uploadDir, dirLastIndex); String pathFileName; diff --git a/linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java b/linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java index f8ceee1d830fd7b9304db063af8dc73fae011a17..d3d1901e661f9cfd4578123026e7b5c2fd2bb7eb 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/utils/img/NetFileUtils.java @@ -28,7 +28,7 @@ public class NetFileUtils { public static FileCallable getNetFile(String urlPath){ FileCallable fileCallable = new FileCallable(); - webClient.getAbs(urlPath).send().onSuccess(response -> { + webClient.getAbs(urlPath).timeout(1000L*60L*10L).send().onSuccess(response -> { if(response.statusCode() == 200 || response.statusCode() == 302){ Buffer buffer = response.body(); buffer.getByteBuf(); diff --git a/linkwe-common/src/main/java/com/linkwechat/common/utils/wecom/RSAUtil.java b/linkwe-common/src/main/java/com/linkwechat/common/utils/wecom/RSAUtil.java index 990e842dd2cab0bf374828a27b0f4de910e50106..8a4d30c760fc963a22788c8fe3efb86650abe1ae 100644 --- a/linkwe-common/src/main/java/com/linkwechat/common/utils/wecom/RSAUtil.java +++ b/linkwe-common/src/main/java/com/linkwechat/common/utils/wecom/RSAUtil.java @@ -18,7 +18,7 @@ import java.security.spec.RSAPrivateCrtKeySpec; import java.util.Base64; /** - * @author sxw + * @author danmo * @description * @date 2020/12/7 23:37 **/ diff --git a/linkwe-common/src/main/java/com/tencent/wework/Finance.java b/linkwe-common/src/main/java/com/tencent/wework/Finance.java index 97559839f2e12b246bd7404178600dfb6cb8e75a..2c74ce95d868cd6661d1f6d18d52edf975fb3b86 100644 --- a/linkwe-common/src/main/java/com/tencent/wework/Finance.java +++ b/linkwe-common/src/main/java/com/tencent/wework/Finance.java @@ -118,7 +118,7 @@ public class Finance { System.loadLibrary("libcurl"); System.loadLibrary("WeWorkFinanceSdk"); } else { - System.load("/app/project/libWeWorkFinanceSdk_Java.so"); + System.load("/var/jenkins_home/app/projects/libWeWorkFinanceSdk_Java.so"); } } diff --git a/linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java b/linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java index 432cc7313f0c48a4c8cdd82f21817c6ab47ec46e..b6e29908782f018695eeaa010c41e6a1b268666a 100644 --- a/linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java +++ b/linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java @@ -21,7 +21,7 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; /** - * @author sxw + * @author danmo * @description * @date 2020/12/2 16:01 **/ @@ -51,7 +51,33 @@ public class FinanceUtils { } } - private final static String privateKey = ""; + private final static String privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" + + "MIIEpAIBAAKCAQEAjGwIQIMGDJonMQdX3OJzZN0YVoYbORK1FU/8vhwdI9ixxSGW\n" + + "nrAQc6r8k3g1QTXzmKAxdVlAa1OGZCpl5X5A6C9JwDhFpuN+SKJxfxtHNv1oBk0r\n" + + "LnDftsdlibZFQn3fiMomxKyU8eujWBe31+pLQXaTSdSHcNhb+NrBa7AtNUr/c7bK\n" + + "nnFUZHDpXFB4Z0BhK1cRh2NN7ppLNnIJXpduGrwGtLdx++LsBaX2vjO4qW/DKP2Z\n" + + "3gZON1tGoofS1IPhCg0naoRN3lL7ctFAyxOr2ualGOc6hpvBGfjnBKU42aoaKQEi\n" + + "7tVJHChonZXMRcm4mdPu5371IzPeR3NYlP3ESQIDAQABAoIBAEux8MDV4GzqrDXB\n" + + "v5tSduHoTTZXFFWvv+29MIFKpmqsZSfe81KXlkbD5WOZaRu9+ZJMyFx5wEAaxlc4\n" + + "g7UyWcrPsvHrY6CTAYAmEQhzq+/4qhq7fouKTQ46boHNv4gYUmdqkXtzjNbcLzFN\n" + + "l8zMf8TKJpul9VzfRLThN2LVlYkkETcCukzZrK+aSCi6E/dL+noL1ndZYmWF5kbB\n" + + "lk881x5CdbusYBtoxfh6ie0EXfCyK4duX3OdvXRcSpTdqiqTcrtt9oinh4ZHV930\n" + + "BCTPkGGz5UL3C243W3dlzuonNXqwl++FCSyRMVONYSgb4NRJn4fvehjGtXyAv3Sz\n" + + "nSAVoAECgYEA9dhYk4DT2Hclaqo/0ugQvUp7oIPN9qFgrZ6nU94SHkdrBqhFrCmz\n" + + "32GeYGSsQJQx3T9Kuip7oGX9AOKn3f30NrcuAe9VzzWAkCKQgQgmtMVySAPWCVr9\n" + + "4MH77hc3ijxr6iGd70BQ7EDyVQGRvZqOLl1wu7yZ9vhbVHA87KpgHf0CgYEAkjjn\n" + + "mNudh+rs8ibrGu+md8bXJdxHtIbncXF5VsV7wi4HlHfKnWqy+z2If1akm2iacnsi\n" + + "XDVqyYNExdtoxmbPc/R9ZJ8jP0FLPoWACcjP03r9H+5eiXrmniZbElGshnwKHFFh\n" + + "ZlY1xPAXFgEjh10DDG1wK6/9eB13o+NdP7c7yz0CgYEA3HujNOadF84DaJ43j1dB\n" + + "bAKYzWRoG4CvzAY12ymW5kD244mWssjT4MsT1y9yrJg8AEj7I+tl5HyTY2/jTVys\n" + + "4UV3pZSYSLWbD6lwH8jHrehGjf+ivdE1T5Wp8+YukXOO9PQhSKlN6hR1QXee1YT/\n" + + "buWubTDAhJZIknn2qepDOaECgYA/OnITLCwTYOey0ldpn2V5d7cC/RzYmFkuOeZB\n" + + "OkYIsoS+k4o+xau9bl8+yQWG2hWnGU3DV6nkl2m+sOC+oihkuL0cLKA+MwrJb0rt\n" + + "cDNF/HHGQ/oHMujUTDunUT/sK2jn09ztNqwri7I/5qApYXP3BL+zdHeDYCKi8Kca\n" + + "7S3i9QKBgQCgKgQf8u+oRojMH14iJssAyNEhZgmJ85s/BeiUmMuW5K8iZZ5pnVuq\n" + + "8nc/IJGVPHRTObdGCd1L4d5UERiX46Z1BjYv/nuK5DScDcB3mq6K9VXJLNE+MxwW\n" + + "wOVT+6FjmBRucGXczAkWXCH7++y6gYzE+OuRIdv5sVkE24gNG7sawg==\n" + + "-----END RSA PRIVATE KEY-----"; /** * 拉取聊天记录 diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java b/linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java index d11f9250b3f2890f1f6358fe98ea8ce5287b8799..d055aca34ac78122d7a0d8a85bc4ddc1ca02b55a 100644 --- a/linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java @@ -1,11 +1,16 @@ package com.linkwechat.framework.config; +import com.linkwechat.framework.listener.EmpleCodeExpiredListener; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.PatternTopic; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; import org.springframework.data.redis.serializer.StringRedisSerializer; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; @@ -20,6 +25,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; @EnableCaching public class RedisConfig extends CachingConfigurerSupport { + + @Autowired + private RedisConnectionFactory redisConnectionFactory; + @Bean @SuppressWarnings(value = { "unchecked", "rawtypes" }) public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) @@ -40,4 +49,18 @@ public class RedisConfig extends CachingConfigurerSupport template.afterPropertiesSet(); return template; } + + + + @Bean + public RedisMessageListenerContainer redisMessageListenerContainer() { + RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer(); + redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory); + return redisMessageListenerContainer; + } + + @Bean + public EmpleCodeExpiredListener codeExpiredListener() { + return new EmpleCodeExpiredListener(this.redisMessageListenerContainer()); + } } diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java b/linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java index 2ad9b9cdaa30677aef4bc0796f2b33fe33b93bf2..0d4f3377285ddfbbfba0d65717f31330eb76627d 100644 --- a/linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java @@ -115,6 +115,17 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .antMatchers("/*/api-docs").anonymous() .antMatchers("/druid/**").anonymous() .antMatchers("/wecom/callback/**").anonymous() + + .antMatchers("/wecom/chat/item/list").anonymous() + .antMatchers("/wecom/chat/collection/list").anonymous() + .antMatchers("/wecom/chat/collection/cancleCollection").anonymous() + .antMatchers("/wecom/chat/collection/addCollection").anonymous() + .antMatchers("/wecom/chat/side/h5List").anonymous() + .antMatchers("/wecom/ticket/**").anonymous() + + .antMatchers("/wecom/user/getUserInfo").anonymous() + // .antMatchers("/common/uploadFile2Cos").anonymous() + .antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/handler/GenericTypeHandler.java b/linkwe-framework/src/main/java/com/linkwechat/framework/handler/GenericTypeHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..98b575ea292f2c051d17615cb76e28e0a1fd4687 --- /dev/null +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/handler/GenericTypeHandler.java @@ -0,0 +1,88 @@ +package com.linkwechat.framework.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的T类型 属性 + * @param + */ +@SuppressWarnings("all") +@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class}) +@MappedJdbcTypes(value = {JdbcType.VARCHAR}, includeNullJdbcType = true) +public class GenericTypeHandler extends BaseTypeHandler { + + private Class clazz; + + public GenericTypeHandler(Class clazz) { + if (clazz == null) { + throw new IllegalArgumentException("Type argument cannot be null"); + } + this.clazz = clazz; + } + + /** + * 设置非空参数 + * @param ps + * @param i + * @param parameter + * @param jdbcType + * @throws SQLException + */ + @Override + public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException { + ps.setString(i, JSON.toJSONString(parameter)); + } + + /** + * 根据列名,获取可以为空的结果 + * @param rs + * @param columnName + * @return + * @throws SQLException + */ + @Override + public T getNullableResult(ResultSet rs, String columnName) throws SQLException { + String sqlJson = rs.getString(columnName); + if (null != sqlJson) { + return JSONObject.parseObject(sqlJson, clazz); + } + return null; + } + + /** + * 根据列索引,获取可以为空的结果 + * @param rs + * @param columnIndex + * @return + * @throws SQLException + */ + @Override + public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + String sqlJson = rs.getString(columnIndex); + if (null != sqlJson) { + return JSONObject.parseObject(sqlJson, clazz); + } + return null; + } + + @Override + public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + String sqlJson = cs.getString(columnIndex); + if (null != sqlJson) { + return JSONObject.parseObject(sqlJson, clazz); + } + return null; + } + +} \ No newline at end of file diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/handler/ListTypeHandler.java b/linkwe-framework/src/main/java/com/linkwechat/framework/handler/ListTypeHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..55b892e3a7779e10fd7016538ea47ea7d6535a06 --- /dev/null +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/handler/ListTypeHandler.java @@ -0,0 +1,88 @@ +package com.linkwechat.framework.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.linkwechat.common.utils.StringUtils; +import com.linkwechat.wecom.domain.WeCustomer; +import com.linkwechat.wecom.domain.WeGroup; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.ibatis.type.*; + +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + + +/** + * 处理jsonArray字符串为pojoList + * @param + */ +//支持的java对象 +@SuppressWarnings("all") +@Slf4j +@MappedTypes(value = {WeCustomer.class,WeGroup.class}) +@MappedJdbcTypes({JdbcType.VARCHAR}) +public class ListTypeHandler implements TypeHandler> { + + private List getListByJsonArrayString(String content,String filedName) { + + if (StringUtils.isEmpty(content)) { + return new ArrayList<>(); + } + + if(filedName!=null && "customers_info".equals(filedName)){ + return JSONObject.parseArray(content, WeCustomer.class); + } + + if(filedName!=null && "groups_info".equals(filedName)){ + return JSONObject.parseArray(content, WeGroup.class); + } + + return null; + } + + /** + * 用于定义在Mybatis设置参数时该如何把Java类型的参数转换为对应的数据库类型 + * + *
+     * PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
+     * SET SALARY = ? WHERE ID = ?");
+     * pstmt.setBigDecimal(1, 153833.00)
+     * pstmt.setInt(2, 110592)
+     * 
+ * + * @param preparedStatement An object that represents a precompiled SQL statement + * @param i 当前参数的位置 + * @param t 当前参数的Java对象 + * @param jdbcType 当前参数的数据库类型 + * @throws SQLException + */ + @Override + public void setParameter(PreparedStatement preparedStatement, int i, List t, JdbcType jdbcType) throws SQLException { + if (CollectionUtils.isEmpty(t)) { + preparedStatement.setString(i, null); + } else { + preparedStatement.setString(i, JSON.toJSONString(t).replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", "")); + } + } + + @Override + public List getResult(ResultSet resultSet, String s) throws SQLException { + log.info("序列化集合字段:{}",s); + return getListByJsonArrayString(resultSet.getString(s),s); + } + + @Override + public List getResult(ResultSet resultSet, int i) throws SQLException { + return getListByJsonArrayString(resultSet.getString(i),null); + } + + @Override + public List getResult(CallableStatement callableStatement, int i) throws SQLException { + return getListByJsonArrayString(callableStatement.getString(i),null); + } + + +} \ No newline at end of file diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/listener/EmpleCodeExpiredListener.java b/linkwe-framework/src/main/java/com/linkwechat/framework/listener/EmpleCodeExpiredListener.java new file mode 100644 index 0000000000000000000000000000000000000000..a80fdd73a04e4db3c85ca2209cb133501fa225c4 --- /dev/null +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/listener/EmpleCodeExpiredListener.java @@ -0,0 +1,34 @@ +package com.linkwechat.framework.listener; + + +import com.linkwechat.common.constant.WeConstans; +import com.linkwechat.wecom.client.WeExternalContactClient; +import com.linkwechat.wecom.domain.WeEmpleCode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; + +import java.nio.charset.StandardCharsets; + +/** + * @author danmo + * @description redis 键值过期监听 + * @date 2021/2/8 17:24 + **/ +public class EmpleCodeExpiredListener extends KeyExpirationEventMessageListener { + @Autowired + private WeExternalContactClient weExternalContactClient; + + public EmpleCodeExpiredListener(RedisMessageListenerContainer listenerContainer) { + super(listenerContainer); + } + + @Override + public void onMessage(Message message, byte[] pattern) { + System.out.println("过期key:" + message.toString()); + if(message.toString().contains(WeConstans.WE_EMPLE_CODE_KEY)){ + weExternalContactClient.delContactWay(message.toString().split(":")[1]); + } + } +} diff --git a/linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java b/linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java index 04881ebf4bcaf7408325db18e7ea2e8d461cf9a7..424a3fcc9384760c304cbcb59fd601d855f66887 100644 --- a/linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java +++ b/linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java @@ -72,7 +72,7 @@ public class UserDetailsServiceImpl implements UserDetailsService .userType(Constants.USER_TYPE_WECOME) .email(weUser.getEmail()) .phonenumber(weUser.getMobile()) - .sex(weUser.getGender().toString()) + .sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString()) .avatar(weUser.getAvatarMediaid()) .roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder() .roleKey(Constants.DEFAULT_WECOME_ROLE_KEY) diff --git a/linkwe-generator/src/main/java/com/linkwechat/generator/domain/GenTable.java b/linkwe-generator/src/main/java/com/linkwechat/generator/domain/GenTable.java index 238f0c1454f72db701835de782de513c7d119166..d06734f3c878df3439d625f795f133b2584eacb8 100644 --- a/linkwe-generator/src/main/java/com/linkwechat/generator/domain/GenTable.java +++ b/linkwe-generator/src/main/java/com/linkwechat/generator/domain/GenTable.java @@ -1,12 +1,13 @@ package com.linkwechat.generator.domain; -import java.util.List; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import org.apache.commons.lang3.ArrayUtils; import com.linkwechat.common.constant.GenConstants; import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.utils.StringUtils; +import org.apache.commons.lang3.ArrayUtils; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import java.util.List; /** * 业务表 gen_table @@ -28,11 +29,17 @@ public class GenTable extends BaseEntity @NotBlank(message = "表描述不能为空") private String tableComment; + /** 关联父表的表名 */ + private String subTableName; + + /** 本表关联父表的外键名 */ + private String subTableFkName; + /** 实体类名称(首字母大写) */ @NotBlank(message = "实体类名称不能为空") private String className; - /** 使用的模板(crud单表操作 tree树表操作) */ + /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ private String tplCategory; /** 生成包路径 */ @@ -64,6 +71,9 @@ public class GenTable extends BaseEntity /** 主键信息 */ private GenTableColumn pkColumn; + /** 子表信息 */ + private GenTable subTable; + /** 表列信息 */ @Valid private List columns; @@ -116,6 +126,26 @@ public class GenTable extends BaseEntity this.tableComment = tableComment; } + public String getSubTableName() + { + return subTableName; + } + + public void setSubTableName(String subTableName) + { + this.subTableName = subTableName; + } + + public String getSubTableFkName() + { + return subTableFkName; + } + + public void setSubTableFkName(String subTableFkName) + { + this.subTableFkName = subTableFkName; + } + public String getClassName() { return className; @@ -216,6 +246,16 @@ public class GenTable extends BaseEntity this.pkColumn = pkColumn; } + public GenTable getSubTable() + { + return subTable; + } + + public void setSubTable(GenTable subTable) + { + this.subTable = subTable; + } + public List getColumns() { return columns; @@ -286,6 +326,16 @@ public class GenTable extends BaseEntity this.parentMenuName = parentMenuName; } + public boolean isSub() + { + return isSub(this.tplCategory); + } + + public static boolean isSub(String tplCategory) + { + return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); + } + public boolean isTree() { return isTree(this.tplCategory); diff --git a/linkwe-generator/src/main/java/com/linkwechat/generator/util/GenUtils.java b/linkwe-generator/src/main/java/com/linkwechat/generator/util/GenUtils.java index 0b8fda991a670e2e8c277f0e5f01100e52aa2292..bc620d3fd1857c9a026ff9094929224c4574bb41 100644 --- a/linkwe-generator/src/main/java/com/linkwechat/generator/util/GenUtils.java +++ b/linkwe-generator/src/main/java/com/linkwechat/generator/util/GenUtils.java @@ -1,12 +1,13 @@ package com.linkwechat.generator.util; -import java.util.Arrays; -import org.apache.commons.lang3.RegExUtils; import com.linkwechat.common.constant.GenConstants; import com.linkwechat.common.utils.StringUtils; import com.linkwechat.generator.config.GenConfig; import com.linkwechat.generator.domain.GenTable; import com.linkwechat.generator.domain.GenTableColumn; +import org.apache.commons.lang3.RegExUtils; + +import java.util.Arrays; /** * 代码生成器 工具类 @@ -40,13 +41,14 @@ public class GenUtils column.setCreateBy(table.getCreateBy()); // 设置java字段名 column.setJavaField(StringUtils.toCamelCase(columnName)); + // 设置默认类型 + column.setJavaType(GenConstants.TYPE_STRING); - if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { - column.setJavaType(GenConstants.TYPE_STRING); // 字符串长度超过500设置为文本域 Integer columnLength = getColumnLength(column.getColumnType()); - String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; + String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; column.setHtmlType(htmlType); } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) @@ -111,6 +113,21 @@ public class GenUtils { column.setHtmlType(GenConstants.HTML_SELECT); } + // 图片字段设置图片上传控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "image")) + { + column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); + } + // 文件字段设置文件上传控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "file")) + { + column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); + } + // 内容字段设置富文本控件 + else if (StringUtils.endsWithIgnoreCase(columnName, "content")) + { + column.setHtmlType(GenConstants.HTML_EDITOR); + } } /** diff --git a/linkwe-generator/src/main/java/com/linkwechat/generator/util/VelocityUtils.java b/linkwe-generator/src/main/java/com/linkwechat/generator/util/VelocityUtils.java index 65b6c3f5d993e33857fc629473f66900937989e3..830c2e8543e305809447ef1aa9a58eac43053592 100644 --- a/linkwe-generator/src/main/java/com/linkwechat/generator/util/VelocityUtils.java +++ b/linkwe-generator/src/main/java/com/linkwechat/generator/util/VelocityUtils.java @@ -63,6 +63,10 @@ public class VelocityUtils { setTreeVelocityContext(velocityContext, genTable); } + if (GenConstants.TPL_SUB.equals(tplCategory)) + { + setSubVelocityContext(velocityContext, genTable); + } return velocityContext; } @@ -96,6 +100,24 @@ public class VelocityUtils } } + public static void setSubVelocityContext(VelocityContext context, GenTable genTable) + { + GenTable subTable = genTable.getSubTable(); + String subTableName = genTable.getSubTableName(); + String subTableFkName = genTable.getSubTableFkName(); + String subClassName = genTable.getSubTable().getClassName(); + String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); + + context.put("subTable", subTable); + context.put("subTableName", subTableName); + context.put("subTableFkName", subTableFkName); + context.put("subTableFkClassName", subTableFkClassName); + context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); + context.put("subClassName", subClassName); + context.put("subclassName", StringUtils.uncapitalize(subClassName)); + context.put("subImportList", getImportList(genTable.getSubTable())); + } + /** * 获取模板信息 * @@ -199,6 +221,37 @@ public class VelocityUtils return basePackage; } + + /** + * 根据列类型获取导入包 + * + * @param genTable 业务表对象 + * @return 返回需要导入的包列表 + */ + public static HashSet getImportList(GenTable genTable) + { + List columns = genTable.getColumns(); + GenTable subGenTable = genTable.getSubTable(); + HashSet importList = new HashSet(); + if (StringUtils.isNotNull(subGenTable)) + { + importList.add("java.util.List"); + } + for (GenTableColumn column : columns) + { + if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) + { + importList.add("java.util.Date"); + importList.add("com.fasterxml.jackson.annotation.JsonFormat"); + } + else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) + { + importList.add("java.math.BigDecimal"); + } + } + return importList; + } + /** * 根据列类型获取导入包 * diff --git a/linkwe-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/linkwe-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml index eeda40dc2413165a2a3377988bff114ffd8373a9..12788eda49d98b8a0b0b360c976150753279aeb2 100644 --- a/linkwe-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml +++ b/linkwe-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -116,5 +116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{tableId} + + + delete from gen_table_column where column_id in + + #{item.columnId} + + \ No newline at end of file diff --git a/linkwe-generator/src/main/resources/vm/java/controller.java.vm b/linkwe-generator/src/main/resources/vm/java/controller.java.vm index 6a2275c5148a8585a60c79537726a91b1a961c16..4e4309d346981ec9ccc103434d0dbf0b0945e5ed 100644 --- a/linkwe-generator/src/main/resources/vm/java/controller.java.vm +++ b/linkwe-generator/src/main/resources/vm/java/controller.java.vm @@ -1,6 +1,9 @@ package ${packageName}.controller; import java.util.List; +import java.util.Arrays; + +import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -11,15 +14,15 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import Log; -import BaseController; -import AjaxResult; -import BusinessType; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; -import ExcelUtil; -#if($table.crud) -import TableDataInfo; +import com.ruoyi.common.utils.poi.ExcelUtil; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.page.TableDataInfo; #elseif($table.tree) #end @@ -29,29 +32,27 @@ import TableDataInfo; * @author ${author} * @date ${datetime} */ +@RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController -@RequestMapping("/${moduleName}/${businessName}") -public class ${ClassName}Controller extends BaseController -{ - @Autowired - private I${ClassName}Service ${className}Service; +@RequestMapping("/${moduleName}/${businessName}" ) +public class ${ClassName}Controller extends BaseController { + + private final I${ClassName}Service i${ClassName}Service; /** * 查询${functionName}列表 */ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @GetMapping("/list") -#if($table.crud) - public TableDataInfo list(${ClassName} ${className}) - { +#if($table.crud || $table.sub) + public TableDataInfo list(${ClassName} ${className}) { startPage(); - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + List<${ClassName}> list = i${ClassName}Service.queryList(${className}); return getDataTable(list); } #elseif($table.tree) - public AjaxResult list(${ClassName} ${className}) - { - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + public AjaxResult list(${ClassName} ${className}) { + List<${ClassName}> list = i${ClassName}Service.queryList(${className}); return AjaxResult.success(list); } #end @@ -59,56 +60,51 @@ public class ${ClassName}Controller extends BaseController /** * 导出${functionName}列表 */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") - @Log(title = "${functionName}", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(${ClassName} ${className}) - { - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')" ) + @Log(title = "${functionName}" , businessType = BusinessType.EXPORT) + @GetMapping("/export" ) + public AjaxResult export(${ClassName} ${className}) { + List<${ClassName}> list = i${ClassName}Service.queryList(${className}); ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); - return util.exportExcel(list, "${businessName}"); + return util.exportExcel(list, "${businessName}" ); } /** * 获取${functionName}详细信息 */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") - @GetMapping(value = "/{${pkColumn.javaField}}") - public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) - { - return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField})); + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')" ) + @GetMapping(value = "/{${pkColumn.javaField}}" ) + public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) { + return AjaxResult.success(i${ClassName}Service.getById(${pkColumn.javaField})); } /** * 新增${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") - @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')" ) + @Log(title = "${functionName}" , businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody ${ClassName} ${className}) - { - return toAjax(${className}Service.insert${ClassName}(${className})); + public AjaxResult add(@RequestBody ${ClassName} ${className}) { + return toAjax(i${ClassName}Service.save(${className}) ? 1 : 0); } /** * 修改${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") - @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')" ) + @Log(title = "${functionName}" , businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody ${ClassName} ${className}) - { - return toAjax(${className}Service.update${ClassName}(${className})); + public AjaxResult edit(@RequestBody ${ClassName} ${className}) { + return toAjax(i${ClassName}Service.updateById(${className}) ? 1 : 0); } /** * 删除${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") - @Log(title = "${functionName}", businessType = BusinessType.DELETE) - @DeleteMapping("/{${pkColumn.javaField}s}") - public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) - { - return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s)); + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')" ) + @Log(title = "${functionName}" , businessType = BusinessType.DELETE) + @DeleteMapping("/{${pkColumn.javaField}s}" ) + public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { + return toAjax(i${ClassName}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s)) ? 1 : 0); } } diff --git a/linkwe-generator/src/main/resources/vm/java/domain.java.vm b/linkwe-generator/src/main/resources/vm/java/domain.java.vm index c5f22514b484830d079f74b51360cd15769e573e..028b1eafecd828bc3a9480a5b45a455f8f85d842 100644 --- a/linkwe-generator/src/main/resources/vm/java/domain.java.vm +++ b/linkwe-generator/src/main/resources/vm/java/domain.java.vm @@ -1,16 +1,19 @@ package ${packageName}.domain; -#foreach ($import in $importList) -import ${import}; -#end -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import Excel; -#if($table.crud) -import BaseEntity; -#elseif($table.tree) -import TreeEntity; -#end +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.Date; +import java.util.Map; +import java.util.HashMap; +import java.math.BigDecimal; /** * ${functionName}对象 ${tableName} @@ -18,17 +21,16 @@ import TreeEntity; * @author ${author} * @date ${datetime} */ -#if($table.crud) -#set($Entity="BaseEntity") -#elseif($table.tree) -#set($Entity="TreeEntity") -#end -public class ${ClassName} extends ${Entity} -{ - private static final long serialVersionUID = 1L; +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("${tableName}") +public class ${ClassName} implements Serializable { + +private static final long serialVersionUID=1L; #foreach ($column in $columns) -#if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ #if($column.list) #set($parentheseIndex=$column.columnComment.indexOf("(")) @@ -38,48 +40,22 @@ public class ${ClassName} extends ${Entity} #set($comment=$column.columnComment) #end #if($parentheseIndex != -1) - @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + @Excel(name = "${comment}" , readConverterExp = "$column.readConverterExp()") #elseif($column.javaType == 'Date') - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "${comment}" , width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") #else @Excel(name = "${comment}") #end #end +#if($column.isPk==1) + @TableId(value = "$column.columnName") private $column.javaType $column.javaField; - -#end -#end -#foreach ($column in $columns) -#if(!$table.isSuperColumn($column.javaField)) -#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) -#set($AttrName=$column.javaField) #else -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -#end - public void set${AttrName}($column.javaType $column.javaField) - { - this.$column.javaField = $column.javaField; - } - - public $column.javaType get${AttrName}() - { - return $column.javaField; - } + private $column.javaType $column.javaField; #end #end - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) -#foreach ($column in $columns) -#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) -#set($AttrName=$column.javaField) -#else -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -#end - .append("${column.javaField}", get${AttrName}()) -#end - .toString(); - } + @TableField(exist = false) + private Map params = new HashMap<>(); } diff --git a/linkwe-generator/src/main/resources/vm/java/mapper.java.vm b/linkwe-generator/src/main/resources/vm/java/mapper.java.vm index 172eb59253046c85c0a83688003f9e9353ffec05..bba2b15f7563da424244bd3b7ee0fe78ad089e24 100644 --- a/linkwe-generator/src/main/resources/vm/java/mapper.java.vm +++ b/linkwe-generator/src/main/resources/vm/java/mapper.java.vm @@ -1,61 +1,14 @@ package ${packageName}.mapper; -import java.util.List; import ${packageName}.domain.${ClassName}; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * ${functionName}Mapper接口 - * + * * @author ${author} * @date ${datetime} */ -public interface ${ClassName}Mapper -{ - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return ${functionName} - */ - public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}); +public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName}集合 - */ - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int insert${ClassName}(${ClassName} ${className}); - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int update${ClassName}(${ClassName} ${className}); - - /** - * 删除${functionName} - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return 结果 - */ - public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}); - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的数据ID - * @return 结果 - */ - public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s); } diff --git a/linkwe-generator/src/main/resources/vm/java/service.java.vm b/linkwe-generator/src/main/resources/vm/java/service.java.vm index 1217d53cf4e63765d42a1c05752301def103b2d7..97fe2d5c3fd84eb760a40894a0f92fd14e3a8e45 100644 --- a/linkwe-generator/src/main/resources/vm/java/service.java.vm +++ b/linkwe-generator/src/main/resources/vm/java/service.java.vm @@ -1,61 +1,19 @@ package ${packageName}.service; -import java.util.List; import ${packageName}.domain.${ClassName}; +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; /** * ${functionName}Service接口 - * + * * @author ${author} * @date ${datetime} */ -public interface I${ClassName}Service -{ - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return ${functionName} - */ - public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}); - - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName}集合 - */ - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int insert${ClassName}(${ClassName} ${className}); - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int update${ClassName}(${ClassName} ${className}); - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}ID - * @return 结果 - */ - public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s); +public interface I${ClassName}Service extends IService<${ClassName}> { /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return 结果 + * 查询列表 */ - public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}); + List<${ClassName}> queryList(${ClassName} ${className}); } diff --git a/linkwe-generator/src/main/resources/vm/java/serviceImpl.java.vm b/linkwe-generator/src/main/resources/vm/java/serviceImpl.java.vm index 4b3a180ac95374c5a810d3523753d09c63c8a8a2..f149763435c70d3b5e052b31926dcff411f53053 100644 --- a/linkwe-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/linkwe-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -1,109 +1,114 @@ package ${packageName}.service.impl; -import java.util.List; -#foreach ($column in $columns) -#if($column.javaField == 'createTime' || $column.javaField == 'updateTime') -import DateUtils; -#break -#end -#end -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.apache.commons.lang3.StringUtils; import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; +import java.util.List; +import java.util.Map; + /** * ${functionName}Service业务层处理 - * + * * @author ${author} * @date ${datetime} */ @Service -public class ${ClassName}ServiceImpl implements I${ClassName}Service -{ - @Autowired - private ${ClassName}Mapper ${className}Mapper; +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return ${functionName} - */ @Override - public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) - { - return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField}); - } - - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName} - */ - @Override - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) - { - return ${className}Mapper.select${ClassName}List(${className}); - } - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - @Override - public int insert${ClassName}(${ClassName} ${className}) - { -#foreach ($column in $columns) -#if($column.javaField == 'createTime') - ${className}.setCreateTime(DateUtils.getNowDate()); + public List<${ClassName}> queryList(${ClassName} ${className}) { + LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); +#foreach($column in $columns) +#set($queryType=$column.queryType) +#set($javaField=$column.javaField) +#set($javaType=$column.javaType) +#set($columnName=$column.columnName) +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#if($column.query) +#if($column.queryType == "EQ") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } #end +#elseif($queryType == "NE") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } #end - return ${className}Mapper.insert${ClassName}(${className}); - } - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - @Override - public int update${ClassName}(${ClassName} ${className}) - { -#foreach ($column in $columns) -#if($column.javaField == 'updateTime') - ${className}.setUpdateTime(DateUtils.getNowDate()); +#elseif($queryType == "GT") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } #end +#elseif($queryType == "GTE") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } #end - return ${className}Mapper.update${ClassName}(${className}); - } - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}ID - * @return 结果 - */ - @Override - public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s) - { - return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s); - } - - /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return 结果 - */ - @Override - public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) - { - return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField}); +#elseif($queryType == "LT") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#end +#elseif($queryType == "LTE") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#end +#elseif($queryType == "LIKE") +#if($javaType == 'String') + if (StringUtils.isNotBlank(${className}.get$AttrName())){ + lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#else + if (${className}.get$AttrName() != null){ + lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName()); + } +#end +#elseif($queryType == "BETWEEN") + Map params = ${className}.getParams(); + if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) { + lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"),params.get("end$AttrName")); + } +#end +#end +#end + return this.list(lqw); } } diff --git a/linkwe-generator/src/main/resources/vm/sql/sql.vm b/linkwe-generator/src/main/resources/vm/sql/sql.vm index bfd71945e258122920299fb2e99bc482e96230fe..057558350ca33f70499732c336a93e0e2d14060d 100644 --- a/linkwe-generator/src/main/resources/vm/sql/sql.vm +++ b/linkwe-generator/src/main/resources/vm/sql/sql.vm @@ -1,22 +1,22 @@ -- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单'); +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); -- 按钮父菜单ID SELECT @parentId := LAST_INSERT_ID(); -- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}查询', @parentId, '1', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}新增', @parentId, '2', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}修改', @parentId, '3', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}删除', @parentId, '4', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}导出', @parentId, '5', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); \ No newline at end of file +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/linkwe-generator/src/main/resources/vm/vue/index-tree.vue.vm b/linkwe-generator/src/main/resources/vm/vue/index-tree.vue.vm index f487eb15134d054fb387ed73e78d36a96b766ee6..bc244c913ff1b907e86c9e7c0a294134f19856fe 100644 --- a/linkwe-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/linkwe-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -38,20 +38,33 @@ -#elseif($column.htmlType == "datetime") +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") - +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + + + #end #end #end - 搜索 + 搜索 重置 @@ -60,6 +73,7 @@ +#elseif($column.htmlType == "imageUpload") + + + +#elseif($column.htmlType == "fileUpload") + + + +#elseif($column.htmlType == "editor") + + + #elseif($column.htmlType == "select" && "" != $dictType) @@ -193,10 +219,10 @@ #elseif($column.htmlType == "datetime") - @@ -221,10 +247,48 @@ import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload") +import ImageUpload from '@/components/ImageUpload'; +#break +#end +#end +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") +import FileUpload from '@/components/FileUpload'; +#break +#end +#end +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") +import Editor from '@/components/Editor'; +#break +#end +#end export default { name: "${BusinessName}", - components: { Treeselect }, + components: { +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload") + ImageUpload, +#break +#end +#end +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") + FileUpload, +#break +#end +#end +#foreach($column in $columns) +#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor") + Editor, +#break +#end +#end + Treeselect + }, data() { return { // 遮罩层 @@ -249,6 +313,10 @@ export default { #if(${column.dictType} != '') // $comment字典 ${column.javaField}Options: [], +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + // $comment时间范围 + daterange${AttrName}: [], #end #end // 查询参数 @@ -273,7 +341,7 @@ export default { #set($comment=$column.columnComment) #end $column.javaField: [ - { required: true, message: "$comment不能为空", trigger: "#if($column.htmlType == "select")"change"#else"blur"#end" } + { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } ]#if($velocityCount != $columns.size()),#end #end @@ -295,6 +363,21 @@ export default { /** 查询${functionName}列表 */ getList() { this.loading = true; +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + this.queryParams.params = {}; +#break +#end +#end +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { + this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; + this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1]; + } +#end +#end list${BusinessName}(this.queryParams).then(response => { this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}"); this.loading = false; @@ -363,6 +446,12 @@ export default { }, /** 重置按钮操作 */ resetQuery() { +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + this.daterange${AttrName} = []; +#end +#end this.resetForm("queryForm"); this.handleQuery(); }, @@ -402,19 +491,15 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - } + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); }); } else { add${BusinessName}(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - } + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); }); } } @@ -431,7 +516,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }).catch(function() {}); + }) } } }; diff --git a/linkwe-generator/src/main/resources/vm/vue/index.vue.vm b/linkwe-generator/src/main/resources/vm/vue/index.vue.vm index d688b7d1c8fdb51b57e8181a8a9a3c161b87bcff..c6b6573e39be710cf862e0fa0d9be884d49dd7e7 100644 --- a/linkwe-generator/src/main/resources/vm/vue/index.vue.vm +++ b/linkwe-generator/src/main/resources/vm/vue/index.vue.vm @@ -38,20 +38,33 @@ -#elseif($column.htmlType == "datetime") +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") - +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + + + #end #end #end - 搜索 + 搜索 重置 @@ -60,6 +73,7 @@ 导出 - + @@ -109,7 +126,7 @@ #set($comment=$column.columnComment) #end #if($column.pk) - + #elseif($column.list && $column.htmlType == "datetime")