puhanshu
2021-10-15 affae11e824d00c66bcccb65310504895fa38d39
添加社区服务人员更新缓存
4个文件已修改
40 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComActWarehouseDonatesApi.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/dao/ComPbMemberRoleDAO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/ComPbServiceTeamServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/resources/mapper/ComPbMemberRoleDOMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComActWarehouseDonatesApi.java
@@ -75,10 +75,13 @@
    @ApiOperation(value = "新增物品捐赠")
    @PostMapping("/add")
    public R addDonates(@RequestBody @Validated(AddGroup.class) ComActWarehouseDonatesDTO comActWarehouseDonatesDTO) {
        Long userId = getUserId();
        comActWarehouseDonatesDTO.setCommunityId(getCommunityId());
        LoginUserInfoVO loginUserInfo = getLoginUserInfo();
        Long userId = loginUserInfo.getUserId();
        comActWarehouseDonatesDTO.setCommunityId(loginUserInfo.getCommunityId());
        comActWarehouseDonatesDTO.setRegisterBy(userId);
        comActWarehouseDonatesDTO.setUserId(userId);
        comActWarehouseDonatesDTO.setName(loginUserInfo.getName());
        comActWarehouseDonatesDTO.setPhone(loginUserInfo.getPhone());
        return communityService.addDonates(comActWarehouseDonatesDTO);
    }
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/dao/ComPbMemberRoleDAO.java
@@ -40,11 +40,11 @@
    SysUserVO getSysUserByPhone(@Param("phone") String phone);
    /**
     * 根据手机号查询小程序用户数量
     * 根据手机号查询小程序用户id
     * @param phone 手机号
     * @return  小程序用户数量
     * @return  小程序用户id
     */
    Integer getSysUserByPhoneCount(@Param("phone") String phone);
    Long getSysUserIdByPhone(@Param("phone") String phone);
    @Update("update sys_user u set u.phone=#{newphone} where u.phone=#{oldphone}")
    void updateUserPhone(@Param("newphone") String newphone, @Param("oldphone") String oldphone);
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/ComPbServiceTeamServiceImpl.java
@@ -4,8 +4,13 @@
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.constants.SecurityConstants;
import com.panzhihua.common.constants.TokenConstant;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -23,6 +28,8 @@
import com.panzhihua.service_dangjian.service.ComPbServiceTeamService;
import lombok.extern.slf4j.Slf4j;
import static java.util.Objects.nonNull;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -52,11 +59,25 @@
        ComPbServiceTeamDO comPbServiceTeamDO = new ComPbServiceTeamDO();
        BeanUtils.copyProperties(comPbServiceTeamDTO, comPbServiceTeamDO);
        comPbServiceTeamDO.setIsReg(2);
        if (comPbMemberRoleDAO.getSysUserByPhoneCount(comPbServiceTeamDTO.getPhone()) > 0) {
        Long userId = comPbMemberRoleDAO.getSysUserIdByPhone(comPbServiceTeamDTO.getPhone());
        if (nonNull(userId)) {
            comPbServiceTeamDO.setIsReg(1);
        }
        int insert = comPbServiceTeamDAO.insert(comPbServiceTeamDO);
        if (insert > 0) {
            if (nonNull(userId)) {
                String userKey = UserConstants.LOGIN_USER_INFO + userId;
                Boolean hasKeyLoginUserInfo = stringRedisTemplate.hasKey(userKey);
                if (hasKeyLoginUserInfo) {
                    ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
                    String userInfo = valueOperations.get(userKey);
                    LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class);
                    loginUserInfoVO.setIsmemberrole(1);
                    loginUserInfoVO.setIsCommunityWorker(1);
                    userInfo = JSONObject.toJSONString(loginUserInfoVO);
                    valueOperations.set(userKey, userInfo, TokenConstant.EXPIRETIME_REFRESH * 60 * 60 * 1000);
                }
            }
            return R.ok();
        }
        return R.fail();
springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/resources/mapper/ComPbMemberRoleDOMapper.xml
@@ -24,8 +24,8 @@
        id, phone, is_reg, name, sex, birth_time, position, position_two, job_responsibilities, photo_path, create_at, update_at, community_id
    </sql>
    <select id="getSysUserByPhoneCount" resultType="integer">
        select count(user_id) from sys_user where phone=#{phone} and type=1
    <select id="getSysUserIdByPhone" resultType="long">
        SELECT user_id FROM sys_user WHERE phone = #{phone} AND `type` = 1
    </select>
</mapper>