Просмотр исходного кода

健康活动查询接口变更

zdm 6 лет назад
Родитель
Сommit
cba1c5240b

+ 6 - 26
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityController.java

@ -294,33 +294,13 @@ public class ActivityController extends EnvelopRestEndpoint {
                                                @ApiParam(name = "size", defaultValue = "10", value = ",每页分页大小")
                                                @RequestParam(value = "size", required = false) Integer size) {
        try{
            StringBuffer stringBuffer=new StringBuffer();
            stringBuffer.append("delFlag=1;");
            if (StringUtils.isNotEmpty(type)) {
                stringBuffer.append("type=").append(type).append(";");
            }
            if (StringUtils.isNotEmpty(filter)) {
                stringBuffer.append("title?").append(filter).append(" g1;").append("organizer?").append(filter).append(" g1;").append("areaName?").append(filter).append(" g1;");
            }
            if (null != status && "2".equals(status) ) {
                stringBuffer.append("status=-1,2;");
            } else if (null != status && "1".equals(status) ) {
                stringBuffer.append("status=0,1;");
            }
            if(null!=crowdType&&StringUtils.isNotBlank(crowdType)){
                stringBuffer.append("crowdType="+crowdType+";");
            }
            if(StringUtils.isNotBlank(releaseTime)){
                stringBuffer.append("activityOfflineTime>="+releaseTime+" 00:00:00;");
            }
            if(StringUtils.isNotBlank(activityOfflineTime)){
                stringBuffer.append("activityOfflineTime<="+ activityOfflineTime+" 59:59:59;");
            }
            String sorts="-createTime";
            List<ActivityDO> activityDOList = service.search("", stringBuffer.toString(), sorts, page, size);
            int count = (int) service.getCount(stringBuffer.toString());
            return success(activityDOList, count, page, size);
            JSONObject obj = service.ListActivityDO(type, status,crowdType,releaseTime,activityOfflineTime,filter,page,size);
//            int count = (int) service.getCount(stringBuffer.toString());
            List<ActivityDO> list=(List<ActivityDO>)obj.get("activityDOList");
            int count =obj.getInteger("count");
            return success(list, count, page, size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());

+ 42 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java

@ -854,4 +854,46 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
        return object;
    }
    public JSONObject ListActivityDO(String type, String status,String crowdType,String releaseTime,String activityOfflineTime, String filter,Integer page,Integer size)throws ParseException {
        JSONObject obj=new JSONObject();
        StringBuffer stringBuffer=new StringBuffer();
        if (StringUtils.isNotEmpty(type)) {
            stringBuffer.append(" and type=").append(type);
        }
        if (StringUtils.isNotEmpty(filter)) {
            stringBuffer.append(" and (title like '%").append(filter).append("%' or ").append("organizer like '%").append(filter).append("%' or ").append("area_name like '%").append(filter).append("%')");
        }
        if (null != status && "2".equals(status) ) {
            stringBuffer.append(" and status in (-1,2) ");
        } else if (null != status && "1".equals(status) ) {
            stringBuffer.append(" and status in (0,1) ");
        }
        if(null!=crowdType&&StringUtils.isNotBlank(crowdType)){
            stringBuffer.append(" and crowd_type="+crowdType);
        }
        if(StringUtils.isNotBlank(releaseTime)){
            stringBuffer.append(" and activity_offline_time>='"+releaseTime+" 00:00:00' ");
        }
        if(StringUtils.isNotBlank(activityOfflineTime)){
            stringBuffer.append(" and activity_offline_time<='"+ activityOfflineTime+" 59:59:59' ");
        }
        stringBuffer.append(" order by create_time desc");
        String sql = "SELECT * FROM wlyy_health_bank.wlyy_health_bank_activity  WHERE 1=1 AND del_flag=1 "+stringBuffer.toString()+" LIMIT "+(page-1)*size+","+size;
        List<ActivityDO> activityDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
        String sqlcount = "SELECT COUNT(1)  AS total  FROM wlyy_health_bank.wlyy_health_bank_activity  WHERE 1=1 AND del_flag=1 "+stringBuffer.toString();
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        obj .put("activityDOList",activityDOList);
        obj .put("count",count);
        return obj;
    }
}