Browse Source

医生端指导模板查询返回值修改

wujunjie 8 years ago
parent
commit
523150a94d

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorGuidanceTempDao.java

@ -16,9 +16,9 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    int deleteByCode(String code);
    @Query("select t.code,t.owner,t.sendTimes,t.createTime,t.modelName from DoctorGuidanceTemp t where t.owner = ?1 order by t.sendTimes desc")
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 order by t.sendTimes desc")
    List<DoctorGuidanceTemp> findByOwner(String owner);
    @Query("select t.code,t.owner,t.sendTimes,t.createTime,t.modelName from DoctorGuidanceTemp t where t.owner = ?1 or t.owner = 'system' order by t.sendTimes desc")
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 or t.owner = 'system' order by t.sendTimes desc")
    List<DoctorGuidanceTemp> findByOwnerAndSystem(String owner);
}

+ 42 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -9,9 +9,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 医生健康指导模板
@ -55,11 +53,15 @@ public class DoctorGuidanceTempService extends BaseService {
        String content= (String)temp.get("content");
        String imagesUrl= (String)temp.get("images_url");
//        多图按逗号分割保存成数组
        String [] imagesArray = imagesUrl.split(",");
        String head = "htttp://";
        for (int i=0;i<imagesArray.length;i++) {
            imagesArray[i]=head +imagesArray[i];
        String [] imagesArray = null;
        if(imagesUrl != null){
            imagesArray = imagesUrl.split(",");
            String head = "htttp://";
            for (int i=0;i<imagesArray.length;i++) {
                imagesArray[i]=head +imagesArray[i];
            }
        }
        String createTime = (String)temp.get("create_time").toString();
        String sendTimes = (String)temp.get("send_times").toString();
        JSONObject json = new JSONObject();
@ -124,13 +126,11 @@ public class DoctorGuidanceTempService extends BaseService {
        String[] codes = code.split(",");
        if (codes != null && codes.length > 0) {
            String sql = "SELECT t.owner FROM wlyy_doctor_guidance_temp t WHERE t.code=?";
            String owner = jdbcTemplate.queryForObject(sql,String.class,code);
            for (String temp : codes) {
                String sql = "SELECT t.owner FROM wlyy_doctor_guidance_temp t WHERE t.code=?";
                String owner = jdbcTemplate.queryForObject(sql,String.class,temp);
                if(!"system".equals(owner)){
//                    String sqlDetele = "DELETE FROM wlyy_doctor_guidance_temp WHERE code=?";
                    guidanceTempDao.deleteByCode(temp);
//                    jdbcTemplate.update(sqlDetele,temp);
                }
            }
@ -146,19 +146,47 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param type   模板类型
     * @return
     */
    public List<DoctorGuidanceTemp> list(String doctor, String type) throws Exception {
    public List<Map<String,Object>> list(String doctor, String type) throws Exception {
        List<DoctorGuidanceTemp> temps = null;
        List<Map<String,Object>> listMap = new ArrayList<>();
        if (type.equals("1")) {
            temps = guidanceTempDao.findByOwner("system");
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                listMap.add(tem);
            }
        } else if (type.equals("2")) {
            temps = guidanceTempDao.findByOwner(doctor);
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                listMap.add(tem);
            }
        } else {
            temps = guidanceTempDao.findByOwnerAndSystem(doctor);
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                tem.put("code:",temp.getCode());
                tem.put("owner:",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                listMap.add(tem);
            }
        }
        return temps;
        return listMap;
    }
}

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * 医生健康指导模板
@ -178,7 +179,7 @@ public class DoctorGuidanceTempController extends BaseController {
    public String list(@RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type) {
        try {
            List<DoctorGuidanceTemp> temps = guidanceTempService.list(getUID(), type);
            List<Map<String,Object>> temps = guidanceTempService.list(getUID(), type);
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功", "data", new JSONArray());