Browse Source

1,fix auth column for skill

2,fix module auth
tags/hc-0802
yk 2 years ago
parent
commit
5bf42e6abd
9 changed files with 225 additions and 79 deletions
  1. +28
    -0
      xueyi-api/xueyi-api-modules-auth/pom.xml
  2. +22
    -0
      xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/domain/vo/IntentionReqDto.java
  3. +24
    -0
      xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/feign/RemoteSkillAuthService.java
  4. +22
    -0
      xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/feign/factory/RemoteSkillAuthFallbackFactory.java
  5. +2
    -0
      xueyi-common/xueyi-common-core/src/main/java/com/xueyi/common/core/constant/basic/ServiceConstants.java
  6. +85
    -0
      xueyi-common/xueyi-common-web/src/main/java/com/xueyi/common/web/controller/BaseApiController.java
  7. +37
    -0
      xueyi-modules/xueyi-modules-auth/src/main/java/com/xueyi/modules/auth/controller/ApiController.java
  8. +4
    -3
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/digitalmans/domain/po/DmInitSkillsPo.java
  9. +1
    -76
      xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/resource/controller/api/BaseApiController.java

+ 28
- 0
xueyi-api/xueyi-api-modules-auth/pom.xml View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.xueyi</groupId>
<artifactId>xueyi-api</artifactId>
<version>2.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>xueyi-api-modules-auth</artifactId>

<description>
xueyi-api-modules-auth管理接口模块
</description>

<dependencies>

<!-- XueYi Common Core -->
<dependency>
<groupId>com.xueyi</groupId>
<artifactId>xueyi-common-core</artifactId>
</dependency>

</dependencies>

</project>

+ 22
- 0
xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/domain/vo/IntentionReqDto.java View File

@@ -0,0 +1,22 @@
package com.xueyi.modules.auth.api.domain.vo;

import lombok.Data;

import javax.validation.constraints.NotNull;

/**
* @author yk
* @description 意图请求对象DTO
* @date 2023-07-31 19:50
*/
@Data
public class IntentionReqDto {
@NotNull(message = "staffId不能为空")
private String staffId;
@NotNull(message = "staffType不能为空")
private String staffType;
@NotNull(message = "skillCode不能为空")
private String skillCode;
@NotNull(message = "devId不能为空")
private String devId;
}

+ 24
- 0
xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/feign/RemoteSkillAuthService.java View File

@@ -0,0 +1,24 @@
package com.xueyi.modules.auth.api.feign;

import com.xueyi.common.core.constant.basic.ServiceConstants;
import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.modules.auth.api.domain.vo.IntentionReqDto;
import com.xueyi.modules.auth.api.feign.factory.RemoteSkillAuthFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

/**
* 数据源服务
*
* @author xueyi
*/
@FeignClient(contextId = "remoteSkillAuthService", value = ServiceConstants.MODULES_AUTH_SERVICE, fallbackFactory = RemoteSkillAuthFallbackFactory.class)
public interface RemoteSkillAuthService {
@RequestMapping(value = "/api/inner/skillAuth", method = {RequestMethod.POST})
@ResponseBody
public AjaxResult skillAuth(@Valid IntentionReqDto intentionSkillAuth);
}

+ 22
- 0
xueyi-api/xueyi-api-modules-auth/src/main/java/com/xueyi/modules.auth/api/feign/factory/RemoteSkillAuthFallbackFactory.java View File

@@ -0,0 +1,22 @@
package com.xueyi.modules.auth.api.feign.factory;

import com.xueyi.modules.auth.api.feign.RemoteSkillAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
* 数据源服务降级处理
*
* @author xueyi
*/
@Slf4j
@Component
public class RemoteSkillAuthFallbackFactory implements FallbackFactory<RemoteSkillAuthService> {

@Override
public RemoteSkillAuthService create(Throwable cause) {
return null;
}
}

+ 2
- 0
xueyi-common/xueyi-common-core/src/main/java/com/xueyi/common/core/constant/basic/ServiceConstants.java View File

