Commit b7982c24 by danmo

重构活码功能

1 parent 2839fb90
Showing 36 changed files with 1505 additions and 8 deletions
...@@ -8,6 +8,7 @@ import com.linkwechat.common.core.domain.AjaxResult; ...@@ -8,6 +8,7 @@ import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.domain.Tree; import com.linkwechat.common.core.domain.Tree;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeCategory; import com.linkwechat.wecom.domain.WeCategory;
import com.linkwechat.wecom.domain.vo.WeCategoryVo;
import com.linkwechat.wecom.service.IWeCategoryService; import com.linkwechat.wecom.service.IWeCategoryService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -26,7 +27,7 @@ import java.util.List; ...@@ -26,7 +27,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/wecom/category") @RequestMapping("/wecom/category")
@Api("企业微信素材分类") @Api(tags = "企业微信素材分类")
public class WeCategoryController extends BaseController { public class WeCategoryController extends BaseController {
@Autowired @Autowired
...@@ -37,7 +38,7 @@ public class WeCategoryController extends BaseController { ...@@ -37,7 +38,7 @@ public class WeCategoryController extends BaseController {
// @PreAuthorize("@ss.hasPermi('wechat:category:list')") // @PreAuthorize("@ss.hasPermi('wechat:category:list')")
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("类目树") @ApiOperation("类目树")
public AjaxResult list(@RequestParam("mediaType") String mediaType) { public AjaxResult<WeCategoryVo> list(@RequestParam("mediaType") String mediaType) {
return AjaxResult.success(weCategoryService.findWeCategoryByMediaType(mediaType)); return AjaxResult.success(weCategoryService.findWeCategoryByMediaType(mediaType));
} }
...@@ -47,7 +48,7 @@ public class WeCategoryController extends BaseController { ...@@ -47,7 +48,7 @@ public class WeCategoryController extends BaseController {
// @PreAuthorize("@ss.hasPermi('wechat:category:query')") // @PreAuthorize("@ss.hasPermi('wechat:category:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiOperation("通过id查询类目详细信息") @ApiOperation("通过id查询类目详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id) { public AjaxResult<WeCategoryVo> getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(weCategoryService.getById(id)); return AjaxResult.success(weCategoryService.getById(id));
} }
...@@ -99,4 +100,6 @@ public class WeCategoryController extends BaseController { ...@@ -99,4 +100,6 @@ public class WeCategoryController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
} }
...@@ -60,6 +60,11 @@ public class WeConstans { ...@@ -60,6 +60,11 @@ public class WeConstans {
public static final String WE_EMPLE_CODE_KEY = "we_emple_code_key"; public static final String WE_EMPLE_CODE_KEY = "we_emple_code_key";
/**
* 活码前缀
*/
public static final String WE_QR_CODE_PREFIX = "we_qr";
/** /**
* 企业微信接口返回成功code * 企业微信接口返回成功code
......
package com.linkwechat.common.core.domain; package com.linkwechat.common.core.domain;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ApiModel
@Data @Data
public class Tree<T> { public class Tree<T> {
...@@ -20,6 +22,12 @@ public class Tree<T> { ...@@ -20,6 +22,12 @@ public class Tree<T> {
private String name; private String name;
/** /**
* 名称
*/
@ApiModelProperty("可删除标识 0 可删除 1 不可删除")
private Integer flag;
/**
* 父的叶子信息 * 父的叶子信息
*/ */
@ApiModelProperty(name = "children", value = "父的叶子信息") @ApiModelProperty(name = "children", value = "父的叶子信息")
......
...@@ -25,7 +25,7 @@ public class WeCategory extends BaseEntity { ...@@ -25,7 +25,7 @@ public class WeCategory extends BaseEntity {
private Long id; private Long id;
@ApiModelProperty("素材分类:0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本") @ApiModelProperty("素材分类:0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file) 4 文本 5 海报 6 活码")
private String mediaType; private String mediaType;
...@@ -38,7 +38,8 @@ public class WeCategory extends BaseEntity { ...@@ -38,7 +38,8 @@ public class WeCategory extends BaseEntity {
@ApiModelProperty("素材上级父节点id") @ApiModelProperty("素材上级父节点id")
private Long parentId; private Long parentId;
@ApiModelProperty("可删除标识 0 可删除 1 不可删除")
private Integer flag;
@ApiModelProperty("素材状态:0 未删除 2 已删除") @ApiModelProperty("素材状态:0 未删除 2 已删除")
private String delFlag; private String delFlag;
......
package com.linkwechat.wecom.domain;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
/**
* 活码附件表(WeQrAttachments)表实体类
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
@ApiModel
@Data
@SuppressWarnings("serial")
@TableName("we_qr_attachments")
public class WeQrAttachments extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; //1
/**
* 主键id
*/
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
@TableField("id")
private Long id;
/**
* 活码id
*/
@ApiModelProperty(value = "活码id")
@TableField("qr_id")
private Long qrId;
/**
* 消息类型 文本:text 图片:image 图文:link 小程序:miniprogram 视频:video 文件:file
*/
@ApiModelProperty(value = "消息类型 文本:text 图片:image 图文:link 小程序:miniprogram 视频:video 文件:file ")
@TableField("msg_type")
private String msgType;
/**
* 消息内容
*/
@ApiModelProperty(value = "消息内容")
@TableField("content")
private String content;
/**
* 媒体id
*/
@ApiModelProperty(value = "媒体id")
@TableField("media_id")
private String mediaId;
/**
* 消息标题
*/
@ApiModelProperty(value = "消息标题")
@TableField("title")
private String title;
/**
* 消息描述
*/
@ApiModelProperty(value = "消息描述")
@TableField("description")
private String description;
/**
* 文件路径
*/
@ApiModelProperty(value = "文件路径")
@TableField("file_url")
private String fileUrl;
/**
* 消息链接
*/
@ApiModelProperty(value = "消息链接")
@TableField("link_url")
private String linkUrl;
/**
* 消息图片地址
*/
@ApiModelProperty(value = "消息图片地址")
@TableField("pic_url")
private String picUrl;
/**
* 小程序appid
*/
@ApiModelProperty(value = "小程序appid")
@TableField("app_id")
private String appId;
/**
* 删除标识 0 有效 1删除
*/
@ApiModelProperty(value = "删除标识 0 有效 1删除",hidden = true)
@TableField("del_flag")
private Integer delFlag;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 活码信息表(WeQrCode)$desc
*
* @author danmo
* @since 2021-11-07 02:24:34
*/
@ApiModel
@Data
@SuppressWarnings("serial")
@TableName("we_qr_code")
public class WeQrCode extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; //1
/**
* 主键id
*/
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
@TableField("id")
private Long id;
/**
* 活码名称
*/
@ApiModelProperty(value = "活码名称")
@TableField("name")
private String name;
/**
* 活码分组id
*/
@ApiModelProperty(value = "活码分组id")
@TableField("group_id")
private Long groupId;
/**
* 添加是否无需验证 0:否 1:是
*/
@ApiModelProperty(value = "添加是否无需验证 0:否 1:是")
@TableField("auto_add")
private Integer autoAdd;
/**
* 活码类型 1:单人 2:多人
*/
@ApiModelProperty(value = "活码类型 1:单人 2:多人")
@TableField("type")
private Integer type;
/**
* 排期类型 1:全天 2:自定义
*/
@ApiModelProperty(value = "排期类型 1:全天 2:自定义")
@TableField("rule_type")
private Integer ruleType;
/**
* 添加渠道
*/
@ApiModelProperty(value = "添加渠道")
@TableField("state")
private String state;
/**
* 二维码配置id
*/
@ApiModelProperty(value = "二维码配置id")
@TableField("config_id")
private String configId;
/**
* 二维码地址
*/
@ApiModelProperty(value = "二维码地址")
@TableField("qr_code")
private String qrCode;
/**
* 删除标识 0 有效 1删除
*/
@ApiModelProperty(value = "删除标识 0 有效 1删除",hidden = true)
@TableField("del_flag")
private Integer delFlag;
}
package com.linkwechat.wecom.domain;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
/**
* 活码使用范围表(WeQrScope)表实体类
*
* @author makejava
* @since 2021-11-07 01:29:14
*/
@ApiModel
@Data
@SuppressWarnings("serial")
@TableName("we_qr_scope")
public class WeQrScope extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; //1
/**
* 主键id
*/
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
@TableField("id")
private Long id;
/**
* 活码id
*/
@ApiModelProperty(value = "活码id")
@TableField("qr_id")
private Long qrId;
/**
* 排期分组id
*/
@ApiModelProperty(value = "排期分组id")
@TableField("scope_id")
private String scopeId;
/**
* 消息类型 0 默认排期 1 自定义排期
*/
@ApiModelProperty(value = "消息类型 0 默认排期 1 自定义排期")
@TableField("type")
private Integer type;
/**
* 范围类型 1-员工 2-部门
*/
@ApiModelProperty(value = "范围类型 1-员工 2-部门")
@TableField("scope_type")
private Integer scopeType;
/**
* 部门id
*/
@ApiModelProperty(value = "部门id")
@TableField("party")
private String party;
/**
* 员工id
*/
@ApiModelProperty(value = "员工id")
@TableField("user_id")
private String userId;
/**
* 周期时间
*/
@ApiModelProperty(value = "周期时间")
@TableField("work_cycle")
private String workCycle;
/**
* 删除标识 0 有效 1删除
*/
@ApiModelProperty(value = "删除标识 0 有效 1删除",hidden = true)
@TableField("del_flag")
private Integer delFlag;
}
package com.linkwechat.wecom.domain;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
/**
* 活码标签关联表(WeQrTagRel)表实体类
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
@ApiModel
@Data
@SuppressWarnings("serial")
@TableName("we_qr_tag_rel")
public class WeQrTagRel extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; //1
/**
* 主键id
*/
@ApiModelProperty(value = "主键id")
@TableId(type = IdType.AUTO)
@TableField("id")
private Long id;
/**
* 活码id
*/
@ApiModelProperty(value = "活码id")
@TableField("qr_id")
private Long qrId;
/**
* 标签id
*/
@ApiModelProperty(value = "标签id")
@TableField("tag_id")
private String tagId;
/**
* 删除标识 0 有效 1删除
*/
@ApiModelProperty(value = "删除标识 0 有效 1删除",hidden = true)
@TableField("del_flag")
private Integer delFlag;
}
package com.linkwechat.wecom.domain.query.qr;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.BooleanUtils;
import java.util.List;
/**
* @author danmo
* @description 活码新增入参
* @date 2021/11/7 13:49
**/
@ApiModel
@Data
public class WeQrAddQuery {
@ApiModelProperty("名称")
private String qrName;
@ApiModelProperty("分组id")
private Long qrGroupId;
@ApiModelProperty("是否自动添加 1-是 0-否")
private Integer qrAutoAdd;
@ApiModelProperty("标签id列表")
private List<String> qrTags;
@ApiModelProperty("活码类型 1-单人, 2-多人")
private Integer qrType;
@ApiModelProperty("排班类型 1-全天 2-自动")
private Integer qrRuleType;
@ApiModelProperty("活码员工列表")
private List<WeQrUserInfoQuery> qrUserInfos;
@ApiModelProperty("欢迎语素材列表")
private List<WeMessageTemplate> attachments;
@ApiModelProperty(value = "渠道",hidden = true)
private static String state;
static {
Snowflake snowflake = IdUtil.getSnowflake(RandomUtil.randomLong(6), RandomUtil.randomInt(6));
state = snowflake.nextIdStr();
}
/**
* 企微接口参数生成方法
*
* @return 企微接口参数实体类
*/
public WeExternalContactDto.WeContactWay getWeContactWay() {
WeExternalContactDto.WeContactWay weContactWay = new WeExternalContactDto.WeContactWay();
//根据类型生成相应的活码
weContactWay.setType(this.qrType);
weContactWay.setScene(WeConstans.QR_CODE_EMPLE_CODE_SCENE);
weContactWay.setSkip_verify(BooleanUtils.toBoolean(this.qrAutoAdd));
weContactWay.setState(WeConstans.WE_QR_CODE_PREFIX + "_" + state);
if (CollectionUtil.isNotEmpty(qrUserInfos)) {
//员工列表
String[] userIdArr = qrUserInfos.stream().filter(item ->
ObjectUtil.equal(1, item.getType())).map(WeQrUserInfoQuery::getUserIds).toArray(String[]::new);
if (userIdArr.length > 0) {
weContactWay.setUser(userIdArr);
}
//部门列表
Long[] partyArr = qrUserInfos.stream().filter(item ->
ObjectUtil.equal(1, item.getType())).map(WeQrUserInfoQuery::getPartys).toArray(Long[]::new);
if (partyArr.length > 0) {
weContactWay.setParty(partyArr);
}
}
return weContactWay;
}
/**
* 获取数据表实体
* @return
* @param configId 二维码配置ID
* @param qrCode 二维码链接
*/
public WeQrCode getWeQrCodeEntity(String configId, String qrCode){
WeQrCode weQrCode = new WeQrCode();
weQrCode.setName(this.qrName);
weQrCode.setAutoAdd(this.qrAutoAdd);
weQrCode.setGroupId(this.getQrGroupId());
weQrCode.setType(this.qrType);
weQrCode.setRuleType(this.qrRuleType);
weQrCode.setState(state);
weQrCode.setConfigId(configId);
weQrCode.setQrCode(qrCode);
return weQrCode;
}
}
package com.linkwechat.wecom.domain.query.qr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author danmo
* @description 活码员工排期入参
* @date 2021/11/7 13:58
**/
@ApiModel
@Data
public class WeQrUserInfoQuery {
@ApiModelProperty("排班员工类型 1-默认 2-自定义")
private Integer type;
@ApiModelProperty("部门id列表")
private List<Integer> partys;
@ApiModelProperty("员工id列表")
private List<String> userIds;
@ApiModelProperty("工作周期")
private List<Integer> workCycle;
@ApiModelProperty("开始时间")
private String beginTime;
@ApiModelProperty("结束时间")
private String endTime;
}
package com.linkwechat.wecom.domain.vo.qr;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeQrAttachments;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author sxw
* @description 活码详情出参
* @date 2021/11/8 22:15
**/
@ApiModel
@Data
public class WeQrCodeDetailVo extends WeQrCode {
@ApiModelProperty("分组名称")
private String qrGroupName;
@ApiModelProperty("标签")
private List<WeTagVo> qrTags;
@ApiModelProperty("适用范围")
private List<WeQrScopeVo> qrUserInfos;
@ApiModelProperty("素材")
private List<WeQrAttachments> qrAttachments;
}
package com.linkwechat.wecom.domain.vo.qr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author danmo
* @description 活码排期部门信息
* @date 2021/11/8 0:19
**/
@ApiModel
@Data
public class WeQrScopePartyVo {
@ApiModelProperty(value = "部门id")
private String party;
@ApiModelProperty(value = "部门名称")
private String partyName;
}
package com.linkwechat.wecom.domain.vo.qr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author danmo
* @description 活码排期员工信息
* @date 2021/11/8 0:18
**/
@ApiModel
@Data
public class WeQrScopeUserVo {
@ApiModelProperty(value = "员工id")
private String userId;
@ApiModelProperty(value = "员工姓名")
private String userName;
}
package com.linkwechat.wecom.domain.vo.qr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author sxw
* @description 活码适用范围出参
* @date 2021/11/8 22:33
**/
@ApiModel
@Data
public class WeQrScopeVo {
@ApiModelProperty(value = "消息类型 0 默认排期 1 自定义排期")
private Integer type;
@ApiModelProperty(value = "周期时间")
private String workCycle;
@ApiModelProperty(value = "开始时间")
private String beginTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty("员工姓名")
private List<WeQrScopeUserVo> weQrUserList;
@ApiModelProperty("部门名称")
private List<WeQrScopePartyVo> weQrPartyList;
}
package com.linkwechat.wecom.domain.vo.tag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author danmo
* @description 标签出参
* @date 2021/11/8 21:34
**/
@ApiModel
@Data
public class WeTagVo {
@ApiModelProperty("标签Id")
private String tagId;
@ApiModelProperty("标签名称")
private String tagName;
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.annotation.SqlParser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import com.linkwechat.wecom.domain.WeQrAttachments;
/**
* 活码附件表(WeQrAttachments)Mapper接口
*
* @author makejava
* @since 2021-11-07 01:29:12
*/
@Repository()
@Mapper
public interface WeQrAttachmentsMapper extends BaseMapper<WeQrAttachments> {
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 活码信息表(WeQrCode)
*
* @author danmo
* @since 2021-11-07 02:30:11
*/
@Repository()
@Mapper
public interface WeQrCodeMapper extends BaseMapper<WeQrCode> {
/**
* 根据活码id查询详情
* @param qrId 活码id
* @return
*/
WeQrCodeDetailVo getQrDetailByQrId(Long qrId);
/**
* 根据活码id批量查询详情
* @param qrIds 活码id
* @return
*/
List<WeQrCodeDetailVo> getQrDetailByQrIds(List<Long> qrIds);
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.annotation.SqlParser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import com.linkwechat.wecom.domain.WeQrScope;
/**
* 活码使用范围表(WeQrScope)Mapper接口
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
@Repository()
@Mapper
public interface WeQrScopeMapper extends BaseMapper<WeQrScope> {
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.annotation.SqlParser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import com.linkwechat.wecom.domain.WeQrTagRel;
/**
* 活码标签关联表(WeQrTagRel)Mapper接口
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
@Repository()
@Mapper
public interface WeQrTagRelMapper extends BaseMapper<WeQrTagRel> {
}
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeTag; import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -79,4 +80,11 @@ public interface WeTagMapper extends BaseMapper<WeTag> ...@@ -79,4 +80,11 @@ public interface WeTagMapper extends BaseMapper<WeTag>
* @return * @return
*/ */
public int batchUpdateWeTag(List<WeTag> weTags); public int batchUpdateWeTag(List<WeTag> weTags);
/**
* 根据标签id批量查询
* @param tagIds
* @return
*/
List<WeTagVo> selectWeTagByIds(List<String> tagIds);
} }
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.domain.WeQrAttachments;
import java.util.List;
/**
* 活码素材表(WeQrAttachments)表服务接口
*
* @author makejava
* @since 2021-11-07 01:29:12
*/
public interface IWeQrAttachmentsService extends IService<WeQrAttachments> {
/**
* 通过活码id批量保存活码欢迎语素材
* @param qrId 活码id
* @param attachments 素材列表
*/
void saveBatchByQrId(Long qrId, List<WeMessageTemplate> attachments);
/**
* 通过活码id批量删除活码欢迎语素材
* @param qrIds 活码id
* @return
*/
Boolean delBatchByQrIds(List<Long> qrIds);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.query.qr.WeQrAddQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import java.util.List;
/**
* 活码信息表(WeQrCode)$desc
*
* @author danmo
* @since 2021-11-07 02:10:51
*/
public interface IWeQrCodeService extends IService<WeQrCode> {
/**
* 新增员工活码
* @param weQrAddQuery 入参
*/
void addQrCode(WeQrAddQuery weQrAddQuery);
/**
* 获取活码详情
* @param qrId
* @return
*/
WeQrCodeDetailVo getQrDetail(Long qrId);
/**
* 删除活码
*/
void delQrCode(List<Long> qrIds);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.domain.WeQrScope;
import java.util.List;
/**
* 活码使用范围表(WeQrScope)表服务接口
*
* @author makejava
* @since 2021-11-07 01:29:14
*/
public interface IWeQrScopeService extends IService<WeQrScope> {
/**
* 通过活码id批量保存适用范围
* @param qrId 活码id
* @param qrUserInfos 适用范围列表
*/
void saveBatchByQrId(Long qrId, List<WeQrUserInfoQuery> qrUserInfos);
/**
* 通过活码id批量删除适用范围
* @param qrIds 活码id
* @return
*/
Boolean delBatchByQrIds(List<Long> qrIds);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.domain.WeQrTagRel;
import java.util.List;
/**
* 活码标签关联表(WeQrTagRel)表服务接口
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
public interface IWeQrTagRelService extends IService<WeQrTagRel> {
/**
* 通过活码id批量保存活码标签
* @param qrId
* @param qrTags
*/
void saveBatchByQrId(Long qrId, List<String> qrTags);
/**
* 通过活码id批量删除活码标签
* @param qrIds
*/
Boolean delBatchByQrIds(List<Long> qrIds);
}
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeTag; import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.dto.WeTagDto; import com.linkwechat.wecom.domain.dto.WeTagDto;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
/** /**
* 企业微信标签Service接口 * 企业微信标签Service接口
...@@ -75,4 +76,12 @@ public interface IWeTagService extends IService<WeTag> ...@@ -75,4 +76,12 @@ public interface IWeTagService extends IService<WeTag>
void deleteTag(String tagId); void deleteTag(String tagId);
void updateTag(String tagId); void updateTag(String tagId);
/**
* 根据标签id查询企业微信标签
*
* @param ids 企业微信标签ID
* @return WeTagVo
*/
List<WeTagVo> selectWeTagByIds(List<String> ids);
} }
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import com.linkwechat.wecom.domain.WeQrAttachments;
import com.linkwechat.wecom.mapper.WeQrAttachmentsMapper;
import com.linkwechat.wecom.service.IWeQrAttachmentsService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 活码附件表(WeQrAttachments)表服务实现类
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
//@DS("db1")
@Service
public class IWeQrAttachmentsServiceImpl extends ServiceImpl<WeQrAttachmentsMapper, WeQrAttachments> implements IWeQrAttachmentsService {
@Override
public void saveBatchByQrId(Long qrId, List<WeMessageTemplate> attachments) {
List<WeQrAttachments> attachmentsList = Optional.ofNullable(attachments)
.orElseGet(ArrayList::new).stream().map(weQrAttachmentsQuery -> {
WeQrAttachments weQrAttachments = new WeQrAttachments();
BeanUtil.copyProperties(weQrAttachmentsQuery, weQrAttachments);
weQrAttachments.setQrId(qrId);
return weQrAttachments;
}).collect(Collectors.toList());
saveBatch(attachmentsList);
}
@Override
public Boolean delBatchByQrIds(List<Long> qrIds) {
WeQrAttachments weQrAttachments = new WeQrAttachments();
weQrAttachments.setDelFlag(1);
return this.update(weQrAttachments,new LambdaQueryWrapper<WeQrAttachments>().in(WeQrAttachments::getQrId,qrIds));
}
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.mapper.WeQrScopeMapper;
import com.linkwechat.wecom.domain.WeQrScope;
import com.linkwechat.wecom.service.IWeQrScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 活码使用范围表(WeQrScope)表服务实现类
*
* @author makejava
* @since 2021-11-07 01:29:14
*/
//@DS("db1")
@Service
public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScope> implements IWeQrScopeService {
public IWeQrScopeServiceImpl() {
}
@Autowired
private WeQrScopeMapper weQrScopeMapper;
@Override
public void saveBatchByQrId(Long qrId, List<WeQrUserInfoQuery> qrUserInfos) {
if (CollectionUtil.isNotEmpty(qrUserInfos)) {
List<WeQrScope> scopeList = new ArrayList<>();
for (WeQrUserInfoQuery userInfo : qrUserInfos) {
String uuId = RandomUtil.randomString(18);
List<WeQrScope> weQrScopeUserList = Optional.ofNullable(userInfo.getUserIds()).orElseGet(ArrayList::new).stream().map(userId -> {
WeQrScope weQrScope = new WeQrScope();
weQrScope.setQrId(qrId);
weQrScope.setScopeId(uuId);
weQrScope.setUserId(userId);
weQrScope.setScopeType(1);
weQrScope.setWorkCycle(userInfo.getWorkCycle().stream().map(String::valueOf).collect(Collectors.joining(",")));
weQrScope.setBeginTime(userInfo.getBeginTime());
weQrScope.setEndTime(userInfo.getEndTime());
return weQrScope;
}).collect(Collectors.toList());
scopeList.addAll(weQrScopeUserList);
List<WeQrScope> weQrScopePartyList = Optional.ofNullable(userInfo.getPartys()).orElseGet(ArrayList::new).stream().map(party -> {
WeQrScope weQrScope = new WeQrScope();
weQrScope.setQrId(qrId);
weQrScope.setScopeId(uuId);
weQrScope.setParty(String.valueOf(party));
weQrScope.setScopeType(2);
weQrScope.setWorkCycle(userInfo.getWorkCycle().stream().map(String::valueOf).collect(Collectors.joining(",")));
weQrScope.setBeginTime(userInfo.getBeginTime());
weQrScope.setEndTime(userInfo.getEndTime());
return weQrScope;
}).collect(Collectors.toList());
scopeList.addAll(weQrScopePartyList);
}
saveBatch(scopeList);
}
}
@Override
public Boolean delBatchByQrIds(List<Long> qrIds) {
WeQrScope weQrScope = new WeQrScope();
weQrScope.setDelFlag(1);
return this.update(weQrScope,new LambdaQueryWrapper<WeQrScope>().in(WeQrScope::getQrId,qrIds));
}
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeQrTagRel;
import com.linkwechat.wecom.mapper.WeQrTagRelMapper;
import com.linkwechat.wecom.service.IWeQrTagRelService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 活码标签关联表(WeQrTagRel)表服务实现类
*
* @author makejava
* @since 2021-11-07 01:29:13
*/
//@DS("db1")
@Service
public class IWeQrTagRelServiceImpl extends ServiceImpl<WeQrTagRelMapper, WeQrTagRel> implements IWeQrTagRelService {
@Override
public void saveBatchByQrId(Long qrId, List<String> qrTags) {
List<WeQrTagRel> tagRels = Optional.ofNullable(qrTags).orElseGet(ArrayList::new).stream().map(tagId -> {
WeQrTagRel weQrTagRel = new WeQrTagRel();
weQrTagRel.setQrId(qrId);
weQrTagRel.setTagId(tagId);
return weQrTagRel;
}).collect(Collectors.toList());
saveBatch(tagRels);
}
@Override
public Boolean delBatchByQrIds(List<Long> qrIds) {
WeQrTagRel weQrTagRel = new WeQrTagRel();
weQrTagRel.setDelFlag(1);
return this.update(weQrTagRel, new LambdaQueryWrapper<WeQrTagRel>().in(WeQrTagRel::getQrId,qrIds));
}
}
...@@ -68,6 +68,7 @@ public class WeCategoryServiceImpl extends ServiceImpl<WeCategoryMapper,WeCatego ...@@ -68,6 +68,7 @@ public class WeCategoryServiceImpl extends ServiceImpl<WeCategoryMapper,WeCatego
WeCategoryVo weCategoryVo = new WeCategoryVo(); WeCategoryVo weCategoryVo = new WeCategoryVo();
weCategoryVo.setId(c.getId()); weCategoryVo.setId(c.getId());
weCategoryVo.setName(c.getName()); weCategoryVo.setName(c.getName());
weCategoryVo.setFlag(c.getFlag());
weCategoryVo.setParentId(c.getParentId()); weCategoryVo.setParentId(c.getParentId());
weCategoryVos.add(weCategoryVo); weCategoryVos.add(weCategoryVo);
}); });
......
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeExternalContactClient;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.WeQrScope;
import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import com.linkwechat.wecom.domain.query.qr.WeQrAddQuery;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
import com.linkwechat.wecom.mapper.WeQrCodeMapper;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 活码信息表(WeQrCode)$desc
*
* @author danmo
* @since 2021-11-07 02:17:43
*/
@Service
public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> implements IWeQrCodeService {
@Autowired
private WeExternalContactClient externalContactClient;
@Autowired
private IWeQrTagRelService tagRelService;
@Autowired
private IWeQrScopeService scopeService;
@Autowired
private IWeQrAttachmentsService attachmentsService;
@Autowired
private IWeTagService weTagService;
/**
* 新增员工活码
*
* @param weQrAddQuery 入参
*/
@Override
public void addQrCode(WeQrAddQuery weQrAddQuery) {
//校验排期是否存在冲突
checkScope(weQrAddQuery.getQrUserInfos());
WeExternalContactDto.WeContactWay weContactWay = weQrAddQuery.getWeContactWay();
WeExternalContactDto resultDto = externalContactClient.addContactWay(weContactWay);
if (resultDto != null && ObjectUtil.equal(0, resultDto.getErrcode())) {
WeQrCode weQrCode = weQrAddQuery.getWeQrCodeEntity(resultDto.getConfig_id(), resultDto.getQr_code());
if (save(weQrCode)) {
//保存标签数据
tagRelService.saveBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrTags());
//保存活码范围数据
scopeService.saveBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrUserInfos());
//保存活码素材
attachmentsService.saveBatchByQrId(weQrCode.getId(), weQrAddQuery.getAttachments());
}
}
}
@Override
public WeQrCodeDetailVo getQrDetail(Long qrId) {
return this.baseMapper.getQrDetailByQrId(qrId);
}
@Override
public void delQrCode(List<Long> qrIds) {
List<WeQrCode> weQrCodes = this.listByIds(qrIds);
if(CollectionUtil.isNotEmpty(weQrCodes)){
weQrCodes.forEach(item -> item.setDelFlag(1));
if(this.updateBatchById(weQrCodes)){
//删除标签数据
tagRelService.delBatchByQrIds(qrIds);
//删除活码范围数据
scopeService.delBatchByQrIds(qrIds);
//删除活码素材
attachmentsService.delBatchByQrIds(qrIds);
}
//异步删除企微活码---最好使用mq
ThreadUtil.execute(() -> weQrCodes.forEach(item ->{
if(StringUtils.isNotEmpty(item.getConfigId())){
externalContactClient.delContactWay(item.getConfigId());
}
}));
}
}
/**
* 校验排期是否重复
*
* @param qrUserInfos 范围参数
*/
private void checkScope(List<WeQrUserInfoQuery> qrUserInfos) {
List<WeQrUserInfoQuery> qrUserInfoList = qrUserInfos.stream().filter(item -> ObjectUtil.equal(2, item.getType())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(qrUserInfoList)) {
for (int i = 0; i < qrUserInfoList.size() - 1; i++) {
for (int j = i + 1; j < qrUserInfoList.size(); j++) {
int finalJ = j;
long userSum = qrUserInfoList.get(i).getUserIds().stream()
.filter(one -> qrUserInfoList.get(finalJ).getUserIds().stream()
.anyMatch(two -> ObjectUtil.equal(two, one))).count();
long partySum = qrUserInfoList.get(i).getPartys().stream()
.filter(one -> qrUserInfoList.get(finalJ).getPartys().stream()
.anyMatch(two -> ObjectUtil.equal(two, one))).count();
if (userSum > 0 || partySum > 0) {
long workCycleSum = qrUserInfoList.get(i).getWorkCycle().stream()
.filter(one -> qrUserInfoList.get(finalJ).getWorkCycle().stream()
.anyMatch(two -> ObjectUtil.equal(two, one))).count();
if (workCycleSum > 0) {
String beginTime1 = qrUserInfoList.get(i).getBeginTime();
String endTime1 = qrUserInfoList.get(i).getEndTime();
String beginTime2 = qrUserInfoList.get(finalJ).getBeginTime();
String endTime2 = qrUserInfoList.get(finalJ).getEndTime();
if (match(beginTime1, endTime1, beginTime2, endTime2)) {
throw new WeComException("员工或部门时间有冲突!");
}
}
}
}
}
}
}
private boolean match(String startTime1, String endTime1, String startTime2, String endTime2) {
DateTime parseStartTime1 = DateUtil.parse(startTime1, "HH:mm");
DateTime parseEndTime1 = DateUtil.parse(endTime1, "HH:mm");
DateTime parseStartTime2 = DateUtil.parse(startTime2, "HH:mm");
DateTime parseEndTime2 = DateUtil.parse(endTime2, "HH:mm");
return !(parseStartTime2.isAfter(parseEndTime1) || parseStartTime1.isAfter(parseEndTime2));
}
}
...@@ -16,6 +16,7 @@ import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto; ...@@ -16,6 +16,7 @@ import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto; import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto;
import com.linkwechat.wecom.domain.dto.tag.WeCropTagDto; import com.linkwechat.wecom.domain.dto.tag.WeCropTagDto;
import com.linkwechat.wecom.domain.dto.tag.WeFindCropTagParam; import com.linkwechat.wecom.domain.dto.tag.WeFindCropTagParam;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
import com.linkwechat.wecom.service.IWeTagGroupService; import com.linkwechat.wecom.service.IWeTagGroupService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -188,4 +189,9 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements ...@@ -188,4 +189,9 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
} }
} }
} }
@Override
public List<WeTagVo> selectWeTagByIds(List<String> tagIds) {
return this.baseMapper.selectWeTagByIds(tagIds);
}
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeQrAttachmentsMapper">
<!--<cache type="yiche.scrm.config.mybatis.MybatisRedisCache"/>-->
<resultMap type="com.linkwechat.wecom.domain.WeQrAttachments" id="WeQrAttachmentsResult">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="qrId" column="qr_id" jdbcType="INTEGER"/>
<result property="msgType" column="msg_type" jdbcType="VARCHAR"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="mediaId" column="media_id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
<result property="linkUrl" column="link_url" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="appId" column="app_id" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="selectWeQrAttachmentsVo">
select id, qr_id, msg_type, content, media_id, title, description, file_url, link_url, pic_url, app_id, create_by, create_time, update_by, update_time, del_flag from we_qr_attachments
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeQrCodeMapper">
<!--<cache type="yiche.scrm.config.mybatis.MybatisRedisCache"/>-->
<resultMap type="com.linkwechat.wecom.domain.WeQrCode" id="WeQrCodeResult">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="autoAdd" column="auto_add" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="ruleType" column="rule_type" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="VARCHAR"/>
<result property="configId" column="config_id" jdbcType="VARCHAR"/>
<result property="qrCode" column="qr_code" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap type="com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo" id="WeQrCodeDetailResult">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="groupId" column="group_id" jdbcType="INTEGER"/>
<result property="autoAdd" column="auto_add" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="ruleType" column="rule_type" jdbcType="INTEGER"/>
<result property="state" column="state" jdbcType="VARCHAR"/>
<result property="configId" column="config_id" jdbcType="VARCHAR"/>
<result property="qrCode" column="qr_code" jdbcType="VARCHAR"/>
<collection property="qrTags" ofType="com.linkwechat.wecom.domain.vo.tag.WeTagVo">
<result property="tagId" column="tag_id" jdbcType="INTEGER"/>
</collection>
<collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo">
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="beginTime" column="begin_time" jdbcType="VARCHAR"/>
<result property="endTime" column="end_time" jdbcType="VARCHAR"/>
<result property="workCycle" column="work_cycle" jdbcType="VARCHAR"/>
<collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopeUserVo">
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
</collection>
<collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopePartyVo">
<result property="party" column="party" jdbcType="VARCHAR"/>
<result property="partyName" column="party_name" jdbcType="VARCHAR"/>
</collection>
</collection>
<collection property="qrAttachments" ofType="com.linkwechat.wecom.domain.WeQrAttachments">
<result property="msgType" column="msg_type" jdbcType="VARCHAR"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="linkUrl" column="link_url" jdbcType="VARCHAR"/>
<result property="mediaId" column="media_id" jdbcType="VARCHAR"/>
<result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
<result property="appId" column="app_id" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<sql id="selectWeQrCodeVo">
select id, name, group_id, auto_add, type, rule_type, state, scan_num, config_id, qr_code, create_by, create_time, update_by, update_time, del_flag from we_qr_code
</sql>
<sql id="selectWeQrCodeDetailVo">
select
wqc.id,
wqc.name,
wqc.group_id,
(select wc.name from we_category wc where wc.id = wqc.group_id limit 1) as group_name,
wqc.auto_add,
wqc.type,
wqc.rule_type,
wqc.state,
wqc.scan_num,
wqc.config_id,
wqc.qr_code,
wqtr.tag_id,
(select name from we_tag wt where wt.tag_id = wqtr.tag_id limit 1) as tag_name,
wqs.scope_id,
wqs.scope_type,
wqs.`type`,
wqs.begin_time,
wqs.end_time,
wqs.work_cycle,
wqs.user_id,
if(wqs.user_id is null,null,(select wu.user_name from we_user wu where wu.user_id = wqs.user_id limit 1)) as user_name,
wqs.party,
if(wqs.party is null,null,(select wd.name from we_department wd where wd.id= wqs.party limit 1)) as party_name,
wqa.msg_type,
wqa.content,
wqa.title,
wqa.description,
wqa.pic_url,
wqa.link_url,
wqa.media_id,
wqa.file_url,
wqa.app_id
from
we_qr_code wqc
left join we_qr_tag_rel wqtr on wqtr.qr_id = wqc.id and wqtr.del_flag = 0
left join we_qr_scope wqs on wqs.qr_id = wqc.id and wqs.del_flag = 0
left join we_qr_attachments wqa on wqa.qr_id = wqc.id and wqs.del_flag = 0
where 1=1
</sql>
<select id="getQrDetailByQrId" resultMap="WeQrCodeDetailResult">
<include refid="selectWeQrCodeDetailVo"/>
<if test="qrId != null">
and wqc.id = #{qrId}
</if>
</select>
<select id="getQrDetailByQrIds" resultMap="WeQrCodeDetailResult">
<include refid="selectWeQrCodeDetailVo"/>
<if test="qrIds != null and qrIds.size > 0">
and wqc.id in
<foreach item="qrId" collection="qrIds" index="index" open="(" separator="," close=")">
#{qrId}
</foreach>
</if>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeQrScopeMapper">
<!--<cache type="yiche.scrm.config.mybatis.MybatisRedisCache"/>-->
<resultMap type="com.linkwechat.wecom.domain.WeQrScope" id="WeQrScopeResult">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="qrId" column="qr_id" jdbcType="INTEGER"/>
<result property="scopeId" column="scope_id" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="scopeType" column="scope_type" jdbcType="INTEGER"/>
<result property="party" column="party" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="workCycle" column="work_cycle" jdbcType="VARCHAR"/>
<result property="beginTime" column="begin_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="selectWeQrScopeVo">
select id, qr_id, scope_id, type, scope_type, party, user_id, work_cycle, begin_time, end_time, create_by, create_time, update_by, update_time, del_flag from we_qr_scope
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeQrTagRelMapper">
<!--<cache type="yiche.scrm.config.mybatis.MybatisRedisCache"/>-->
<resultMap type="com.linkwechat.wecom.domain.WeQrTagRel" id="WeQrTagRelResult">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="qrId" column="qr_id" jdbcType="INTEGER"/>
<result property="tagId" column="tag_id" jdbcType="INTEGER"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="selectWeQrTagRelVo">
select id, qr_id, tag_id, create_by, create_time, update_by, update_time, del_flag from we_qr_tag_rel
</sql>
</mapper>
...@@ -5,10 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -5,10 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.linkwechat.wecom.mapper.WeTagMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeTagMapper">
<resultMap type="WeTag" id="WeTagResult"> <resultMap type="WeTag" id="WeTagResult">
<result property="id" column="id" /> <result property="tagId" column="id" />
<result property="groupId" column="group_id" /> <result property="groupId" column="group_id" />
<result property="name" column="name" /> <result property="name" column="name" />
<result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectWeTagVo"> <sql id="selectWeTagVo">
...@@ -27,7 +26,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -27,7 +26,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWeTagVo"/> <include refid="selectWeTagVo"/>
where id = #{id} and status=0 where id = #{id} and status=0
</select> </select>
<select id="selectWeTagByIds" resultType="com.linkwechat.wecom.domain.vo.tag.WeTagVo">
select tag_id, `name` as tag_name from we_tag
<where>
<if test="tagIds != null and tagIds.size() > 0">
and tag_id in
<foreach item="tagId" collection="tagIds" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select>
<insert id="insertWeTag" parameterType="WeTag"> <insert id="insertWeTag" parameterType="WeTag">
insert into we_tag insert into we_tag
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!