|
@ -0,0 +1,170 @@
|
|
|
package com.yihu.jw.door.controller.doctor;
|
|
|
|
|
|
import com.yihu.jw.door.controller.BaseController;
|
|
|
import com.yihu.jw.door.service.consult.DoctorQuickReplyService;
|
|
|
import com.yihu.jw.entity.door.DoctorQuickReply;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by lyr-pc on 2016/12/28.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/doctor/reply", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(description = "医生快捷回复")
|
|
|
public class DoctorQuickReplyController extends BaseController {
|
|
|
@Autowired
|
|
|
DoctorQuickReplyService quickReplyService;
|
|
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "添加快捷回复")
|
|
|
public String addReply(
|
|
|
@RequestParam(value = "content", required = true) @ApiParam(value = "快捷回复内容") String content,
|
|
|
@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
|
|
|
@RequestParam(value = "type", required = false, defaultValue = "0") String type) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
return error(-1, "快捷回复内容不能为空");
|
|
|
}
|
|
|
|
|
|
DoctorQuickReply reply = quickReplyService.addReply(getUID(), content,type);
|
|
|
|
|
|
if (reply != null) {
|
|
|
return write(200, "添加成功", "data", reply);
|
|
|
} else {
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/modify", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "修改快捷回复")
|
|
|
public String modifyReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id,
|
|
|
@RequestParam @ApiParam(value = "快捷回复内容") String content,
|
|
|
@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
|
|
|
@RequestParam(value = "type", required = false, defaultValue = "0") String type) {
|
|
|
try {
|
|
|
if (id == null || id < 1) {
|
|
|
return error(-1, "快捷回复ID不能为空");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
return error(-1, "快捷回复内容不能为空");
|
|
|
}
|
|
|
|
|
|
DoctorQuickReply reply = quickReplyService.modifyReply(id, content,type);
|
|
|
|
|
|
if (reply != null) {
|
|
|
return write(200, "添加成功", "data", reply);
|
|
|
} else {
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "删除快捷回复")
|
|
|
public String delReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id) {
|
|
|
try {
|
|
|
if (id == null || id < 1) {
|
|
|
return error(-1, "请选择需删除的快捷回复");
|
|
|
}
|
|
|
|
|
|
int result = quickReplyService.delReply(getUID(), id);
|
|
|
|
|
|
if (result == 1) {
|
|
|
return write(200, "删除成功");
|
|
|
} else if (result == -1) {
|
|
|
return error(-1, "快捷回复不存在或已删除");
|
|
|
} else {
|
|
|
return error(-1, "删除失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, "删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/sort", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "快捷回复排序")
|
|
|
public String sortReply(@RequestParam @ApiParam(value = "快捷回复ID")Long id,
|
|
|
@RequestParam @ApiParam(value = "排序位置")Integer sort) {
|
|
|
try {
|
|
|
if (id == null || id < 1) {
|
|
|
return error(-1, "请选择排序的快捷回复");
|
|
|
}
|
|
|
if (sort == null || sort < 1) {
|
|
|
return error(-1, "请设置快捷回复的排序位置");
|
|
|
}
|
|
|
|
|
|
int result = quickReplyService.sortReply(getUID(), id, sort);
|
|
|
|
|
|
if (result == 1) {
|
|
|
return write(200, "排序成功");
|
|
|
} else if (result == -1) {
|
|
|
return error(-1, "快捷回复不存在或已删除");
|
|
|
} else if (result == -2) {
|
|
|
return error(-1, "快捷回复已在排序位置");
|
|
|
} else {
|
|
|
return error(-1, "排序失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "排序失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/sortList", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "快捷回复排序")
|
|
|
public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id,
|
|
|
@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
|
|
|
@RequestParam(value = "type", required = false, defaultValue = "0") String type) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
return error(-1, "请输入排序后的回复ID");
|
|
|
}
|
|
|
|
|
|
int result = quickReplyService.sortReplyList(id,type);
|
|
|
|
|
|
if (result == 1) {
|
|
|
return write(200, "排序成功");
|
|
|
} else if (result == -1) {
|
|
|
return error(-1, "快捷回复不存在或已删除");
|
|
|
} else if (result == -2) {
|
|
|
return error(-1, "快捷回复已在排序位置");
|
|
|
} else {
|
|
|
return error(-1, "排序失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, "排序失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "快捷回复列表")
|
|
|
public String replyList(@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
|
|
|
@RequestParam(value = "type", required = false, defaultValue = "0") String type,
|
|
|
@ApiParam(name = "keyword", value = "搜索关键字", defaultValue = "")
|
|
|
@RequestParam(value = "keyword", required = false, defaultValue = "") String keyword) {
|
|
|
try {
|
|
|
List<DoctorQuickReply> replies = quickReplyService.getDoctorReplyList(getUID(),type,keyword);
|
|
|
return write(200, "查询成功", "data", replies);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
}
|