访客接口,对指定用户下线功能-1
This commit is contained in:
1 parent
fe87379564
commit
3ab0cbef40
13 files changed
+309
-21
No files matched your search
@@ -74,10 +74,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -320,9 +317,14 @@ public class PjcloudTokenEndpoint {
|
||||
}).filter(tokenVo -> {
|
||||
// 根据用户名过滤
|
||||
String username = MapUtil.getStr(params, SecurityConstants.DETAILS_USERNAME);
|
||||
// Long userId = MapUtil.getLong(params, SecurityConstants.USER_ID);
|
||||
if (StrUtil.isBlank(username)) {
|
||||
return true;
|
||||
}
|
||||
// if (null==userId) {
|
||||
// return true;
|
||||
// }
|
||||
// return tokenVo.getUserId().equals(userId);
|
||||
return tokenVo.getUsername().contains(username);
|
||||
}).collect(Collectors.toList());
|
||||
result.setRecords(tokenVoList);
|
||||
@@ -330,6 +332,53 @@ public class PjcloudTokenEndpoint {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端下线
|
||||
* token查询
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("/selectTokenByUserId")
|
||||
public R<List<TokenVO>> tokenList(@RequestParam("userId")Long userId,@RequestParam("clientId")String clientId) {
|
||||
// 根据分页参数获取对应数据
|
||||
String key = String.format("%s::%s::*", tenantKeyStrResolver.key(), CacheConstants.PROJECT_OAUTH_ACCESS);
|
||||
Set<String> keys = redisTemplate.keys(key);
|
||||
|
||||
List<TokenVO> tokenVoList = redisTemplate.opsForValue().multiGet(new ArrayList<>(keys)).stream().map(obj -> {
|
||||
OAuth2Authorization authorization = (OAuth2Authorization) obj;
|
||||
TokenVO tokenVo = new TokenVO();
|
||||
tokenVo.setClientId(authorization.getRegisteredClientId());
|
||||
tokenVo.setId(authorization.getId());
|
||||
tokenVo.setUsername(authorization.getPrincipalName());
|
||||
OAuth2Authorization.Token<OAuth2AccessToken> accessToken = authorization.getAccessToken();
|
||||
tokenVo.setAccessToken(accessToken.getToken().getTokenValue());
|
||||
|
||||
String expiresAt = TemporalAccessorUtil.format(accessToken.getToken().getExpiresAt(),
|
||||
DatePattern.NORM_DATETIME_PATTERN);
|
||||
tokenVo.setExpiresAt(expiresAt);
|
||||
|
||||
String issuedAt = TemporalAccessorUtil.format(accessToken.getToken().getIssuedAt(),
|
||||
DatePattern.NORM_DATETIME_PATTERN);
|
||||
tokenVo.setIssuedAt(issuedAt);
|
||||
|
||||
Map<String, Object> attributes = authorization.getAttributes();
|
||||
Authentication authentication = (Authentication) attributes.get(Principal.class.getName());
|
||||
|
||||
if (Objects.isNull(authentication)) {
|
||||
return tokenVo;
|
||||
}
|
||||
|
||||
PjcloudUser pjcloudUser = (PjcloudUser) authentication.getPrincipal();
|
||||
tokenVo.setUserId(pjcloudUser.getId());
|
||||
return tokenVo;
|
||||
}).filter(tokenVo -> {
|
||||
return tokenVo.getUserId().equals(userId) && tokenVo.getClientId().equals(clientId);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return R.ok(tokenVoList);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/query-token")
|
||||
public R queryToken(String token) {
|
||||
|
||||
+6
@@ -204,6 +204,12 @@ public interface SecurityConstants {
|
||||
*/
|
||||
String DETAILS_USERNAME = "username";
|
||||
|
||||
|
||||
/**
|
||||
* id建
|
||||
*/
|
||||
String USER_ID = "userId";
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
|
||||
+11
-10
@@ -55,13 +55,8 @@ public class VisitorsAppDTO {
|
||||
* 接待人
|
||||
*/
|
||||
@Schema(description="接待人")
|
||||
private Long userName;
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 车牌号id
|
||||
*/
|
||||
@Schema(description="车牌号id")
|
||||
private Long carId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
@@ -75,11 +70,17 @@ public class VisitorsAppDTO {
|
||||
@Schema(description="随行人员数量")
|
||||
private Integer peopleNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vDate;
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vStartDate;
|
||||
/**
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vEndDate;
|
||||
|
||||
/**
|
||||
* 是否驾驶车辆0 否 1是
|
||||
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.bsd.pjcloud.integrated.vo.app.visitor;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 访客表
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-04-09 15:22:47
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "访客表vo")
|
||||
public class VisitorsAppVo{
|
||||
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Schema(description="id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Schema(description="姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Schema(description="手机号")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@Schema(description="身份证号")
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description="描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
@Schema(description="审核状态")
|
||||
private String checkStatus;
|
||||
|
||||
/**
|
||||
* 到访单位
|
||||
*/
|
||||
@Schema(description="到访单位")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 接待人
|
||||
*/
|
||||
@Schema(description="接待人")
|
||||
private Long userName;
|
||||
|
||||
/**
|
||||
* 车牌号id
|
||||
*/
|
||||
@Schema(description="车牌号id")
|
||||
private Long carId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Schema(description="公司名称")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 随行人员数量
|
||||
*/
|
||||
@Schema(description="随行人员数量")
|
||||
private Integer peopleNumber;
|
||||
|
||||
/**
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vStartDate;
|
||||
/**
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vEndDate;
|
||||
|
||||
/**
|
||||
* 是否驾驶车辆0 否 1是
|
||||
*/
|
||||
@Schema(description="是否驾驶车辆0 否 1是")
|
||||
private String isDrive;
|
||||
|
||||
|
||||
/**
|
||||
* 审核原因
|
||||
*/
|
||||
@Schema(description="审核原因")
|
||||
private String checkReason;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
|
||||
@Schema(description="token")
|
||||
private String token;
|
||||
|
||||
@Schema(description="车牌号")
|
||||
private List<VisitorsCarAppVo> visitorsCarAppVos;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.bsd.pjcloud.integrated.vo.app.visitor;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-04-09 15:10:54
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Schema(description = "车牌号")
|
||||
public class VisitorsCarAppVo {
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
@Schema(description="车牌号")
|
||||
private String carNumber;
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,12 @@
|
||||
<artifactId>pjcloud-integrated-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- 幂等插件使用 -->
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--必备: undertow容器-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
* <p>
|
||||
* 项目启动类
|
||||
*/
|
||||
@EnableOpenApi("supermarketerp")
|
||||
@EnableOpenApi("integrated")
|
||||
@EnablePjcloudFeignClients
|
||||
@EnableDiscoveryClient
|
||||
@EnablePjcloudResourceServer
|
||||
|
||||
+36
-1
@@ -7,7 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.integrated.dto.visitors.app.VisitorsAppDTO;
|
||||
import com.bsd.pjcloud.integrated.entity.VisitorsEntity;
|
||||
import com.bsd.pjcloud.integrated.service.VisitorsService;
|
||||
@@ -21,6 +24,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -129,9 +133,40 @@ public class VisitorsController {
|
||||
*/
|
||||
@Operation(summary = "app新增访客表" , description = "app新增访客表" )
|
||||
@SysLog("新增访客表" )
|
||||
@PostMapping
|
||||
@PostMapping("/app/save")
|
||||
@Idempotent(key = "#key", expireTime = 10, info = "请勿重复提交")
|
||||
@Inner(value = false)
|
||||
public R save(@RequestBody VisitorsAppDTO visitors) {
|
||||
|
||||
return R.ok(visitorsService.vistorsSave(visitors));
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码发送请求确认是否能通过
|
||||
* 通过token查询访客表
|
||||
* @param
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过token查询" , description = "通过token查询" )
|
||||
@GetMapping("/app/check/{token}" )
|
||||
public R getByToken(@PathVariable("token" ) String token) {
|
||||
|
||||
LambdaQueryWrapper<VisitorsEntity> visitorsEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getToken,token);
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getCheckStatus, TaskCheckStatusEnum.RESULT);
|
||||
VisitorsEntity visitors = visitorsService.getOne(visitorsEntityLambdaQueryWrapper);
|
||||
if (visitors == null){
|
||||
return R.failed("没有此预约信息");
|
||||
}
|
||||
LocalDateTime vStartDate = visitors.getVStartDate();
|
||||
if (vStartDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约时间未到");
|
||||
}
|
||||
LocalDateTime vEndDate = visitors.getVEndDate();
|
||||
if (vEndDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约已过期");
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -93,7 +93,12 @@ public class VisitorsEntity extends Model<VisitorsEntity> {
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vDate;
|
||||
private LocalDateTime vStartDate;
|
||||
/**
|
||||
* 到访时间
|
||||
*/
|
||||
@Schema(description="到访时间")
|
||||
private LocalDateTime vEndDate;
|
||||
|
||||
/**
|
||||
* 是否驾驶车辆0 否 1是
|
||||
@@ -154,4 +159,8 @@ public class VisitorsEntity extends Model<VisitorsEntity> {
|
||||
*/
|
||||
@Schema(description="租户编号")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
@Schema(description="token")
|
||||
private String token;
|
||||
}
|
||||
+16
-2
@@ -17,12 +17,18 @@ import com.bsd.pjcloud.integrated.entity.VisitorsEntity;
|
||||
import com.bsd.pjcloud.integrated.mapper.VisitorsCarMapper;
|
||||
import com.bsd.pjcloud.integrated.mapper.VisitorsMapper;
|
||||
import com.bsd.pjcloud.integrated.service.VisitorsService;
|
||||
import com.bsd.pjcloud.integrated.vo.app.visitor.VisitorsAppVo;
|
||||
import com.bsd.pjcloud.integrated.vo.app.visitor.VisitorsCarAppVo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.oauth2.jwt.JwtClaimsSet;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 访客表
|
||||
@@ -61,7 +67,10 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
bean.setProcessInstanceId(processInstanceId);
|
||||
bean.setCheckStatus(TaskCheckStatusEnum.PADDING.getCode());
|
||||
|
||||
int insert = baseMapper.insert(bean);
|
||||
String uniqueToken = UUID.randomUUID().toString();
|
||||
String token = uniqueToken.replace("-", "");
|
||||
bean.setToken(token);
|
||||
baseMapper.insert(bean);
|
||||
List<VisitorsCarAppDTO> visitorsCarAppDTOList = visitors.getVisitorsCarAppDTOList();
|
||||
if (!CollectionUtils.isEmpty(visitorsCarAppDTOList)){
|
||||
List<VisitorsCarEntity> visitorsCarEntities = BeanUtils.toBean(visitorsCarAppDTOList, VisitorsCarEntity.class);
|
||||
@@ -70,6 +79,11 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
});
|
||||
visitorsCarMapper.insert(visitorsCarEntities);
|
||||
}
|
||||
return insert;
|
||||
VisitorsAppVo visitorAppVo = BeanUtils.toBean(bean, VisitorsAppVo.class);
|
||||
List<VisitorsCarAppVo> visitorsCarAppVos = BeanUtils.toBean(visitorsCarAppDTOList, VisitorsCarAppVo.class);
|
||||
visitorAppVo.setVisitorsCarAppVos(visitorsCarAppVos);
|
||||
return visitorAppVo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+3
-1
@@ -15,7 +15,8 @@
|
||||
<result property="carId" column="car_id"/>
|
||||
<result property="companyName" column="company_name"/>
|
||||
<result property="peopleNumber" column="people_number"/>
|
||||
<result property="vDate" column="v_date"/>
|
||||
<result property="vStartDate" column="v_start_date"/>
|
||||
<result property="vEndDate" column="v_end_data"/>
|
||||
<result property="isDrive" column="is_drive"/>
|
||||
<result property="processInstanceId" column="process_instance_id"/>
|
||||
<result property="checkReason" column="check_reason"/>
|
||||
@@ -25,5 +26,6 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
<result property="token" column="token"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+10
@@ -44,6 +44,16 @@ public interface RemoteTokenService {
|
||||
@PostMapping("/token/page")
|
||||
R<Page> getTokenPage(@RequestBody Map<String, Object> params);
|
||||
|
||||
|
||||
/**
|
||||
* 查询token 信息
|
||||
* @param
|
||||
* @return page
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/token/selectTokenByUserId")
|
||||
R<Page> getTokenByUserId(@RequestParam("userId")Long userId,@RequestParam("clientId")String clientId);
|
||||
|
||||
/**
|
||||
* 删除token
|
||||
* @param token token
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class SysTokenController {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param token getTokenPage
|
||||
* @param tokens getTokenPage
|
||||
* @return success/false
|
||||
*/
|
||||
@SysLog("删除用户token")
|
||||
|
||||
Reference in new issue
Block a user