Browse Source

场所添加和列表

master
zhizhi wu 6 years ago
parent
commit
cb8281553e
  1. 13
      health/src/main/java/com/ccsens/health/api/ClockController.java
  2. 45
      health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java
  3. 19
      health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java
  4. 10
      health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java
  5. 17
      health/src/main/java/com/ccsens/health/service/ClockService.java
  6. 5
      health/src/main/java/com/ccsens/health/service/IClockService.java
  7. 4
      health/src/main/resources/application.yml
  8. 21
      health/src/main/resources/mapper_dao/SiteDao.xml

13
health/src/main/java/com/ccsens/health/api/ClockController.java

@ -10,6 +10,7 @@ import com.ccsens.health.bean.vo.HealthVo;
import com.ccsens.health.service.IClockService;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -60,9 +61,9 @@ public class ClockController {
@MustLogin
@ApiOperation(value = "获取所有场所信息", notes = "")
@RequestMapping(value = "siteInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<Site>> getAllSiteInfo() throws Exception {
public JsonResponse<PageInfo<ClockVo.SiteList>> getAllSiteInfo(@ApiParam @Validated @RequestBody QueryDto<JourneyDto.Query> query) throws Exception {
log.info("获取所有场景信息");
List<Site> siteList = clockService.getAllSiteInfo();
PageInfo<ClockVo.SiteList> siteList = clockService.getAllSiteInfo(query.getParam());
return JsonResponse.newInstance().ok(siteList);
}
@ -84,4 +85,12 @@ public class ClockController {
return JsonResponse.newInstance().ok(codePath);
}
@MustLogin
@ApiOperation(value = "添加场所", notes = "")
@RequestMapping(value = "addSite", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> addSite(@ApiParam @Validated @RequestBody QueryDto<JourneyDto.SiteAdd> params) throws Exception {
log.info("添加场所:{}", params);
clockService.addSite(params.getParam().toSite());
return JsonResponse.newInstance().ok();
}
}

45
health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java

@ -1,8 +1,15 @@
package com.ccsens.health.bean.dto;
import com.ccsens.health.bean.po.Site;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class JourneyDto {
@ -53,5 +60,43 @@ public class JourneyDto {
private int type;
}
@Data
@ApiModel("查询场所")
public static class Query{
@ApiModelProperty("场所上级")
private String parentCode = "SXDX";
@ApiModelProperty("第几页")
@Min(value = 1)
private int pageNum = 1;
@ApiModelProperty("每页多少条")
@Min(value = 1)
@Max(value=100)
private int pageSize = 10;
}
@Data
@ApiModel("添加场所")
public static class SiteAdd{
@NotNull
@ApiModelProperty("场所名字")
private String siteName;
@NotNull
@ApiModelProperty("场所code")
private String siteCode;
@NotNull
@ApiModelProperty("经度")
private BigDecimal longitude;
@NotNull
@ApiModelProperty("纬度")
private BigDecimal latitude;
@NotNull
@ApiModelProperty("上级")
private String parentCode = "SXDX";
public Site toSite(){
Site site = new Site();
BeanUtils.copyProperties(this, site);
return site;
}
}
}

19
health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java

@ -56,4 +56,23 @@ public class ClockVo {
@ApiModelProperty("进还是出 0进 1出")
private int type;
}
@Data
@ApiModel("获取个人打卡记录")
public static class SiteList{
@ApiModelProperty("场景id")
private Long id;
@ApiModelProperty("场所名称")
private String siteName;
@ApiModelProperty("场所Code")
private String siteCode;
@ApiModelProperty("经度")
private BigDecimal longitude;
@ApiModelProperty("纬度")
private BigDecimal latitude;
@ApiModelProperty("进二维码")
private String inUrl;
@ApiModelProperty("出二维码")
private String outUrl;
}
}

10
health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java

@ -1,8 +1,18 @@
package com.ccsens.health.persist.dao;
import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.health.persist.mapper.SiteMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SiteDao extends SiteMapper {
/**
* 查询场所信息
* @param query
* @return
*/
List<ClockVo.SiteList> queryAll(JourneyDto.Query query);
}

17
health/src/main/java/com/ccsens/health/service/ClockService.java

@ -21,6 +21,8 @@ import com.ccsens.util.WebConstant;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.wx.WxXcxUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -168,14 +170,19 @@ public class ClockService implements IClockService {
@Override
public List<Site> getAllSiteInfo() {
SiteExample siteExample = new SiteExample();
siteExample.clear();
List<Site> siteList = siteDao.selectByExample(siteExample);
return siteList;
public PageInfo<ClockVo.SiteList> getAllSiteInfo(JourneyDto.Query query) {
PageHelper.startPage(query.getPageNum(), query.getPageSize());
List<ClockVo.SiteList> vos = siteDao.queryAll(query);
return new PageInfo<>(vos);
}
@Override
public void addSite(Site site) {
site.setId(snowflake.nextId());
siteDao.insertSelective(site);
}
@Override
public ClockVo.SiteInfo getSiteInfoById(Long siteQrcodeId) {
SiteQrcode siteQrcode = siteQrcodeDao.selectByPrimaryKey(siteQrcodeId);

5
health/src/main/java/com/ccsens/health/service/IClockService.java

@ -5,6 +5,7 @@ import com.ccsens.health.bean.dto.JourneyDto;
import com.ccsens.health.bean.po.Site;
import com.ccsens.health.bean.vo.ClockVo;
import com.ccsens.util.bean.dto.QueryDto;
import com.github.pagehelper.PageInfo;
import java.io.IOException;
import java.util.List;
@ -18,7 +19,9 @@ public interface IClockService {
String getQRCode(QueryDto<JourneyDto.CreateQRCode> params) throws Exception;
List<Site> getAllSiteInfo();
PageInfo<ClockVo.SiteList> getAllSiteInfo(JourneyDto.Query query);
ClockVo.SiteInfo getSiteInfoById(Long id);
void addSite(Site site);
}

4
health/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: dev
include: common, util-dev
active: test
include: common, util-test

21
health/src/main/resources/mapper_dao/SiteDao.xml

@ -0,0 +1,21 @@
<?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.ccsens.health.persist.dao.SiteDao">
<select id="queryAll" resultType="com.ccsens.health.bean.vo.ClockVo$SiteList">
select t.id, t.site_name as siteName, t.site_code as siteCode, t.longitude, t.latitude, t1.qrcode_path as inUrl, t2.qrcode_path as outUrl
from
(select * from t_site
<if test="parentCode != null and parentCode != ''">
where parent_code = #{parentCode, jdbcType=VARCHAR}
</if>
) t
left join
(select * from t_site_qrcode where out_or_in = 0 ) t1
on t.id = t1.site_id
left join
(select * from t_site_qrcode where out_or_in = 1) t2
on t.id = t2.site_id
</select>
</mapper>
Loading…
Cancel
Save