Commit 986c9500 authored by zhangc's avatar zhangc

优化部分代码

parent 7893c12f
......@@ -245,3 +245,20 @@ CREATE TABLE `t_api_syncing_datasource_type` (
`is_deleted` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api数据源类型信息表';
# 字典表
DROP TABLE IF EXISTS `t_api_direction`;
CREATE TABLE `t_api_direction` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`key` varchar(64) DEFAULT NULL COMMENT '字典key',
`value` varchar(64) DEFAULT NULL COMMENT '字典value',
`code` varchar(100) DEFAULT NULL COMMENT '字典编码',
`parent` varchar(32) DEFAULT NULL COMMENT '父节点',
`direction_type` varchar(32) DEFAULT NULL COMMENT '字典类型',
`level` int(10) DEFAULT NULL COMMENT '等级',
`is_enabled` char(1) DEFAULT NULL COMMENT '是否启用',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
`is_deleted` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api字典表信息表';
\ No newline at end of file
......@@ -42,4 +42,12 @@ public enum ApiStatusEnum {
return text;
}
public static ApiStatusEnum fromTypeName(String typeName) {
for (ApiStatusEnum type : ApiStatusEnum.values()) {
if (type.name().equals(typeName)) {
return type;
}
}
return null;
}
}
......@@ -34,4 +34,13 @@ public enum AuthModeEnum {
public String getText() {
return text;
}
public static AuthModeEnum fromTypeName(String typeName) {
for (AuthModeEnum type : AuthModeEnum.values()) {
if (type.name().equals(typeName)) {
return type;
}
}
return null;
}
}
......@@ -29,4 +29,13 @@ public enum AuthTypeEnum {
public String getText() {
return text;
}
public static AuthTypeEnum fromTypeName(String typeName) {
for (AuthTypeEnum type : AuthTypeEnum.values()) {
if (type.name().equals(typeName)) {
return type;
}
}
return null;
}
}
package com.jz.dm.common.enums.direction;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums
* @PROJECT_NAME: jz-dm-parent
* @NAME: DirectionTypeEnum
* @DATE: 2020-12-31/18:39
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public enum DirectionTypeEnum {
/**
* API类型
*/
API_TYPE;
public static DirectionTypeEnum fromTypeName(String typeName) {
for (DirectionTypeEnum type : DirectionTypeEnum.values()) {
if (type.name().equals(typeName)) {
return type;
}
}
return null;
}
}
package com.jz.dm.controller;
import com.jz.common.utils.Result;
import com.jz.dm.service.ApiDirectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiLogController
* @DATE: 2020-12-25/14:25
* @DAY_NAME_SHORT: 周五
* @Description:
**/
@RestController
@RequestMapping("api/direction")
@Api(tags = "API字典信息Controller")
public class ApiDirectionController {
@Autowired
private ApiDirectionService apiDirectionService;
/**
* @Description:api类型列表
* @return: api类型列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation("api类型列表")
@PostMapping(value = "/getApiTypeList")
public Mono<Result> getApiTypeList(@RequestParam(name = "type") String type) {
return Mono.fromSupplier(() -> Result.of_success(apiDirectionService.getApiType(type)));
}
}
package com.jz.dm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jz.dm.models.domian.ApiDirection;
/**api授权信息表 mapper
* @author zc
*
*/
public interface ApiDirectionMapper extends BaseMapper<ApiDirection> {
}
package com.jz.dm.models.domian;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jz.dm.common.base.BaseObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@Accessors(chain = true)
@TableName("t_api_direction")
public class ApiDirection extends BaseObject implements Serializable {
/**
* 字典key
*/
@TableField("key")
private String key;
/**
* 字典value
*/
@TableField("value")
private String value;
/**
* 字典编码
*/
@TableField("code")
private String code;
/**
* 父节点
*/
@TableField("parent")
private String parent;
/**
* 字典类型
*/
@TableField("direction_type")
private String directionType;
/**
* is_enabled
*/
@TableField("level")
private Integer level;
/**
* 是否启用:UNABLE 停用,ENABLE 启用
*/
@TableField("is_enabled")
private String isEnabled;
}
package com.jz.dm.service;
import com.jz.dm.models.domian.ApiDirection;
import java.util.List;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionService
* @DATE: 2020-12-31/18:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public interface ApiDirectionService {
/**
* 根据类型获取API类型信息
* @param type
* @return
*/
List<ApiDirection> getApiType(String type);
}
package com.jz.dm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jz.dm.mapper.ApiDirectionMapper;
import com.jz.dm.models.domian.ApiDirection;
import com.jz.dm.service.ApiDirectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionServiceImpl
* @DATE: 2020-12-31/18:01
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Service("apiDirectionService")
@Slf4j
public class ApiDirectionServiceImpl implements ApiDirectionService {
@Resource
private ApiDirectionMapper apiDirectionMapper;
@Override
public List<ApiDirection> getApiType(String type) {
QueryWrapper<ApiDirection> query = new QueryWrapper<>();
query.eq("direction_type",type);
query.eq("is_enabled",0);
return apiDirectionMapper.selectList(query);
}
}
......@@ -76,14 +76,12 @@ public class ApiLogServiceImpl implements ApiLogService {
*/
@Override
public void updateLog(Long id, JSONObject jsonObject) {
//if (!lock.tryLock("apiLog")){
// return;
//}
try {
ApiReqLog apiReqLog = apiReqLogMapper.maxId(id);
if (null != apiReqLog){
ApiReqLog reqLog = new ApiReqLog();
reqLog.setId(apiReqLog.getId());
reqLog.setStatus(apiReqLog.getStatus());
reqLog.setResponseParams(jsonObject.toString());
reqLog.setUpdateDate(new Date());
apiReqLogMapper.updateById(reqLog);
......@@ -93,9 +91,5 @@ public class ApiLogServiceImpl implements ApiLogService {
}catch (Exception ex){
log.error("更新日志返回信息异常:{}",ex.getMessage());
}
//finally {
// lock.unlock("apiLog");
//}
}
}
......@@ -5,6 +5,7 @@ import com.jz.common.utils.IpUtils;
import com.jz.common.utils.JsonUtils;
import com.jz.common.utils.UrlUtil;
import com.jz.dm.common.util.SignType;
import com.jz.dm.mapper.ApiReqLogMapper;
import com.jz.dm.models.domian.ApiReqLog;
import com.jz.dm.service.ApiLogService;
import com.jz.dm.web.annotation.ApiLogAspect;
......@@ -46,6 +47,8 @@ public class SystemLogAspect {
@Resource
private ApiLogService apiLogService;
@Resource
private ApiReqLogMapper apiReqLogMapper;
/* //前置通知切入点
@Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
......@@ -98,7 +101,7 @@ public class SystemLogAspect {
reqLog.setRemark(getServiceMethodDescription(joinPoint));
System.out.println(reqLog);
if (null != reqLog) {
apiLogService.insetLogInfo(reqLog);
apiReqLogMapper.insert(reqLog);
}
Object result = joinPoint.proceed(joinPoint.getArgs());
JSONObject jsonObject = JSONObject.fromObject(result);
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.jz.dm.mapper.ApiDirectionMapper" >
</mapper>
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