Browse Source

Merge branch 'master' of gitee.com:ccsens_s/ccsenscloud

master
zhangye 5 years ago
parent
commit
d92066332f
  1. 14
      health/src/main/java/com/ccsens/health/api/ClockController.java
  2. 2
      health/src/main/java/com/ccsens/health/api/WeixinController.java
  3. 45
      health/src/main/java/com/ccsens/health/bean/dto/JourneyDto.java
  4. 19
      health/src/main/java/com/ccsens/health/bean/vo/ClockVo.java
  5. 10
      health/src/main/java/com/ccsens/health/persist/dao/SiteDao.java
  6. 17
      health/src/main/java/com/ccsens/health/service/ClockService.java
  7. 5
      health/src/main/java/com/ccsens/health/service/IClockService.java
  8. 21
      health/src/main/resources/mapper_dao/SiteDao.xml
  9. 12
      tall/src/main/java/com/ccsens/tall/service/UserService.java
  10. 1
      util/src/main/java/com/ccsens/util/WebConstant.java
  11. 11
      util/src/main/java/com/ccsens/util/enterprisewx/WeiXinConstant.java

14
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);
}
@ -83,4 +84,13 @@ public class ClockController {
String codePath = clockService.getQRCode(params);
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();
}
}

2
health/src/main/java/com/ccsens/health/api/WeixinController.java

@ -201,7 +201,7 @@ public class WeixinController {
* @param bind
* @return
*/
@GetMapping("bindUser")
@GetMapping("initMsg")
public JsonResponse bindUser(@RequestBody EmployeeDto.Bind bind) {
weiXinService.bindUser(bind);
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);
}

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>

12
tall/src/main/java/com/ccsens/tall/service/UserService.java

@ -116,14 +116,14 @@ public class UserService implements IUserService {
* @return
*/
private UserVo.UserSign wxEnterpriseLogin(String identifier, String credential, String redirect) {
log.info("企业微信登录:{},{}, {}");
log.info("企业微信登录:{},{}, {}", identifier, credential, redirect);
String suiteId = WeiXinConstant.SuiteId.getValue(credential);
if (StrUtil.isBlank(suiteId) || StrUtil.isBlank(identifier)) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
String suiteAccessToken = healthFeignClient.getSuiteAccessToken(suiteId);
WeiXinVo.UserInfo userInfo = WeiXinConstant.getUserInfo(identifier, suiteAccessToken);
log.info("用户信息");
log.info("用户信息:{}", userInfo);
if (userInfo == null) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
@ -475,6 +475,12 @@ public class UserService implements IUserService {
return userSignVo;
}
/**
* 获取企业微信信息并绑定用户
* @param identifyType
* @param param
* @param user
*/
private void getUserDetail(byte identifyType, WxEnterpriseParam param, SysUser user) {
if (identifyType == WebConstant.IDENTIFY_TYPE.Wxmp.value) {
WeiXinVo.UserDetail userDetail = WeiXinConstant.getUserDetail(param.getSuiteAccessToken(), param.getUserTicket());
@ -486,7 +492,7 @@ public class UserService implements IUserService {
Map<String, Object> map = new HashMap<>();
map.put("tallUserId", user.getId());
map.put("userid", userDetail.getUserid());
String s = RestTemplateUtil.postBody(WeiXinConstant.getBindUrl(param.getRedirect()), map);
String s = RestTemplateUtil.postBody(param.getRedirect(), map);
log.info("{}绑定关系结果:{}", s);
//TODO 绑定失败如何处理
}

1
util/src/main/java/com/ccsens/util/WebConstant.java

@ -162,6 +162,7 @@ public class WebConstant {
case 1: return H5;
case 2: return Android;
case 3: return IOS;
case 4: return WxEnterprise;
default: return null;
}
}

11
util/src/main/java/com/ccsens/util/enterprisewx/WeiXinConstant.java

@ -152,15 +152,4 @@ public class WeiXinConstant {
return userDetail;
}
/**
* 获取绑定路径
* @param type
* @return
*/
public static String getBindUrl(String type){
if (StrUtil.isBlank(PropUtil.gatewayUrl)) {
throw new BaseException(CodeEnum.LACK_CONFIG);
}
return PropUtil.gatewayUrl + type + "/bindUser";
}
}

Loading…
Cancel
Save