| @@ -0,0 +1,24 @@ | |||||
| package com.simple.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| @Configuration | |||||
| public class RestTemplateConfig { | |||||
| @Bean | |||||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||||
| return new RestTemplate(factory); | |||||
| } | |||||
| @Bean | |||||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||||
| factory.setReadTimeout(5000);//ms | |||||
| factory.setConnectTimeout(10000);//ms | |||||
| return factory; | |||||
| } | |||||
| } | |||||
| @@ -11,10 +11,18 @@ import java.util.Map; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.HttpEntity; | |||||
| import org.springframework.http.HttpHeaders; | |||||
| import org.springframework.http.MediaType; | |||||
| import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.util.LinkedMultiValueMap; | |||||
| import org.springframework.util.MultiValueMap; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import org.springframework.web.client.RestTemplate; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.dto.WxCuerBasicInfoDto; | import com.simple.domain.dto.WxCuerBasicInfoDto; | ||||
| @@ -245,5 +253,33 @@ public class WxUserStructureController { | |||||
| return vo; | return vo; | ||||
| } | } | ||||
| public static String token="https://api.weixin.qq.com/cgi-bin/token?"+ | |||||
| "grant_type=client_credential&appid=APPID&secret=APPSECRET"; | |||||
| private static String visit = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token="; | |||||
| @Autowired | |||||
| private RestTemplate r; | |||||
| @GetMapping("test") | |||||
| public String visit() { | |||||
| String url = token.replace("APPID", "wx8eb8275b78db4ede"). | |||||
| replace("APPSECRET", "76c43df01296998d8ce12383f213ac10"); | |||||
| Map map = r.getForObject(url,Map.class); | |||||
| System.out.println(map.get("access_token")); | |||||
| String reqUrl= visit+map.get("access_token"); | |||||
| // Map map = r.getForObject(reqUrl,Map.class); | |||||
| HttpHeaders headers = new HttpHeaders(); | |||||
| headers.setContentType(MediaType.APPLICATION_JSON); | |||||
| map = new HashMap<String, String>(); | |||||
| map.put("begin_date", "20180828"); | |||||
| map.put("end_date", "20180828"); | |||||
| RestTemplate restTemplate = new RestTemplate(); | |||||
| HttpEntity<Map> entity = new HttpEntity<Map>(map, headers); | |||||
| // ResponseEntity<Student> responseEntity = restTemplate.exchange(url, HttpMethod.POST, entity, Student.class, aa); | |||||
| ResponseEntity<String> responseEntity = restTemplate.postForEntity(reqUrl, entity, String.class); | |||||
| return JSON.toJSONString(responseEntity); | |||||
| } | |||||
| } | } | ||||
| @@ -2,17 +2,20 @@ package com.simple.schedule; | |||||
| import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.scheduling.annotation.EnableScheduling; | import org.springframework.scheduling.annotation.EnableScheduling; | ||||
| import org.springframework.scheduling.annotation.SchedulingConfigurer; | |||||
| import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | |||||
| import org.springframework.scheduling.config.ScheduledTaskRegistrar; | |||||
| @Configuration | @Configuration | ||||
| @EnableScheduling | @EnableScheduling | ||||
| public class SchedulingConfig { //implements SchedulingConfigurer { | |||||
| public class SchedulingConfig implements SchedulingConfigurer { | |||||
| // @Override | |||||
| // public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { | |||||
| // ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); | |||||
| // scheduler.setPoolSize(10); | |||||
| // scheduler.initialize(); | |||||
| // taskRegistrar.setTaskScheduler(scheduler); | |||||
| // } | |||||
| @Override | |||||
| public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { | |||||
| ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); | |||||
| scheduler.setPoolSize(10); | |||||
| scheduler.initialize(); | |||||
| taskRegistrar.setTaskScheduler(scheduler); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,107 @@ | |||||
| package com.simple.schedule; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.http.HttpEntity; | |||||
| import org.springframework.http.HttpHeaders; | |||||
| import org.springframework.http.MediaType; | |||||
| import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.scheduling.annotation.Scheduled; | |||||
| import org.springframework.stereotype.Component; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.simple.domain.po.WxUserVisit; | |||||
| import com.simple.service.WxUserVisitService; | |||||
| @Component | |||||
| public class WxAppVisitSchedule { | |||||
| private Logger logger = Logger.getLogger(WxAppVisitSchedule.class); | |||||
| private static String token="https://api.weixin.qq.com/cgi-bin/token?"+ | |||||
| "grant_type=client_credential&appid=APPID&secret=APPSECRET"; | |||||
| private static String visit = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token="; | |||||
| @Autowired | |||||
| private RestTemplate restTemplate; | |||||
| @Autowired | |||||
| private WxUserVisitService wxUserVisitService; | |||||
| //@Scheduled(cron = "0 */1 * * * *?") | |||||
| @Scheduled(cron = "0 0 0 * * ? *") | |||||
| public void start() { | |||||
| try { | |||||
| Calendar c =Calendar.getInstance(); | |||||
| c.add(Calendar.DAY_OF_YEAR, -1); | |||||
| Date time = c.getTime(); | |||||
| String yesterday = new SimpleDateFormat("yyyyMMdd").format(time); | |||||
| getData(yesterday); | |||||
| }catch(Exception e) { | |||||
| logger.error("获取微信访问数据失败",e); | |||||
| } | |||||
| } | |||||
| private void getData(String yesterday) throws Exception { | |||||
| String accessToken = getAccessToken("wx8eb8275b78db4ede", "76c43df01296998d8ce12383f213ac10"); | |||||
| HttpHeaders headers = new HttpHeaders(); | |||||
| headers.setContentType(MediaType.APPLICATION_JSON); | |||||
| Map<String, String> map = new HashMap<String, String>(); | |||||
| map.put("begin_date", yesterday); | |||||
| map.put("end_date",yesterday); | |||||
| RestTemplate restTemplate = new RestTemplate(); | |||||
| HttpEntity<Map<String,String>> entity = new HttpEntity<Map<String,String>>(map, headers); | |||||
| String reqUrl =visit+accessToken; | |||||
| ResponseEntity<String> responseEntity = restTemplate.postForEntity(reqUrl, entity, String.class); | |||||
| logger.info("获取wx访问数据:"+JSON.toJSONString(responseEntity)); | |||||
| if(responseEntity.hasBody()) { | |||||
| String body = responseEntity.getBody(); | |||||
| Map<String,Object> maps = (Map<String,Object>)JSON.parse(body); | |||||
| JSONArray jSONArray = (JSONArray)maps.get("list"); | |||||
| if(jSONArray.isEmpty()) { | |||||
| return; | |||||
| } | |||||
| JSONObject jsonObject = jSONArray.getJSONObject(0); | |||||
| Map<String, Object> itemMap = JSONObject.toJavaObject(jsonObject, Map.class); | |||||
| //{"visit_uv":6,"stay_time_uv":1178.3333,"stay_time_session":115.9016,"ref_date":"20180828", | |||||
| // "visit_depth":3.1311,"session_cnt":61,"visit_pv":645,"visit_uv_new":3} | |||||
| logger.info(JSON.toJSONString(itemMap)); | |||||
| WxUserVisit v = new WxUserVisit(); | |||||
| v.setAppId("wx8eb8275b78db4ede"); | |||||
| String time = itemMap.get("ref_date")+""; | |||||
| Date date = new SimpleDateFormat("yyyyMMdd").parse(time); | |||||
| v.setDayDate(date); | |||||
| v.setRefDate(time); | |||||
| v.setSessionCnt(Integer.valueOf(itemMap.get("session_cnt")+"")); | |||||
| v.setVisitPv(Integer.valueOf(itemMap.get("visit_pv")+"")); | |||||
| v.setVisitUv(Integer.valueOf(itemMap.get("visit_uv")+"")); | |||||
| v.setVisitUvNew(Integer.valueOf(itemMap.get("visit_uv_new")+"")); | |||||
| v.setStayTimeSession(itemMap.get("stay_time_session")+""); | |||||
| v.setVisitDepth(itemMap.get("visit_depth")+""); | |||||
| v.setStayTimeUv(itemMap.get("stay_time_uv")+""); | |||||
| wxUserVisitService.saveOrUpdate(v); | |||||
| } | |||||
| } | |||||
| private String getAccessToken(String appId,String appSecret) { | |||||
| // return "13_rBo3ajS3jjd8OXZ2MLd4HfLrmt78gvaCeRtu-Xme0iC0fhs_lNS47aLPEwI8kfZQIMKnWYshY5wpaf2IoSI7tgVBm7WwVrm_Bg96J31VPKi8pEp8yB6JiTpDcWkpwv5GngiH2vDkwz7VHOsPLBYcAGAZPM"; | |||||
| String url = token.replace("APPID", appId). | |||||
| replace("APPSECRET", appSecret); | |||||
| Map<String,Object> map = restTemplate.getForObject(url,Map.class); | |||||
| logger.info("获取access_token返回:"+JSON.toJSONString(map)); | |||||
| return (String)map.get("access_token"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,212 @@ | |||||
| package com.simple.domain.po; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_user_visit") | |||||
| public class WxUserVisit implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /*日期字符串**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="日期字符串",name="refDate") | |||||
| private String refDate; | |||||
| /*日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="日期",name="dayDate") | |||||
| private Date dayDate; | |||||
| /*打开次数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="打开次数",name="sessionCnt") | |||||
| private Integer sessionCnt; | |||||
| /*访问次数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="访问次数",name="visitPv") | |||||
| private Integer visitPv; | |||||
| /*访问人数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="访问人数",name="visitUv") | |||||
| private Integer visitUv; | |||||
| /*新用户数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="新用户数",name="visitUvNew") | |||||
| private Integer visitUvNew; | |||||
| /*人均停留时长 (浮点型,单位:秒)**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="人均停留时长 (浮点型,单位:秒)",name="stayTimeUv") | |||||
| private String stayTimeUv; | |||||
| /*次均停留时长 (浮点型,单位:秒)**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="次均停留时长 (浮点型,单位:秒)",name="stayTimeSession") | |||||
| private String stayTimeSession; | |||||
| /*平均访问深度 (浮点型)**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="平均访问深度 (浮点型)",name="visitDepth") | |||||
| private String visitDepth; | |||||
| /*appId**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="appId",name="appId") | |||||
| private String appId; | |||||
| /*创建时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| public String getRefDate() { | |||||
| return refDate; | |||||
| } | |||||
| public void setRefDate(String _refDate) { | |||||
| refDate = _refDate; | |||||
| } | |||||
| public Date getDayDate() { | |||||
| return dayDate; | |||||
| } | |||||
| public void setDayDate(Date _dayDate) { | |||||
| dayDate = _dayDate; | |||||
| } | |||||
| public Integer getSessionCnt() { | |||||
| return sessionCnt; | |||||
| } | |||||
| public void setSessionCnt(Integer _sessionCnt) { | |||||
| sessionCnt = _sessionCnt; | |||||
| } | |||||
| public Integer getVisitPv() { | |||||
| return visitPv; | |||||
| } | |||||
| public void setVisitPv(Integer _visitPv) { | |||||
| visitPv = _visitPv; | |||||
| } | |||||
| public Integer getVisitUv() { | |||||
| return visitUv; | |||||
| } | |||||
| public void setVisitUv(Integer _visitUv) { | |||||
| visitUv = _visitUv; | |||||
| } | |||||
| public Integer getVisitUvNew() { | |||||
| return visitUvNew; | |||||
| } | |||||
| public void setVisitUvNew(Integer _visitUvNew) { | |||||
| visitUvNew = _visitUvNew; | |||||
| } | |||||
| public String getStayTimeUv() { | |||||
| return stayTimeUv; | |||||
| } | |||||
| public void setStayTimeUv(String _stayTimeUv) { | |||||
| stayTimeUv = _stayTimeUv; | |||||
| } | |||||
| public String getStayTimeSession() { | |||||
| return stayTimeSession; | |||||
| } | |||||
| public void setStayTimeSession(String _stayTimeSession) { | |||||
| stayTimeSession = _stayTimeSession; | |||||
| } | |||||
| public String getVisitDepth() { | |||||
| return visitDepth; | |||||
| } | |||||
| public void setVisitDepth(String _visitDepth) { | |||||
| visitDepth = _visitDepth; | |||||
| } | |||||
| public String getAppId() { | |||||
| return appId; | |||||
| } | |||||
| public void setAppId(String _appId) { | |||||
| appId = _appId; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | |||||
| } | |||||
| public void setCreateDate(Date _createDate) { | |||||
| createDate = _createDate; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,RefDate_ASC("`refDate` ASC"),RefDate_DESC("`refDate` DESC") | |||||
| ,DayDate_ASC("`dayDate` ASC"),DayDate_DESC("`dayDate` DESC") | |||||
| ,SessionCnt_ASC("`sessionCnt` ASC"),SessionCnt_DESC("`sessionCnt` DESC") | |||||
| ,VisitPv_ASC("`visitPv` ASC"),VisitPv_DESC("`visitPv` DESC") | |||||
| ,VisitUv_ASC("`visitUv` ASC"),VisitUv_DESC("`visitUv` DESC") | |||||
| ,VisitUvNew_ASC("`visitUvNew` ASC"),VisitUvNew_DESC("`visitUvNew` DESC") | |||||
| ,StayTimeUv_ASC("`stayTimeUv` ASC"),StayTimeUv_DESC("`stayTimeUv` DESC") | |||||
| ,StayTimeSession_ASC("`stayTimeSession` ASC"),StayTimeSession_DESC("`stayTimeSession` DESC") | |||||
| ,VisitDepth_ASC("`visitDepth` ASC"),VisitDepth_DESC("`visitDepth` DESC") | |||||
| ,AppId_ASC("`appId` ASC"),AppId_DESC("`appId` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxUserVisit.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| package com.simple.mapper; | |||||
| import java.util.*; | |||||
| import com.simple.common.CommonMapper; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.simple.domain.po.WxUserVisit; | |||||
| public interface WxUserVisitMapper extends CommonMapper<WxUserVisit, Long> { | |||||
| List<WxUserVisit> findList(WxUserVisit wxUserVisit); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.simple.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.domain.po.WxUserVisit; | |||||
| public interface WxUserVisitService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxUserVisit> listAsPage(WxUserVisit record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxUserVisit getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxUserVisit record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,54 @@ | |||||
| package com.simple.service.impl; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.domain.po.WxUserVisit; | |||||
| import com.simple.mapper.WxUserVisitMapper; | |||||
| import com.simple.service.WxUserVisitService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.simple.common.IdWorker; | |||||
| @Service | |||||
| public class WxUserVisitServiceImpl implements WxUserVisitService { | |||||
| @Autowired | |||||
| WxUserVisitMapper wxUserVisitMapper; | |||||
| @Override | |||||
| public PageInfo<WxUserVisit> listAsPage(WxUserVisit record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxUserVisitMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxUserVisit getById(Long id) { | |||||
| return wxUserVisitMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxUserVisit record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxUserVisitMapper.insertSelective(record); | |||||
| } else { | |||||
| wxUserVisitMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxUserVisitMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,104 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.simple.mapper.WxUserVisitMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxUserVisit"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="ref_date" jdbcType="VARCHAR" property="refDate" /> | |||||
| <result column="day_date" jdbcType="TIMESTAMP" property="dayDate" /> | |||||
| <result column="session_cnt" jdbcType="INTEGER" property="sessionCnt" /> | |||||
| <result column="visit_pv" jdbcType="INTEGER" property="visitPv" /> | |||||
| <result column="visit_uv" jdbcType="INTEGER" property="visitUv" /> | |||||
| <result column="visit_uv_new" jdbcType="INTEGER" property="visitUvNew" /> | |||||
| <result column="stay_time_uv" jdbcType="VARCHAR" property="stayTimeUv" /> | |||||
| <result column="stay_time_session" jdbcType="VARCHAR" property="stayTimeSession" /> | |||||
| <result column="visit_depth" jdbcType="VARCHAR" property="visitDepth" /> | |||||
| <result column="app_id" jdbcType="VARCHAR" property="appId" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`ref_date`,`day_date`,`session_cnt`,`visit_pv`,`visit_uv`,`visit_uv_new`,`stay_time_uv`,`stay_time_session`,`visit_depth`,`app_id`,`create_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != refDate "> | |||||
| and `ref_date` like concat('%', #{refDate},'%') | |||||
| </if> | |||||
| <if test=" null != dayDate "> | |||||
| and `day_date` = #{dayDate} | |||||
| </if> | |||||
| <if test=" null != sessionCnt "> | |||||
| and `session_cnt` = #{sessionCnt} | |||||
| </if> | |||||
| <if test=" null != visitPv "> | |||||
| and `visit_pv` = #{visitPv} | |||||
| </if> | |||||
| <if test=" null != visitUv "> | |||||
| and `visit_uv` = #{visitUv} | |||||
| </if> | |||||
| <if test=" null != visitUvNew "> | |||||
| and `visit_uv_new` = #{visitUvNew} | |||||
| </if> | |||||
| <if test=" null != stayTimeUv "> | |||||
| and `stay_time_uv` like concat('%', #{stayTimeUv},'%') | |||||
| </if> | |||||
| <if test=" null != stayTimeSession "> | |||||
| and `stay_time_session` like concat('%', #{stayTimeSession},'%') | |||||
| </if> | |||||
| <if test=" null != visitDepth "> | |||||
| and `visit_depth` like concat('%', #{visitDepth},'%') | |||||
| </if> | |||||
| <if test=" null != appId "> | |||||
| and `app_id` like concat('%', #{appId},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.simple.domain.po.WxUserVisit" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_user_visit | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||