角色初始化调整,修改分页日志插入数据集问题,修改用户名称不能查询问题
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m17s
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m17s
This commit is contained in:
parent
3c138d6e39
commit
ec69eebe65
@ -70,6 +70,7 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
record.setAlertDeviceId(nccAlertInfo.getLocatorDeviceId());
|
||||
record.setMock(nccAlertInfo.isMock());
|
||||
record.setAlarmStatus(AlertStatus.NOT_DO);
|
||||
record.setLineType(nccAlertInfo.getLineType());
|
||||
// record.setAlertLocation(nccAlertInfo.getAlertLocationName());
|
||||
return record;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.alert;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertInfo;
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
@ -32,6 +33,8 @@ public class NccAlertInfo implements AlertInfo {
|
||||
@Setter
|
||||
private Integer alarmStatus;
|
||||
private AlertDeviceType alertDeviceType;
|
||||
@Setter
|
||||
private LineTypeEnum lineType;
|
||||
// private AlertType confirmAlertType;
|
||||
|
||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
||||
|
@ -5,13 +5,16 @@ import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.constants.SystemContext;
|
||||
import club.joylink.xiannccda.event.OperateEvent;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.google.common.collect.Maps;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
@ -62,24 +65,39 @@ public class SystemEventAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private String getUri(String[] uriMapping, String requestUri) {
|
||||
if (ArrayUtils.isEmpty(uriMapping)) {
|
||||
return requestUri;
|
||||
}
|
||||
if (Arrays.stream(uriMapping).anyMatch(StringUtils::isEmpty)) {
|
||||
return requestUri;
|
||||
}
|
||||
return uriMapping[0];
|
||||
}
|
||||
|
||||
private OperateEvent parseRequestParameter(JoinPoint joinPoint) {
|
||||
MethodSignature ms = (MethodSignature) joinPoint.getSignature();
|
||||
CommonLogAnno commonLogAnno = ms.getMethod().getDeclaredAnnotation(CommonLogAnno.class);
|
||||
if (Objects.nonNull(commonLogAnno)) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
GetMapping getMapping = ms.getMethod().getDeclaredAnnotation(GetMapping.class);
|
||||
PostMapping postMapping = ms.getMethod().getDeclaredAnnotation(PostMapping.class);
|
||||
DeleteMapping deleteMapping = ms.getMethod().getDeclaredAnnotation(DeleteMapping.class);
|
||||
Map<String, Object> params = Map.of();
|
||||
if (Objects.nonNull(getMapping)) {
|
||||
params = getRequestParam(getMapping.value(), joinPoint.getArgs());
|
||||
String requestURI = this.getUri(getMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
} else if (Objects.nonNull(postMapping)) {
|
||||
params = getRequestParam(postMapping.value(), joinPoint.getArgs());
|
||||
String requestURI = this.getUri(postMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
|
||||
} else if (Objects.nonNull(deleteMapping)) {
|
||||
params = getRequestParam(deleteMapping.value(), joinPoint.getArgs());
|
||||
String requestURI = this.getUri(deleteMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
|
||||
}
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
String method = request.getMethod();
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Long userId = null;
|
||||
@ -91,18 +109,16 @@ public class SystemEventAspect {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, Object> getRequestParam(String[] mappingUri, Object[] args) {
|
||||
private Map<String, Object> getRequestParam(String uriMap, Object[] args) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
int argsIndex = 0;
|
||||
if (ArrayUtils.isNotEmpty(mappingUri)) {
|
||||
Map<String, Object> uriParamMap = new HashMap<>();
|
||||
UriTemplate ut = new UriTemplate(mappingUri[0]);
|
||||
UriTemplate ut = new UriTemplate(uriMap);
|
||||
for (String vn : ut.getVariableNames()) {
|
||||
uriParamMap.put(vn, args[argsIndex]);
|
||||
argsIndex++;
|
||||
}
|
||||
params.put("uriParam", uriParamMap);
|
||||
}
|
||||
for (; argsIndex < args.length; argsIndex++) {
|
||||
params.put("param", args[argsIndex]);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO;
|
||||
import club.joylink.xiannccda.dto.record.AlertRecordReportDTO;
|
||||
import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO;
|
||||
@ -79,7 +80,8 @@ public class AlertRecordController {
|
||||
@ApiResponse(description = "报警记录")
|
||||
@CommonLogAnno(name = "报警信息-列表数据", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public Page<AlertRecord> pageQuery(@RequestBody AlertRecordQueryDTO queryDTO) {
|
||||
return alertRecordRepository.page(queryDTO);
|
||||
|
||||
return alertRecordRepository.newPage(CommonPageRequest.defaultPage(), queryDTO);
|
||||
}
|
||||
|
||||
|
||||
|
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
@ -0,0 +1,30 @@
|
||||
package club.joylink.xiannccda.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommonPage {
|
||||
|
||||
@Schema(description = "当前页码")
|
||||
private Integer current;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
@Schema(description = "每页条数")
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
@Schema(description = "排序字段,字段驼峰名称,如:userName")
|
||||
private String sortField;
|
||||
|
||||
/**
|
||||
* 排序方式
|
||||
*/
|
||||
@Schema(description = "排序方式,升序:ASCEND;降序:DESCEND")
|
||||
private String sortOrder;
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package club.joylink.xiannccda.dto;
|
||||
|
||||
import club.joylink.xiannccda.util.CommonServletUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 通用分页请求
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2021/12/18 14:43
|
||||
*/
|
||||
@Slf4j
|
||||
public class CommonPageRequest {
|
||||
|
||||
private static final String PAGE_SIZE_PARAM_NAME = "size";
|
||||
|
||||
private static final String PAGE_PARAM_NAME = "current";
|
||||
|
||||
private static final Integer PAGE_SIZE_MAX_VALUE = 100;
|
||||
|
||||
public static <T> Page<T> defaultPage() {
|
||||
return defaultPage(null);
|
||||
}
|
||||
|
||||
public static <T> Page<T> defaultPage(List<OrderItem> orderItemList) {
|
||||
|
||||
int size = 20;
|
||||
|
||||
int page = 1;
|
||||
|
||||
//每页条数
|
||||
String pageSizeString = CommonServletUtil.getParamFromRequest(PAGE_SIZE_PARAM_NAME);
|
||||
if (StringUtils.isNotEmpty(pageSizeString)) {
|
||||
try {
|
||||
size = Integer.parseInt(pageSizeString);
|
||||
if (size > PAGE_SIZE_MAX_VALUE) {
|
||||
size = PAGE_SIZE_MAX_VALUE;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 分页条数转换异常:", e);
|
||||
size = 20;
|
||||
}
|
||||
}
|
||||
|
||||
//第几页
|
||||
String pageString = CommonServletUtil.getParamFromRequest(PAGE_PARAM_NAME);
|
||||
if (StringUtils.isNotEmpty(pageString)) {
|
||||
try {
|
||||
page = Integer.parseInt(pageString);
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 分页页数转换异常:", e);
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
Page<T> objectPage = new Page<>(page, size);
|
||||
if (Objects.nonNull(orderItemList)) {
|
||||
objectPage.setOrders(orderItemList);
|
||||
}
|
||||
return objectPage;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.dto.alertTip;
|
||||
|
||||
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
@ -13,7 +14,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class AlertTipQueryDTO extends PageDTO<AlertTip> {
|
||||
public class AlertTipQueryDTO extends CommonPage {
|
||||
|
||||
@Schema(description = "告警类型")
|
||||
private String alertType;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.dto.config;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.entity.DeviceAreaConfig;
|
||||
import club.joylink.xiannccda.entity.DeviceGuardConfig;
|
||||
@ -9,7 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceAreaConfigQueryDto extends PageDTO<DeviceAreaConfig> {
|
||||
public class DeviceAreaConfigQueryDto extends CommonPage {
|
||||
|
||||
|
||||
@Schema(description = "设备类型")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.dto.record;
|
||||
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.entity.AlertRecord;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
@ -7,7 +8,7 @@ import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlertRecordQueryDTO extends PageDTO<AlertRecord> {
|
||||
public class AlertRecordQueryDTO extends CommonPage {
|
||||
|
||||
private AlertType alertType;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.dto.user;
|
||||
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.entity.AlertRecord;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
@ -12,10 +13,12 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
public class UserQueryDTO extends PageDTO<UserQueryDTO> {
|
||||
public class UserQueryDTO extends CommonPage {
|
||||
|
||||
|
||||
private String mobile;
|
||||
private String password;
|
||||
private String name;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.entity;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -44,6 +45,8 @@ public class AlertRecord {
|
||||
private String alertDeviceType;
|
||||
private String alertDeviceId;
|
||||
private Boolean mock;
|
||||
//线路类型
|
||||
private LineTypeEnum lineType;
|
||||
// private String confirmAlertType;
|
||||
public static final String ID = "id";
|
||||
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.entity;
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.entity.AuthApiPath.AuthApi;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -23,6 +25,15 @@ import org.apache.commons.lang3.StringUtils;
|
||||
@Schema(name = "authRole", description = "用户角色")
|
||||
public class AuthRole {
|
||||
|
||||
public AuthRole() {
|
||||
|
||||
}
|
||||
|
||||
public AuthRole(Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ -36,14 +47,17 @@ public class AuthRole {
|
||||
|
||||
@Schema(description = "角色配置")
|
||||
@TableField(exist = false)
|
||||
private RoleConfig roleConfig;
|
||||
private List<RoleConfig> roleConfig;
|
||||
|
||||
public RoleConfig getRoleConfig() {
|
||||
public List<RoleConfig> getRoleConfig() {
|
||||
if (StringUtils.isNotEmpty(this.roleConfigStr)) {
|
||||
return JSON.parseObject(this.roleConfigStr, RoleConfig.class);
|
||||
return JSONArray.parseArray(this.roleConfigStr, RoleConfig.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<RoleConfig> tmpRoleConfig() {
|
||||
return this.roleConfig;
|
||||
}
|
||||
|
||||
public static final String ID = "id";
|
||||
@ -58,5 +72,13 @@ public class AuthRole {
|
||||
@Schema(description = "线路类型")
|
||||
private LineTypeEnum lineType;
|
||||
|
||||
public RoleConfig() {
|
||||
|
||||
}
|
||||
|
||||
public RoleConfig(Integer lineId, LineTypeEnum lineType) {
|
||||
this.lineId = lineId;
|
||||
this.lineType = lineType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,5 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface AlertTipMapper extends BaseMapper<AlertTip> {
|
||||
|
||||
IPage<AlertTipInfoDto> selectForPage(@Param("tipQuery") AlertTipQueryDTO dto);
|
||||
IPage<AlertTipInfoDto> selectForPage(IPage page, @Param("tipQuery") AlertTipQueryDTO dto);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.mapper;
|
||||
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||
import club.joylink.xiannccda.entity.User;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -19,6 +20,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
Page<UserDetailDTO> detailQuery(@Param("dto") UserQueryDTO dto);
|
||||
Page<UserDetailDTO> detailQuery(Page page, @Param("ew") QueryWrapper<UserDetailDTO> qw);
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface IAlertRecordRepository extends IService<AlertRecord> {
|
||||
|
||||
Page<AlertRecord> page(AlertRecordQueryDTO queryDTO);
|
||||
Page<AlertRecord> newPage(Page page, AlertRecordQueryDTO queryDTO);
|
||||
|
||||
List<AlertRecordReportResponseDTO> report(Integer lineId, AlertRecordReportDTO reportDTO);
|
||||
}
|
||||
|
@ -22,5 +22,5 @@ public interface IAlertTipRepository extends IService<AlertTip> {
|
||||
|
||||
Map<Long, String> findBindAreaConfigId(List<Long> areaConfigList);
|
||||
|
||||
IPage<AlertTipInfoDto> leftAreaPage(AlertTipQueryDTO queryDTO);
|
||||
IPage<AlertTipInfoDto> leftAreaPage(IPage<AlertTipQueryDTO> page, AlertTipQueryDTO queryDTO);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
public class AlertRecordRepository extends ServiceImpl<AlertRecordMapper, AlertRecord> implements IAlertRecordRepository {
|
||||
|
||||
@Override
|
||||
public Page<AlertRecord> page(AlertRecordQueryDTO queryDTO) {
|
||||
public Page<AlertRecord> newPage(Page page, AlertRecordQueryDTO queryDTO) {
|
||||
if (Objects.nonNull(queryDTO.getBeginDateTime()) && Objects.nonNull(queryDTO.getEndDateTime())) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(queryDTO.getBeginDateTime().isAfter(queryDTO.getEndDateTime()), "查询开始时间不能小于结束时间");
|
||||
}
|
||||
@ -41,7 +41,7 @@ public class AlertRecordRepository extends ServiceImpl<AlertRecordMapper, AlertR
|
||||
queryWrapper.orderByDesc(AlertRecord::getId);
|
||||
queryWrapper.orderByAsc(AlertRecord::getAlarmStatus);
|
||||
|
||||
return page(queryDTO, queryWrapper);
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,8 +55,8 @@ public class AlertTipRepository extends ServiceImpl<AlertTipMapper, AlertTip> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<AlertTipInfoDto> leftAreaPage(AlertTipQueryDTO queryDTO) {
|
||||
return this.baseMapper.selectForPage(queryDTO);
|
||||
public IPage<AlertTipInfoDto> leftAreaPage(IPage page, AlertTipQueryDTO queryDTO) {
|
||||
return this.baseMapper.selectForPage(page, queryDTO);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package club.joylink.xiannccda.repository.impl;
|
||||
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserDetailDTO.UserRoleDetail;
|
||||
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||
import club.joylink.xiannccda.entity.User;
|
||||
import club.joylink.xiannccda.mapper.UserMapper;
|
||||
import club.joylink.xiannccda.repository.IUserRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -28,7 +30,18 @@ public class UserRepository extends ServiceImpl<UserMapper, User> implements IUs
|
||||
|
||||
@Override
|
||||
public Page<UserDetailDTO> userRolePage(UserQueryDTO dto) {
|
||||
Page<UserDetailDTO> page = this.baseMapper.detailQuery(dto);
|
||||
|
||||
QueryWrapper<UserDetailDTO> qw = new QueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(dto.getMobile())) {
|
||||
qw.eq("A.mobile", dto.getMobile());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dto.getPassword())) {
|
||||
qw.eq("A.password", dto.getPassword());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dto.getName())) {
|
||||
qw.like("A.name", dto.getName());
|
||||
}
|
||||
Page<UserDetailDTO> page = this.baseMapper.detailQuery(CommonPageRequest.defaultPage(), qw);
|
||||
for (UserDetailDTO record : page.getRecords()) {
|
||||
List<UserRoleDetail> userRoleList = Lists.newArrayList();
|
||||
if (StringUtils.isNotEmpty(record.getUserRoles())) {
|
||||
|
@ -3,6 +3,8 @@ package club.joylink.xiannccda.service;
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.TipTimeConfig;
|
||||
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO;
|
||||
@ -13,6 +15,7 @@ import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
||||
import club.joylink.xiannccda.repository.impl.AlertTipRepository;
|
||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||
import club.joylink.xiannccda.util.CommonServletUtil;
|
||||
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
@ -184,6 +187,7 @@ public class AlertRecordService {
|
||||
AlertType.valueOf(record.getAlertType()), Objects.isNull(record.getAlertTipId()) ? null : record.getAlertTipId().intValue(), record.getLineId(),
|
||||
record.getAlertObject(), "", record.getAlertLocationId(), deviceType);
|
||||
nccAlertInfo.setId(record.getId());
|
||||
nccAlertInfo.setLineType(record.getLineType());
|
||||
nccAlertInfo.setAlarmStatus(record.getAlarmStatus());
|
||||
// if (StringUtils.isNotEmpty(record.getConfirmAlertType())) {
|
||||
// nccAlertInfo.setAlertType(AlertType.valueOf(record.getConfirmAlertType()));
|
||||
@ -195,7 +199,8 @@ public class AlertRecordService {
|
||||
}
|
||||
|
||||
public Page<NccAlertInfo> pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) {
|
||||
Page<AlertRecord> recordPage = alertRecordRepository.page(queryDTO);
|
||||
|
||||
Page<AlertRecord> recordPage = alertRecordRepository.newPage(CommonPageRequest.defaultPage(), queryDTO);
|
||||
List<NccAlertInfo> collect = this.changeData(recordPage.getRecords());
|
||||
Page<NccAlertInfo> nccPage = Page.of(recordPage.getCurrent(), recordPage.getSize(),
|
||||
recordPage.getTotal());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.service;
|
||||
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||
@ -92,7 +93,7 @@ public class AlertTipService {
|
||||
}
|
||||
|
||||
public IPage<AlertTipInfoDto> page(AlertTipQueryDTO queryDTO) {
|
||||
IPage<AlertTipInfoDto> page = this.alertTipRepository.leftAreaPage(queryDTO);
|
||||
IPage<AlertTipInfoDto> page = this.alertTipRepository.leftAreaPage(CommonPageRequest.defaultPage(), queryDTO);
|
||||
|
||||
for (AlertTipInfoDto record : page.getRecords()) {
|
||||
if (StringUtils.isNotEmpty(record.getTipTimeRef())) {
|
||||
|
@ -37,6 +37,7 @@ public class UserService {
|
||||
final IAuthRoleUserRefRepository authRoleUserRefRepository;
|
||||
final IAuthRoleRepository authRoleRepository;
|
||||
private final static long EXPIRY = 3 * 24 * 60 * 60;//3天过期时间
|
||||
// private final static long EXPIRY = 180;//3天过期时间
|
||||
|
||||
public UserService(IUserRepository userRepository, JwtEncoder jwtEncoder, IAuthRoleUserRefRepository authRoleUserRefRepository, IAuthRoleRepository authRoleRepository) {
|
||||
this.userRepository = userRepository;
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.service.config;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigDto;
|
||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigPageDto;
|
||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigQueryDto;
|
||||
@ -176,7 +177,7 @@ public class DeviceAreaConfigService {
|
||||
queryWrapper.last(String.format(" and find_in_set('%s',%s) > 0", queryDTO.getAlertType().name(), DeviceAreaConfig.ALERT_TYPES));
|
||||
}
|
||||
|
||||
Page<DeviceAreaConfig> pageConfig = deviceAreaConfigRepository.page(queryDTO, queryWrapper);
|
||||
Page<DeviceAreaConfig> pageConfig = deviceAreaConfigRepository.page(CommonPageRequest.defaultPage(), queryWrapper);
|
||||
return this.convertPage(pageConfig);
|
||||
}
|
||||
|
||||
|
56
src/main/java/club/joylink/xiannccda/task/InitTask.java
Normal file
56
src/main/java/club/joylink/xiannccda/task/InitTask.java
Normal file
@ -0,0 +1,56 @@
|
||||
package club.joylink.xiannccda.task;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.entity.AuthRole;
|
||||
import club.joylink.xiannccda.entity.AuthRole.RoleConfig;
|
||||
import club.joylink.xiannccda.repository.IAuthRoleRepository;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class InitTask implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private IAuthRoleRepository authRoleRepository;
|
||||
|
||||
private Map<String, AuthRole> staticInitialData() {
|
||||
Map<String, AuthRole> roleMap = new HashMap<>();
|
||||
AuthRole r1 = new AuthRole(1L, "超级管理员");
|
||||
r1.setRoleConfig(List.of(initRoleConfig(3, LineTypeEnum.NCC),
|
||||
initRoleConfig(4, LineTypeEnum.NCC)));
|
||||
roleMap.put("超级管理员", r1);
|
||||
r1 = new AuthRole(2L, "3号线ATS");
|
||||
r1.setRoleConfig(List.of(initRoleConfig(3, LineTypeEnum.OCC)));
|
||||
roleMap.put("3号线ATS", r1);
|
||||
r1 = new AuthRole(3L, "4号线ATS");
|
||||
r1.setRoleConfig(List.of(initRoleConfig(4, LineTypeEnum.OCC)));
|
||||
roleMap.put("4号线ATS", r1);
|
||||
return roleMap;
|
||||
}
|
||||
|
||||
private RoleConfig initRoleConfig(int lineId, LineTypeEnum lineType) {
|
||||
return new RoleConfig(lineId, lineType);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Map<String, AuthRole> initRoleMap = this.staticInitialData();
|
||||
QueryWrapper<AuthRole> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(AuthRole::getName, List.of(initRoleMap.keySet()));
|
||||
// List<AuthRole> authRoles = this.authRoleRepository.list(qw);
|
||||
initRoleMap.forEach((k, v) -> {
|
||||
|
||||
v.setRoleConfigStr(JSON.toJSONString(v.tmpRoleConfig()));
|
||||
this.authRoleRepository.saveOrUpdate(v);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package club.joylink.xiannccda.util;
|
||||
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
/**
|
||||
* HttpServlet工具类,获取当前request和response
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2020/3/30 15:09
|
||||
*/
|
||||
@Slf4j
|
||||
public class CommonServletUtil {
|
||||
|
||||
/**
|
||||
* 从请求中中获取参数
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2021/10/14 10:44
|
||||
**/
|
||||
public static String getParamFromRequest(String paramName) {
|
||||
HttpServletRequest request = getRequest();
|
||||
|
||||
// 1. 尝试从请求体里面读取
|
||||
String paramValue = request.getParameter(paramName);
|
||||
|
||||
// 2. 尝试从header里读取
|
||||
if (StringUtils.isEmpty(paramValue)) {
|
||||
paramValue = request.getHeader(paramName);
|
||||
}
|
||||
// 3. 尝试从cookie里读取
|
||||
if (Objects.isNull(paramValue)) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (ArrayUtils.isNotEmpty(cookies)) {
|
||||
for (Cookie cookie : cookies) {
|
||||
String cookieName = cookie.getName();
|
||||
if (cookieName.equals(paramName)) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4. 返回
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
ServletRequestAttributes servletRequestAttributes;
|
||||
try {
|
||||
servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
} catch (Exception e) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception();
|
||||
}
|
||||
if (servletRequestAttributes == null) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception();
|
||||
} else {
|
||||
return servletRequestAttributes.getRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpServletResponse getResponse() {
|
||||
ServletRequestAttributes servletRequestAttributes;
|
||||
try {
|
||||
servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 非Web上下文无法获取Response:", e);
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception();
|
||||
}
|
||||
if (servletRequestAttributes == null) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception();
|
||||
} else {
|
||||
return servletRequestAttributes.getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWeb() {
|
||||
return RequestContextHolder.getRequestAttributes() != null;
|
||||
}
|
||||
}
|
@ -15,20 +15,16 @@
|
||||
<sql id="Base_Column_List">
|
||||
id, name, mobile, password, register_time
|
||||
</sql>
|
||||
<select id="detailQuery" resultType="club.joylink.xiannccda.dto.user.UserDetailDTO" parameterType="club.joylink.xiannccda.dto.user.UserQueryDTO">
|
||||
<select id="detailQuery" resultType="club.joylink.xiannccda.dto.user.UserDetailDTO">
|
||||
select A.id, A.name, A.mobile, A.register_time, B.user_roles,A.default_role
|
||||
from user A
|
||||
left join (select A.user_id, GROUP_CONCAT(A.role_id, '|', B.`name`) as user_roles
|
||||
from auth_role_user_ref A
|
||||
left join auth_role B on A.role_id = B.id
|
||||
GROUP BY user_id) B
|
||||
on A.id = B.user_id
|
||||
GROUP BY user_id) B on A.id = B.user_id
|
||||
where 1 = 1
|
||||
<if test="dto.mobile != null">
|
||||
and A.mobile = #{dto.mobile}
|
||||
</if>
|
||||
<if test="dto.password != null">
|
||||
and A.password = #{dto.password}
|
||||
<if test="ew.sqlSegment !=null and ew.sqlSegment !=''">
|
||||
and ${ew.sqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user