|
@ -0,0 +1,141 @@
|
|
|
package com.yihu.wlyy.web.doctor.template;
|
|
|
|
|
|
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
|
|
|
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
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;
|
|
|
|
|
|
/**
|
|
|
* 医生健康指导模板
|
|
|
* <p>
|
|
|
* Created by lyr on 2017/2/3.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/doctor/guidance_temp")
|
|
|
@Api(description = "医生健康指导模板")
|
|
|
public class DoctorGuidanceTempController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
DoctorGuidanceTempService guidanceTempService;
|
|
|
|
|
|
/**
|
|
|
* 添加指导模板
|
|
|
*
|
|
|
* @param content
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "添加指导模板")
|
|
|
public String add(@RequestParam @ApiParam(value = "指导内容") String content) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
return error(-1, "内容不能为空");
|
|
|
}
|
|
|
|
|
|
DoctorGuidanceTemp temp = guidanceTempService.add(getUID(), content);
|
|
|
|
|
|
if (temp != null) {
|
|
|
return write(200, "添加成功");
|
|
|
} else {
|
|
|
return write(-1, "添加失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改指导模板
|
|
|
*
|
|
|
* @param code
|
|
|
* @param content
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/modify", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "修改指导模板")
|
|
|
public String modify(@RequestParam @ApiParam(value = "指导编码") String code,
|
|
|
@RequestParam @ApiParam(value = "指导内容") String content) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(code)) {
|
|
|
return error(-1, "请指定需修改的模板");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
return error(-1, "内容不能为空");
|
|
|
}
|
|
|
|
|
|
DoctorGuidanceTemp temp = guidanceTempService.modify(code, content);
|
|
|
|
|
|
if (temp != null) {
|
|
|
return write(200, "修改成功");
|
|
|
} else {
|
|
|
return write(-1, "修改失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "修改失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除指导模板
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "删除指导模板")
|
|
|
public String delete(@RequestParam @ApiParam(value = "指导编码") String code) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(code)) {
|
|
|
return error(-1, "请指定需删除的模板");
|
|
|
}
|
|
|
|
|
|
int result = guidanceTempService.delete(code);
|
|
|
|
|
|
if (result == 1) {
|
|
|
return write(200, "删除成功");
|
|
|
} else {
|
|
|
return write(-1, "删除失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询指导模板
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "查询指导模板")
|
|
|
public String list(@RequestParam(required = false, defaultValue = "")
|
|
|
@ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type) {
|
|
|
try {
|
|
|
List<DoctorGuidanceTemp> temps = guidanceTempService.list(getUID(), type);
|
|
|
|
|
|
if (temps == null || temps.size() < 1) {
|
|
|
return write(200, "查询成功", "data", new JSONArray());
|
|
|
} else {
|
|
|
return write(200, "查询成功", "data", new JSONArray(temps));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
}
|