公众号回复

This commit is contained in:
TinyAnts 2022-09-13 15:32:53 +08:00
parent ca8fc2dfae
commit 21431d751a
9 changed files with 206 additions and 41 deletions

View File

@ -1,4 +1,4 @@
package com.mdd.admin.controller.channel.oa;
package com.mdd.admin.controller.channel;
import com.mdd.admin.service.channel.IChannelOaMenuService;
import com.mdd.common.core.AjaxResult;
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 公众号菜单
* 公众号菜单管理
*/
@RestController
@RequestMapping("api/channel/oa/menu")

View File

@ -0,0 +1,46 @@
package com.mdd.admin.controller.channel;
import com.mdd.admin.service.channel.IChannelOaReplyService;
import com.mdd.common.core.AjaxResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
/**
* 公众号回复管理
*/
@RestController
@RequestMapping("api/channel/OaReply")
public class OaReplyController {
@Resource
IChannelOaReplyService iChannelOaReplyService;
@GetMapping("/list")
public Object list() {
return AjaxResult.success();
}
@GetMapping("/detail")
public Object detail() {
return AjaxResult.success();
}
@PostMapping("/add")
public Object add(@RequestBody Map<String, String> params) {
iChannelOaReplyService.add(params);
return AjaxResult.success();
}
@PostMapping("/edit")
public Object edit() {
return AjaxResult.success();
}
@PostMapping("/del")
public Object del() {
return AjaxResult.success();
}
}

View File

@ -1,15 +0,0 @@
package com.mdd.admin.controller.channel.oa;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 公众号默认回复
*/
@RestController
@RequestMapping("api/channel/oa/defaultReply")
public class OaDefaultReplyController {
}

View File

@ -1,12 +0,0 @@
package com.mdd.admin.controller.channel.oa;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 公众号关注回复
*/
@RestController
@RequestMapping("api/channel/oa/followReply")
public class OaFollowReplyController {
}

View File

@ -1,12 +0,0 @@
package com.mdd.admin.controller.channel.oa;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 公众号关键词回复
*/
@RestController
@RequestMapping("api/channel/oa/keywordReply")
public class OaKeywordReplyController {
}

View File

@ -0,0 +1,17 @@
package com.mdd.admin.service.channel;
import java.util.Map;
public interface IChannelOaReplyService {
Object list();
Object detail();
void add(Map<String, String> params);
void edit();
void del();
}

View File

@ -0,0 +1,98 @@
package com.mdd.admin.service.channel.impl;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.mdd.admin.service.channel.IChannelOaReplyService;
import com.mdd.common.entity.OfficialReply;
import com.mdd.common.entity.server.Sys;
import com.mdd.common.exception.OperateException;
import com.mdd.common.mapper.OfficialReplyMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Map;
@Service
public class ChannelOaReplyServiceImpl implements IChannelOaReplyService {
@Resource
OfficialReplyMapper officialReplyMapper;
@Override
public Object list() {
return null;
}
@Override
public Object detail() {
return null;
}
@Override
public void add(Map<String, String> params) {
String type = params.getOrDefault("type", "");
OfficialReply officialReply = new OfficialReply();
switch (type) {
case "follow":
Assert.notNull(params.get("name"), "规则名称不能为空");
Assert.notNull(params.get("contentType"), "请正确选择回复类型");
Assert.notNull(params.get("content"), "回复内容不能为空");
Assert.notNull(params.get("status"), "请正确选择状态");
officialReply.setName(params.get("name"));
officialReply.setReplyType(1);
officialReply.setContentType(Integer.parseInt(params.get("replyType")));
officialReply.setContent(params.get("content"));
officialReply.setStatus(Integer.parseInt(params.get("status")));
officialReply.setCreateTime(System.currentTimeMillis() / 1000);
officialReply.setUpdateTime(System.currentTimeMillis() / 1000);
officialReplyMapper.insert(officialReply);
break;
case "keyword":
Assert.notNull(params.get("name"), "规则名称不能为空");
Assert.notNull(params.get("keyword"), "关键词不能为空");
Assert.notNull(params.get("matchingType"), "请正确选择匹配模式");
Assert.notNull(params.get("contentType"), "请正确选择回复类型");
Assert.notNull(params.get("content"), "回复内容不能为空");
Assert.notNull(params.get("status"), "请正确选择状态");
officialReply.setName(params.get("name"));
officialReply.setKeyword(params.get("keyword"));
officialReply.setMatchingType(Integer.parseInt(params.get("matchingType")));
officialReply.setReplyType(2);
officialReply.setContent(params.get("content"));
officialReply.setContentType(Integer.parseInt(params.get("contentType")));
officialReply.setStatus(Integer.parseInt(params.get("status")));
officialReply.setCreateTime(System.currentTimeMillis() / 1000);
officialReply.setUpdateTime(System.currentTimeMillis() / 1000);
officialReplyMapper.insert(officialReply);
break;
case "default":
Assert.notNull(params.get("name"), "规则名称不能为空");
Assert.notNull(params.get("contentType"), "请正确选择回复类型");
Assert.notNull(params.get("content"), "回复内容不能为空");
Assert.notNull(params.get("status"), "请正确选择状态");
officialReply.setName(params.get("name"));
officialReply.setReplyType(3);
officialReply.setMatchingType(Integer.parseInt(params.get("matchingType")));
officialReply.setStatus(Integer.parseInt(params.get("status")));
officialReply.setCreateTime(System.currentTimeMillis() / 1000);
officialReply.setUpdateTime(System.currentTimeMillis() / 1000);
officialReplyMapper.insert(officialReply);
break;
default:
throw new OperateException("不被支持的类型");
}
}
@Override
public void edit() {
}
@Override
public void del() {
}
}

View File

@ -0,0 +1,31 @@
package com.mdd.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
/**
* 公众号回复实体
*/
@Data
public class OfficialReply implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Integer id; // 主键ID
private String name; // 规则名
private String keyword; // 关键词
private Integer replyType; // 回复类型: [1=关注回复 2=关键字回复, 3=默认回复]
private Integer matchingType; // 匹配方式: [1=全匹配, 2=模糊匹配]
private Integer contentType; // 内容类型: [1=文本]
private Integer status; // 启动状态: [1=启动, 0=关闭]
private String content; // 回复内容
private Integer sort; // 排序编号
private Long createTime; // 创建时间
private Long updateTime; // 更新时间
private Long deleteTime; // 删除时间
}

View File

@ -0,0 +1,12 @@
package com.mdd.common.mapper;
import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.OfficialReply;
import org.apache.ibatis.annotations.Mapper;
/**
* 公众号回复Mapper
*/
@Mapper
public interface OfficialReplyMapper extends IBaseMapper<OfficialReply> {
}