@@ -25,6 +25,8 @@ public class ServiceConstants {
/** 系统模块的serviceId */
public static final String MESSAGE_SERVICE = "xueyi-message";

public static final String MODULES_AUTH_SERVICE = "xueyi-modules-auth";

/** 定时任务模块的serviceId */
public static final String JOB_SERVICE = "xueyi-job";
/** 定时任务模块的serviceId */


+ 85
- 0
xueyi-common/xueyi-common-web/src/main/java/com/xueyi/common/web/controller/BaseApiController.java View File

@@ -0,0 +1,85 @@
package com.xueyi.common.web.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.collect.Lists;
import com.xueyi.common.web.constant.ResponseCode;
import com.xueyi.common.web.response.MyResponse;
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo;
import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

public class BaseApiController {

@Autowired
protected Map<Integer, Map<String,String>> responseMessageMap;
protected final static String EMPTY_STRING = "";

protected final static String LANGUAGE_CHINESE = "zh";
private MyResponse message = null;


public DeviceTenantSourceMergeVo getDeviceTenantSourceMergeVo(String devId){
return remoteDeviceTenantMergeService.selectDeviceTenantSourceMerge(devId);
}


@Autowired
private RemoteDeviceTenantMergeService remoteDeviceTenantMergeService;


protected MyResponse outputSuccess(){
return outputSuccess(null);
}
/**
* 业务处理成功
* @param data
* @return
*/
protected MyResponse outputSuccess(Object data){
return output(ResponseCode.SUCCESS, EMPTY_STRING, data);
}

protected MyResponse output(final Integer code) {
return output(code, EMPTY_STRING);
}

protected MyResponse output(final Integer code, final String replaceParameter) {
return output(code, replaceParameter, null);
}


protected MyResponse output(final Integer code, final String replaceParameter, final Object data) {
if (null == replaceParameter) {
return output(code, Lists.newArrayList(EMPTY_STRING), data, null);
}
return output(code, Lists.newArrayList(replaceParameter), data, null);
}

protected MyResponse output(final Integer code, final List<String> replaceParameters, final Object data, final String errorMessage){
if (ResponseCode.SUCCESS.equals(code)) {
if (null == data) {
message = new MyResponse(code);
} else {
message = new MyResponse(code, EMPTY_STRING, data);
}
} else {
String reponseText = StringUtils.isEmpty(errorMessage)? responseMessageMap.get(code).get(LANGUAGE_CHINESE) : errorMessage;
if (null != replaceParameters && replaceParameters.size() > 0) {
for (int i = 0; i < replaceParameters.size(); i++) {
reponseText = reponseText.replace("#p" + i + "#", replaceParameters.get(i));
}
}else{
reponseText = reponseText.replace("#p0#", "");
}
if (null == data){
message = new MyResponse(code, reponseText);
}else{
message = new MyResponse(code, reponseText, data);
}
}
return message;
}
}

+ 37
- 0
xueyi-modules/xueyi-modules-auth/src/main/java/com/xueyi/modules/auth/controller/ApiController.java View File

@@ -0,0 +1,37 @@
package com.xueyi.modules.auth.controller;


import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.web.controller.BaseApiController;
import com.xueyi.modules.auth.entity.IntentionReqDto;
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@RestController
@RequestMapping("api")
public class ApiController extends BaseApiController {



/**
* @Author yangkai
* @Description 技能权限验证,判断的意图对应的技能和传递的人员进行权限比对
* @Date 2023/7/31
* @Param IntentionReqDto对象
* @return AjaxResult
**/
@RequestMapping(value = "/skillAuth", method = {RequestMethod.GET})
@ResponseBody
public AjaxResult auth(@Valid IntentionReqDto reqDto, HttpServletResponse response) {
DeviceTenantSourceMergeVo vo = super.getDeviceTenantSourceMergeVo(reqDto.getDevId());

return AjaxResult.success("true");
}

}

+ 4
- 3
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/digitalmans/domain/po/DmInitSkillsPo.java View File

@@ -1,12 +1,11 @@
package com.xueyi.system.digitalmans.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.xueyi.common.core.annotation.Correlation;
import com.xueyi.common.core.annotation.Correlations;
import com.xueyi.common.core.annotation.Excel;
import com.xueyi.common.core.constant.basic.OperateConstants;
import com.xueyi.common.core.web.entity.base.BaseEntity;
import com.xueyi.system.digitalmans.domain.dto.DmInitSkillsDto;
import com.xueyi.common.core.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

@@ -58,4 +57,6 @@ public class DmInitSkillsPo extends BaseEntity {
@Excel(name = "执行动作")
protected String executeAction;

protected String auth;

}

+ 1
- 76
xueyi-modules/xueyi-system/src/main/java/com/xueyi/system/resource/controller/api/BaseApiController.java View File

@@ -4,11 +4,8 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.xueyi.common.web.constant.ResponseCode;
import com.xueyi.common.web.response.MyResponse;
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo;
import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService;
import com.xueyi.system.digitalmans.domain.dto.DmDigitalmanDto;
import com.xueyi.system.digitalmans.mapper.DmDigitalmanMapper;
import com.xueyi.system.digitalmans.service.impl.DmDigitalmanServiceImpl;
@@ -17,82 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class BaseApiController {

@Autowired
protected Map<Integer, Map<String,String>> responseMessageMap;
protected final static String EMPTY_STRING = "";

protected final static String LANGUAGE_CHINESE = "zh";
private MyResponse message = null;


public DeviceTenantSourceMergeVo getDeviceTenantSourceMergeVo(String devId){
return remoteDeviceTenantMergeService.selectDeviceTenantSourceMerge(devId);
}


@Autowired
private RemoteDeviceTenantMergeService remoteDeviceTenantMergeService;


protected MyResponse outputSuccess(){
return outputSuccess(null);
}
/**
* 业务处理成功
* @param data
* @return
*/
protected MyResponse outputSuccess(Object data){
return output(ResponseCode.SUCCESS, EMPTY_STRING, data);
}

protected MyResponse output(final Integer code) {
return output(code, EMPTY_STRING);
}

protected MyResponse output(final Integer code, final String replaceParameter) {
return output(code, replaceParameter, null);
}


protected MyResponse output(final Integer code, final String replaceParameter, final Object data) {
if (null == replaceParameter) {
return output(code, Lists.newArrayList(EMPTY_STRING), data, null);
}
return output(code, Lists.newArrayList(replaceParameter), data, null);
}

protected MyResponse output(final Integer code, final List<String> replaceParameters, final Object data, final String errorMessage){
if (ResponseCode.SUCCESS.equals(code)) {
if (null == data) {
message = new MyResponse(code);
} else {
message = new MyResponse(code, EMPTY_STRING, data);
}
} else {
String reponseText = StringUtils.isEmpty(errorMessage)? responseMessageMap.get(code).get(LANGUAGE_CHINESE) : errorMessage;
if (null != replaceParameters && replaceParameters.size() > 0) {
for (int i = 0; i < replaceParameters.size(); i++) {
reponseText = reponseText.replace("#p" + i + "#", replaceParameters.get(i));
}
}else{
reponseText = reponseText.replace("#p0#", "");
}
if (null == data){
message = new MyResponse(code, reponseText);
}else{
message = new MyResponse(code, reponseText, data);
}
}
return message;
}

public class BaseApiController extends com.xueyi.common.web.controller.BaseApiController {


@Autowired


Loading…
Cancel
Save