Commit 0e6fe017 by 阮思源

个人二维码替换群二维码

parent 57861225
......@@ -4,10 +4,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
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.*;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
......@@ -34,4 +31,12 @@ public interface BookGroupService {
@RequestMapping(value = "getBaseInfoBySceneId",method = RequestMethod.GET)
ResponseEntity<ResponseDto<BookGroupDTO>> getBaseInfoBySceneId(@RequestParam("sceneId")Long sceneId) throws BizException;
@ApiOperation("获取暗号状态")
@GetMapping("/getCipherState")
ResponseEntity<ResponseDto<Integer>> getCipherState(@RequestParam("cipher")String cipher) throws BizException;
@ApiOperation("更新暗号状态为已使用")
@GetMapping("/updateCipherStateToUsed")
void updateCipherStateToUsed(@RequestParam("cipher")String cipher, @RequestParam("wxId")String wxId) throws BizException;
}
......@@ -247,4 +247,14 @@ public interface BookGroupBiz {
* 根据分类id获取个人二维码信息
*/
OwnAltQrcodeInfoDTO getOwnAltQrcodeInfoDTOByClassifyId(Long wechatUserId, Long classifyId);
/**
* 获取暗号状态
*/
Integer getCipherState(String cipher);
/**
* 更新状态为已使用
*/
void updateCipherStateToUsed(String cipher, String wxId);
}
......@@ -1075,6 +1075,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
Long templetId = bookDto.getTempletId();
//根据分类id获取大类
TempletRelevance templetRelevance = templetRelevanceDao.getByTempletId(templetId);
LOGGER.info("根据分类id获取大类templetRelevance" + templetRelevance.toString());
Integer largeTemplet = templetRelevance.getLargeTemplet();
//TODO 调内部接口获取分配的小号信息
//获取之前是否有没有使用的暗号
......@@ -1088,6 +1089,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
JoinGroupCipher joinGroupCipherNew = new JoinGroupCipher();
joinGroupCipherNew.setCipher(cipher);
joinGroupCipherNew.setCreateUser(wechatUserId);
joinGroupCipherNew.setClassifyId(classifyId);
joinGroupCipherDao.insert(joinGroupCipherNew);
}
OwnAltQrcodeInfoDTO ownAltQrcodeInfoDTO=new OwnAltQrcodeInfoDTO();
......@@ -1098,4 +1100,31 @@ public class BookGroupBizImpl implements BookGroupBiz {
return ownAltQrcodeInfoDTO;
}
@ParamLog("获取暗号状态")
@Override
public Integer getCipherState(String cipher) {
Integer state;
if (StringUtil.isEmpty(cipher)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
JoinGroupCipher joinGroupCipher = joinGroupCipherDao.getByCipher(cipher);
if (joinGroupCipher == null) {
//暗号错误
state = 2;
} else if (joinGroupCipher.getHasUsed() != null && joinGroupCipher.getHasUsed()) {
//已使用
state = 1;
} else {
//未使用
state = 0;
}
return state;
}
@ParamLog("获取暗号状态为已使用")
@Override
public void updateCipherStateToUsed(String cipher, String wxId) {
joinGroupCipherDao.updateCipherStateToUsed(cipher,wxId);
}
}
......@@ -5,4 +5,8 @@ import com.pcloud.common.core.dao.BaseDao;
public interface JoinGroupCipherDao extends BaseDao<JoinGroupCipher> {
JoinGroupCipher getByCreateUser(Long wechatUserId,Long classifyId);
JoinGroupCipher getByCipher(String cipher);
void updateCipherStateToUsed(String cipher, String wxId);
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.JoinGroupCipherDao;
import com.pcloud.book.group.entity.JoinGroupCipher;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
......@@ -12,6 +13,7 @@ import java.util.Map;
* @Author ruansiyuan
* @Date 2019/8/5 16:18
**/
@Component("joinGroupCipherDao")
public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> implements JoinGroupCipherDao {
@Override
public JoinGroupCipher getByCreateUser(Long wechatUserId,Long classifyId) {
......@@ -20,4 +22,17 @@ public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> impleme
map.put("classifyId",classifyId);
return this.getSqlSession().selectOne(this.getStatement("getByCreateUser"), map);
}
@Override
public JoinGroupCipher getByCipher(String cipher) {
return this.getSqlSession().selectOne(this.getStatement("getByCipher"), cipher);
}
@Override
public void updateCipherStateToUsed(String cipher, String wxId) {
Map<String,Object> map=new HashMap<>();
map.put("cipher",cipher);
map.put("wxId",wxId);
this.getSqlSession().update(this.getStatement("updateCipherStateToUsed"), map);
}
}
......@@ -3,12 +3,14 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.TempletRelevanceDao;
import com.pcloud.book.group.entity.TempletRelevance;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/8/5 16:19
**/
@Component("templetRelevanceDao")
public class TempletRelevanceDaoImpl extends BaseDaoImpl<TempletRelevance> implements TempletRelevanceDao {
@Override
public TempletRelevance getByTempletId(Long templetId) {
......
......@@ -14,6 +14,9 @@ public class JoinGroupCipher extends BaseEntity {
@ApiModelProperty("密码")
private String cipher;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("创建人")
private Long createUser;
......@@ -31,6 +34,14 @@ public class JoinGroupCipher extends BaseEntity {
this.cipher = cipher;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getCreateUser() {
return createUser;
}
......@@ -59,6 +70,7 @@ public class JoinGroupCipher extends BaseEntity {
public String toString() {
return "JoinGroupCipher{" +
"cipher='" + cipher + '\'' +
", classifyId=" + classifyId +
", createUser=" + createUser +
", wxId='" + wxId + '\'' +
", hasUsed=" + hasUsed +
......
......@@ -54,4 +54,20 @@ public class BookGroupServiceImpl implements BookGroupService {
return ResponseHandleUtil.toResponse(bookGroupBiz.getBaseInfoBySceneId(sceneId));
}
/**
* 获取暗号状态
*/
@Override
public ResponseEntity<ResponseDto<Integer>> getCipherState(String cipher) throws BizException {
return ResponseHandleUtil.toResponse(bookGroupBiz.getCipherState(cipher));
}
/**
* 更新密码状态为已使用
*/
@Override
public void updateCipherStateToUsed(String cipher, String wxId) throws BizException {
bookGroupBiz.updateCipherStateToUsed(cipher,wxId);
}
}
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.JoinGroupCipher">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="cipher" property="cipher" jdbcType="VARCHAR"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
......@@ -12,7 +13,7 @@
</resultMap>
<sql id="Base_Column_List">
id, cipher, create_time, create_user, update_time, wx_id, has_used
id, cipher, classify_id, create_time, create_user, update_time, wx_id, has_used
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.JoinGroupCipher" useGeneratedKeys="true"
......@@ -20,12 +21,14 @@
insert into join_group_cipher
<trim prefix="(" suffix=")" suffixOverrides=",">
cipher,
classify_id,
create_time,
create_user,
has_used
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{cipher,jdbcType=BIGINT},
#{classifyId,jdbcType=BIGINT},
now(),
#{createUser,jdbcType=BIGINT},
0
......@@ -38,4 +41,19 @@
where create_user=#{wechatUserId} and
classify_id=#{classify_id}
</select>
<!--根据暗号获取-->
<select id="getByCipher" parameterType="String" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from join_group_cipher
where cipher=#{cipher} limit 1
</select>
<!--更新暗号状态为已使用-->
<update id="updateCipherStateToUsed" parameterType="map">
update join_group_cipher set
has_used=1,
wx_id=#{wxId},
update_time=now()
where cipher=#{cipher}
</update>
</mapper>
\ No newline at end of file
......@@ -8,7 +8,7 @@
</resultMap>
<sql id="Base_Column_List">
id, templet_id, large_templet_id
id, templet_id, large_templet
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.TempletRelevance" useGeneratedKeys="true"
......@@ -27,6 +27,6 @@
<!--根据模板id查询大类id-->
<select id="getByTempletId" parameterType="Long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from templet_relevance
where templet_id=#{templetId} order by create_time limit 1
where templet_id=#{templetId} order by id desc limit 1
</select>
</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