diff --git a/health/src/main/java/com/ccsens/health/api/ClockController.java b/health/src/main/java/com/ccsens/health/api/ClockController.java index 9f11b107..667c4c9e 100644 --- a/health/src/main/java/com/ccsens/health/api/ClockController.java +++ b/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> getAllSiteInfo() throws Exception { + public JsonResponse> getAllSiteInfo(@ApiParam @Validated @RequestBody QueryDto query) throws Exception { log.info("获取所有场景信息"); - List siteList = clockService.getAllSiteInfo(); + PageInfo 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 addSite(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("添加场所:{}", params); + clockService.addSite(params.getParam().toSite()); + return JsonResponse.newInstance().ok(); + } } diff --git a/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java b/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java index aa1a97da..72cb35c0 100644 --- a/health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java +++ b/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; + } + } } diff --git a/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java b/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java index 588d7d3d..9b6aac51 100644 --- a/health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java +++ b/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; + } } diff --git a/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java b/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java index 96027584..91ce6adf 100644 --- a/health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java +++ b/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 queryAll(JourneyDto.Query query); } diff --git a/health/src/main/java/com/ccsens/health/service/ClockService.java b/health/src/main/java/com/ccsens/health/service/ClockService.java index c71afc6d..df4ba8a7 100644 --- a/health/src/main/java/com/ccsens/health/service/ClockService.java +++ b/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 getAllSiteInfo() { - SiteExample siteExample = new SiteExample(); - siteExample.clear(); - List siteList = siteDao.selectByExample(siteExample); - return siteList; + public PageInfo getAllSiteInfo(JourneyDto.Query query) { + PageHelper.startPage(query.getPageNum(), query.getPageSize()); + List 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); diff --git a/health/src/main/java/com/ccsens/health/service/IClockService.java b/health/src/main/java/com/ccsens/health/service/IClockService.java index efaa2dbc..ea975cfc 100644 --- a/health/src/main/java/com/ccsens/health/service/IClockService.java +++ b/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 params) throws Exception; - List getAllSiteInfo(); + PageInfo getAllSiteInfo(JourneyDto.Query query); ClockVo.SiteInfo getSiteInfoById(Long id); + + void addSite(Site site); } diff --git a/health/src/main/resources/application.yml b/health/src/main/resources/application.yml index 5c2cd5c4..5889ff7f 100644 --- a/health/src/main/resources/application.yml +++ b/health/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: dev - include: common, util-dev \ No newline at end of file + active: test + include: common, util-test \ No newline at end of file diff --git a/health/src/main/resources/mapper_dao/SiteDao.xml b/health/src/main/resources/mapper_dao/SiteDao.xml new file mode 100644 index 00000000..0a23004f --- /dev/null +++ b/health/src/main/resources/mapper_dao/SiteDao.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file