Commit cc4d59c4 by 阮思源

个人二维码替换群二维码

parent e1c705fa
package com.pcloud.book.group.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/8/7 9:26
**/
@ApiModel("群使用情况模型")
public class GroupUseDTO implements Serializable {
@ApiModelProperty("已使用")
private Integer hasUsed;
@ApiModelProperty("未使用")
private Integer notUsed;
public Integer getHasUsed() {
return hasUsed;
}
public void setHasUsed(Integer hasUsed) {
this.hasUsed = hasUsed;
}
public Integer getNotUsed() {
return notUsed;
}
public void setNotUsed(Integer notUsed) {
this.notUsed = notUsed;
}
@Override
public String toString() {
return "GroupUseDTO{" +
"hasUsed=" + hasUsed +
", notUsed=" + notUsed +
'}';
}
}
...@@ -2,6 +2,8 @@ package com.pcloud.book.group.service; ...@@ -2,6 +2,8 @@ package com.pcloud.book.group.service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.pcloud.book.group.dto.GroupUseDTO;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -39,4 +41,7 @@ public interface BookGroupService { ...@@ -39,4 +41,7 @@ public interface BookGroupService {
@GetMapping("/updateCipherStateToUsed") @GetMapping("/updateCipherStateToUsed")
void updateCipherStateToUsed(@RequestParam("cipher")String cipher, @RequestParam("wxId")String wxId) throws BizException; void updateCipherStateToUsed(@RequestParam("cipher")String cipher, @RequestParam("wxId")String wxId) throws BizException;
@ApiOperation("获取个人二维码方式群已使用和未使用数量")
@PostMapping("/getGroupUse")
ResponseEntity<ResponseDto<GroupUseDTO>> getGroupUse(@RequestBody List<String> altIds) throws BizException;
} }
...@@ -257,4 +257,9 @@ public interface BookGroupBiz { ...@@ -257,4 +257,9 @@ public interface BookGroupBiz {
* 更新状态为已使用 * 更新状态为已使用
*/ */
void updateCipherStateToUsed(String cipher, String wxId); void updateCipherStateToUsed(String cipher, String wxId);
/**
* 获取个人二维码方式群已使用和未使用数量
*/
GroupUseDTO getGroupUse(List<String> altIds);
} }
...@@ -158,6 +158,8 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -158,6 +158,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private JoinGroupCipherDao joinGroupCipherDao; private JoinGroupCipherDao joinGroupCipherDao;
@Autowired @Autowired
private WechatGroupConsr wechatGroupConsr; private WechatGroupConsr wechatGroupConsr;
@Autowired
private WeixinQrcodeDao weixinQrcodeDao;
@Override @Override
...@@ -1135,7 +1137,25 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -1135,7 +1137,25 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog("获取暗号状态为已使用") @ParamLog("获取暗号状态为已使用")
@Override @Override
public void updateCipherStateToUsed(String cipher, String wxId) { public void updateCipherStateToUsed(String cipher, String wxId) {
if (StringUtil.isEmpty(cipher) || StringUtil.isEmpty(wxId)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
joinGroupCipherDao.updateCipherStateToUsed(cipher,wxId); joinGroupCipherDao.updateCipherStateToUsed(cipher,wxId);
} }
@ParamLog("获取个人二维码方式群已使用和未使用数量")
@Override
public GroupUseDTO getGroupUse(List<String> altIds) {
if (ListUtils.isEmpty(altIds)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
GroupUseDTO groupUseDTO = new GroupUseDTO();
Integer notUsed = weixinQrcodeDao.countByState(0, altIds);
Integer hasUsed = weixinQrcodeDao.countByState(1, altIds);
Integer full = weixinQrcodeDao.countByState(2, altIds);
groupUseDTO.setHasUsed(hasUsed + full);
groupUseDTO.setNotUsed(notUsed);
return groupUseDTO;
}
} }
...@@ -155,4 +155,9 @@ public interface WeixinQrcodeDao extends BaseDao<WeixinQrcode> { ...@@ -155,4 +155,9 @@ public interface WeixinQrcodeDao extends BaseDao<WeixinQrcode> {
Map<String, BookWxQrcodeDTO> listByWxGroupIds(List<String> wxGroupIds); Map<String, BookWxQrcodeDTO> listByWxGroupIds(List<String> wxGroupIds);
String getVirtualIp(Integer generation); String getVirtualIp(Integer generation);
/**
* 根据状态获取群数量
*/
Integer countByState(Integer state, List<String> altIds);
} }
...@@ -154,4 +154,12 @@ public class WeixinQrcodeDaoImpl extends BaseDaoImpl<WeixinQrcode> implements We ...@@ -154,4 +154,12 @@ public class WeixinQrcodeDaoImpl extends BaseDaoImpl<WeixinQrcode> implements We
public String getVirtualIp(Integer generation) { public String getVirtualIp(Integer generation) {
return this.getSessionTemplate().selectOne("getVirtualIp", generation); return this.getSessionTemplate().selectOne("getVirtualIp", generation);
} }
@Override
public Integer countByState(Integer state, List<String> altIds) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("state", state);
paramMap.put("altIds", altIds);
return this.getSessionTemplate().selectOne("countByState", paramMap);
}
} }
...@@ -2,13 +2,12 @@ package com.pcloud.book.group.service.impl; ...@@ -2,13 +2,12 @@ package com.pcloud.book.group.service.impl;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.pcloud.book.group.dto.GroupUseDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.pcloud.book.group.biz.BookGroupBiz; import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.dto.BookGroupDTO; import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.service.BookGroupService; import com.pcloud.book.group.service.BookGroupService;
...@@ -57,6 +56,8 @@ public class BookGroupServiceImpl implements BookGroupService { ...@@ -57,6 +56,8 @@ public class BookGroupServiceImpl implements BookGroupService {
/** /**
* 获取暗号状态 * 获取暗号状态
*/ */
@ApiOperation("获取暗号状态")
@GetMapping("/getCipherState")
@Override @Override
public ResponseEntity<ResponseDto<Integer>> getCipherState(String cipher) throws BizException { public ResponseEntity<ResponseDto<Integer>> getCipherState(String cipher) throws BizException {
return ResponseHandleUtil.toResponse(bookGroupBiz.getCipherState(cipher)); return ResponseHandleUtil.toResponse(bookGroupBiz.getCipherState(cipher));
...@@ -65,9 +66,21 @@ public class BookGroupServiceImpl implements BookGroupService { ...@@ -65,9 +66,21 @@ public class BookGroupServiceImpl implements BookGroupService {
/** /**
* 更新密码状态为已使用 * 更新密码状态为已使用
*/ */
@ApiOperation("更新暗号状态为已使用")
@GetMapping("/updateCipherStateToUsed")
@Override @Override
public void updateCipherStateToUsed(String cipher, String wxId) throws BizException { public void updateCipherStateToUsed(String cipher, String wxId) throws BizException {
bookGroupBiz.updateCipherStateToUsed(cipher,wxId); bookGroupBiz.updateCipherStateToUsed(cipher,wxId);
} }
/**
* 获取个人二维码方式群已使用和未使用数量
*/
@ApiOperation("获取个人二维码方式群已使用和未使用数量")
@PostMapping("/getGroupUse")
@Override
public ResponseEntity<ResponseDto<GroupUseDTO>> getGroupUse(@RequestBody List<String> altIds) throws BizException {
return ResponseHandleUtil.toResponse(bookGroupBiz.getGroupUse(altIds));
}
} }
...@@ -275,4 +275,12 @@ ...@@ -275,4 +275,12 @@
where generation = #{_parameter} where generation = #{_parameter}
</select> </select>
<!--根据状态获取群数量-->
<select id="countByState" parameterType="map" resultType="Integer">
select count(1) from weixin_qrcode t where t.robot_wx_id in
<foreach collection="altIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
and use_state=#{state}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment