提交 b06bbb42 编写于 作者: L linkwechat8856@163.com

欢迎语模板api升级

上级 526b2180
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.StringUtils;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import com.linkwechat.wecom.service.IWeMsgTlpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 欢迎语模板Controller
*
......@@ -30,8 +27,6 @@ public class WeMsgTlpController extends BaseController
private IWeMsgTlpService weMsgTlpService;
@Autowired
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板列表
......@@ -41,54 +36,40 @@ public class WeMsgTlpController extends BaseController
public TableDataInfo list(WeMsgTlp weMsgTlp)
{
startPage();
List<WeMsgTlp> list = weMsgTlpService.selectWeMsgTlpList(weMsgTlp);
return getDataTable(list);
}
/**
* 获取欢迎语模板详细信息
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:query')")
@GetMapping(value = "/scop/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return getDataTable(weMsgTlpService.list(
new LambdaQueryWrapper<WeMsgTlp>()
.like(StringUtils.isNotEmpty(weMsgTlp.getWelcomeMsg()),WeMsgTlp::getWelcomeMsg,weMsgTlp.getWelcomeMsg())
.eq(weMsgTlp.getWelcomeMsgTplType() !=null,WeMsgTlp::getWelcomeMsgTplType,weMsgTlp.getWelcomeMsgTplType())
.like(StringUtils.isNotEmpty(weMsgTlp.getUserIds()),WeMsgTlp::getUserIds,weMsgTlp.getUserIds())
));
return AjaxResult.success(
iWeMsgTlpScopeService.selectWeMsgTlpScopeList(WeMsgTlpScope.builder().msgTlpId(id).build())
);
}
/**
* 新增欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:add')")
@Log(title = "新增欢迎语模板", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp)
@PostMapping(value = "/addorUpdate")
public AjaxResult addorUpdate(@RequestBody WeMsgTlp weMsgTlp)
{
return toAjax(weMsgTlpService.insertWeMsgTlp(weMsgTlp));
}
/**
* 修改欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:edit')")
@Log(title = "修改欢迎语模板", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WeMsgTlp weMsgTlp)
{
return toAjax(weMsgTlpService.updateWeMsgTlp(weMsgTlp));
weMsgTlpService.addorUpdate(weMsgTlp);
return AjaxResult.success();
}
/**
* 删除欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:remove')")
@Log(title = "删除欢迎语模板", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/remove/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(weMsgTlpService.batchRemoveByids(Arrays.asList(ids)));
weMsgTlpService.removeByIds(CollectionUtil.toList(ids));
return AjaxResult.success();
}
}
......@@ -2,6 +2,7 @@ package com.linkwechat.framework.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
......
package com.linkwechat.wecom.domain;
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 com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.handler.GenericTypeHandler;
import io.swagger.models.auth.In;
import lombok.Data;
......@@ -15,29 +19,75 @@ import java.util.List;
* @date 2020-10-04
*/
@Data
@TableName("we_msg_tlp")
public class WeMsgTlp extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();
@TableId
private Long id;
/** 欢迎语 */
private String welcomeMsg;
/** 素材的id */
private Long mediaId;
/**图片url*/
private String picUrl;
/**图文*/
@TableField(typeHandler = GenericTypeHandler.class)
private ImageText imageText;
/**小程序*/
@TableField(typeHandler = GenericTypeHandler.class)
private Applet applet;
/** 0:正常;1:删除; */
private Integer delFlag=new Integer(0);
private Integer delFlag;
/** 欢迎语模板类型:1:活码欢迎语;2:员工欢迎语;3:入群欢迎语 */
private Integer welcomeMsgTplType;
/**用户名 */
private String userNames;
/**用户id,用逗号隔开*/
private String userIds;
@Data
public static class Applet{
//小程序标题
private String appTile;
//小程序id
private String appId;
//小程序路径
private String appPath;
//小程序图片
private String appPic;
}
@Data
public static class ImageText{
/** 欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语 */
private Long welcomeMsgTplType;
//图文标题
private String imageTextTile;
/** 欢迎语模板使用范围 */
private List<WeMsgTlpScope> weMsgTlpScopes;
//图文url
private String imageTextUrl;
private String materialUrl;
}
......
package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.experimental.SuperBuilder;
import lombok.Data;
/**
* 模板使用人员范围对象 we_msg_tlp_scope
*
* @author ruoyi
* @date 2020-10-04
*/
@Data
@SuperBuilder
public class WeMsgTlpScope extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();
/** 模板id */
@Excel(name = "模板id")
private Long msgTlpId;
/** 使用人id */
@Excel(name = "使用人id")
private Long useUserId;
/** 0:正常;1:删除; */
private Integer delFlag=new Integer(0);
}
package com.linkwechat.wecom.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMsgTlp;
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 <T>
*/
@SuppressWarnings("all")
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class, WeMsgTlp.Applet.class,WeMsgTlp.ImageText.class})
@MappedJdbcTypes(value = {JdbcType.VARCHAR}, includeNullJdbcType = true)
public class GenericTypeHandler<T extends Object> extends BaseTypeHandler<T> {
private Class<T> clazz;
public GenericTypeHandler(Class<T> 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;
}
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeMsgTlp;
import org.apache.ibatis.annotations.Param;
......@@ -10,7 +12,7 @@ import org.apache.ibatis.annotations.Param;
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpMapper
public interface WeMsgTlpMapper extends BaseMapper<WeMsgTlp>
{
/**
* 查询欢迎语模板
......@@ -20,13 +22,13 @@ public interface WeMsgTlpMapper
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
// /**
// * 查询欢迎语模板列表
// *
// * @param weMsgTlp 欢迎语模板
// * @return 欢迎语模板集合
// */
// public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import org.apache.ibatis.annotations.Param;
/**
* 模板使用人员范围Mapper接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpScopeMapper
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 删除模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(@Param("weMsgTlpScopes") List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 模板id,批量删除
* @param msgTlpIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> msgTlpIds);
}
package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
/**
* 模板使用人员范围Service接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpScopeService
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 通过使用者id批量删除
* @param useUserIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds);
}
package com.linkwechat.wecom.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeMsgTlp;
/**
......@@ -9,23 +9,9 @@ import com.linkwechat.wecom.domain.WeMsgTlp;
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpService
public interface IWeMsgTlpService extends IService<WeMsgTlp>
{
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......@@ -33,37 +19,7 @@ public interface IWeMsgTlpService
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
public int insertWeMsgTlp(WeMsgTlp weMsgTlp);
void addorUpdate(WeMsgTlp weMsgTlp);
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
public int updateWeMsgTlp(WeMsgTlp weMsgTlp);
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpByIds(Long[] ids);
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpById(Long id);
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
public int batchRemoveByids(List<Long> msgTlpIds);
}
package com.linkwechat.wecom.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpScopeMapper;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
/**
* 模板使用人员范围Service业务层处理
*
* @author ruoyi
* @date 2020-10-04
*/
@Service
public class WeMsgTlpScopeServiceImpl implements IWeMsgTlpScopeService
{
@Autowired
private WeMsgTlpScopeMapper weMsgTlpScopeMapper;
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
@Override
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeById(id);
}
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围
*/
@Override
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeList(weMsgTlpScope);
}
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.insertWeMsgTlpScope(weMsgTlpScope);
}
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.updateWeMsgTlpScope(weMsgTlpScope);
}
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeByIds(Long[] ids)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeByIds(ids);
}
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeById(id);
}
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
@Override
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes) {
return weMsgTlpScopeMapper.batchInsetWeMsgTlpScope(weMsgTlpScopes);
}
/**
* 通过使用者id,批量删除
* @param useUserIds
* @return
*/
@Override
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds) {
return weMsgTlpScopeMapper.batchRemoveWeMsgTlpScopesByMsgTlpIds(useUserIds);
}
}
package com.linkwechat.wecom.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpMapper;
......@@ -24,37 +23,12 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2020-10-04
*/
@Service
public class WeMsgTlpServiceImpl implements IWeMsgTlpService
public class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> implements IWeMsgTlpService
{
@Autowired
private WeMsgTlpMapper weMsgTlpMapper;
@Autowired
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
@Override
public WeMsgTlp selectWeMsgTlpById(Long id)
{
return weMsgTlpMapper.selectWeMsgTlpById(id);
}
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板
*/
@Override
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp)
{
return weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp);
}
@Autowired
private IWeUserService iWeUserService;
/**
* 新增欢迎语模板
......@@ -63,91 +37,34 @@ public class WeMsgTlpServiceImpl implements IWeMsgTlpService
* @return 结果
*/
@Override
public int insertWeMsgTlp(WeMsgTlp weMsgTlp)
@Transactional
public void addorUpdate(WeMsgTlp weMsgTlp)
{
weMsgTlp.setCreateBy(SecurityUtils.getUsername());
weMsgTlp.setCreateTime(new Date());
return weMsgTlpMapper.insertWeMsgTlp(weMsgTlp);
// if(returnCode>0){
// List<WeMsgTlpScope> weMsgTlpScopess = weMsgTlp.getWeMsgTlpScopes();
// if(CollectionUtil.isNotEmpty(weMsgTlpScopess)){
//
// List<WeMsgTlpScope> weMsgTlpScopes=weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
//
// weMsgTlpScopes.forEach(v->{
// v.setMsgTlpId(weMsgTlp.getId());
// v.setId(SnowFlakeUtil.nextId());
// });
//
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
// }
// return returnCode;
}
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
@Override
public int updateWeMsgTlp(WeMsgTlp weMsgTlp)
{
// int returnCode = weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
//
// if(returnCode>0){
// iWeMsgTlpScopeService.batchRemoveWeMsgTlpScopesByMsgTlpIds(ListUtil.toList(weMsgTlp.getId()));
// List<WeMsgTlpScope> weMsgTlpScopes = weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
//
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
// weMsgTlpScopes.stream().forEach(v->v.setMsgTlpId(weMsgTlp.getId()));
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
return weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
}
if(weMsgTlp.getWelcomeMsgTplType()
.equals(new Integer(2))) {
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpByIds(Long[] ids)
{
return weMsgTlpMapper.deleteWeMsgTlpByIds(ids);
}
String userIds = weMsgTlp.getUserIds();
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpById(Long id)
{
return weMsgTlpMapper.deleteWeMsgTlpById(id);
}
if (StringUtils.isNotEmpty(userIds)) {
List<WeUser> weUsers = iWeUserService.listByIds(
ListUtil.toList(userIds.split(","))
);
if (CollectionUtil.isNotEmpty(weUsers)) {
weMsgTlp.setUserNames(String.join(",",
weUsers.stream().map(WeUser::getName).collect(Collectors.toList())));
}
}
}
this.saveOrUpdate(weMsgTlp);
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
@Override
public int batchRemoveByids(List<Long> msgTlpIds) {
return weMsgTlpMapper.batchRemoveByids(msgTlpIds);
}
}
......@@ -19,25 +19,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, welcome_msg, media_id, del_flag, welcome_msg_tpl_type,create_by,create_time from we_msg_tlp
</sql>
<select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">
SELECT
wmt.id,
wmt.welcome_msg,
wmt.media_id,
wmt.del_flag,
wmt.welcome_msg_tpl_type,
wmt.create_by,
wmt.create_time,
wm.material_url
FROM
we_msg_tlp wmt
LEFT JOIN we_material wm ON wmt.media_id=wm.id
<where>
<if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>
<if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>
and wmt.del_flag = 0
</where>
</select>
<!-- <select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">-->
<!-- SELECT-->
<!-- wmt.id,-->
<!-- wmt.welcome_msg,-->
<!-- wmt.media_id,-->
<!-- wmt.del_flag,-->
<!-- wmt.welcome_msg_tpl_type,-->
<!-- wmt.create_by,-->
<!-- wmt.create_time,-->
<!-- wm.material_url-->
<!-- FROM-->
<!-- we_msg_tlp wmt-->
<!-- LEFT JOIN we_material wm ON wmt.media_id=wm.id-->
<!-- <where> -->
<!-- <if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>-->
<!-- <if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>-->
<!-- and wmt.del_flag = 0-->
<!-- </where>-->
<!-- </select>-->
<select id="selectWeMsgTlpById" parameterType="Long" resultMap="WeMsgTlpResult">
......
<?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.WeMsgTlpScopeMapper">
<resultMap type="WeMsgTlpScope" id="WeMsgTlpScopeResult">
<result property="id" column="id" />
<result property="msgTlpId" column="msg_tlp_id" />
<result property="useUserId" column="use_user_id" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectWeMsgTlpScopeVo">
select id, msg_tlp_id, use_user_id, del_flag from we_msg_tlp_scope
</sql>
<select id="selectWeMsgTlpScopeList" parameterType="WeMsgTlpScope" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
<where>
<if test="msgTlpId != null "> and msg_tlp_id = #{msgTlpId}</if>
<if test="useUserId != null "> and use_user_id = #{useUserId}</if>
</where>
</select>
<select id="selectWeMsgTlpScopeById" parameterType="Long" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
where id = #{id}
</select>
<insert id="insertWeMsgTlpScope" parameterType="WeMsgTlpScope">
insert into we_msg_tlp_scope
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="msgTlpId != null">msg_tlp_id,</if>
<if test="useUserId != null">use_user_id,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="msgTlpId != null">#{msgTlpId},</if>
<if test="useUserId != null">#{useUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateWeMsgTlpScope" parameterType="WeMsgTlpScope">
update we_msg_tlp_scope
<trim prefix="SET" suffixOverrides=",">
<if test="msgTlpId != null">msg_tlp_id = #{msgTlpId},</if>
<if test="useUserId != null">use_user_id = #{useUserId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeMsgTlpScopeById" parameterType="Long">
delete from we_msg_tlp_scope where id = #{id}
</delete>
<delete id="deleteWeMsgTlpScopeByIds" parameterType="String">
delete from we_msg_tlp_scope where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsetWeMsgTlpScope">
insert into we_msg_tlp_scope (id,msg_tlp_id,use_user_id,del_flag)
values
<foreach collection="weMsgTlpScopes" item="scop" index="index" separator=",">
(#{scop.id},#{scop.msgTlpId},#{scop.useUserId},#{scop.delFlag})
</foreach>
</insert>
<update id="batchRemoveWeMsgTlpScopesByMsgTlpIds">
update we_msg_tlp_scope set
del_flag = 2
where msgTlpId in
<foreach collection="msgTlpIds" item="msgTlpId" index="index"
separator="," open="(" close=")">
#{msgTlpId.msgTlpId}
</foreach>
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册