Commit 29646613 authored by zhangc's avatar zhangc

优化部分认证代码

parent bb7a4f1d
...@@ -45,6 +45,24 @@ CREATE TABLE `t_api_interface_custom` ( ...@@ -45,6 +45,24 @@ CREATE TABLE `t_api_interface_custom` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api自定义信息表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api自定义信息表';
#api api文件表
DROP TABLE IF EXISTS `t_api_interface_file`;
CREATE TABLE `t_api_interface_file` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'api文件表自增ID',
`api_interface_id` bigint(20) NOT NULL COMMENT 'api表自增id',
`api_key` varchar(200) NOT NULL COMMENT 'api唯一标识',
`file_type` varchar(50) DEFAULT NULL COMMENT '文件类型',
`file_name` varchar(50) DEFAULT NULL COMMENT '文件名称',
`file_en_name` varchar(50) DEFAULT NULL COMMENT '文件英文名称',
`status` varchar(50) DEFAULT NULL COMMENT 'VALID 有效,UNVALID 无效',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
`update_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`update_user` varchar(100) DEFAULT NULL COMMENT '更新人',
`is_deleted` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api文件表';
#api组织信息表 #api组织信息表
DROP TABLE IF EXISTS `t_api_org`; DROP TABLE IF EXISTS `t_api_org`;
......
package com.jz.dm.common.enums;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums
* @PROJECT_NAME: jz-dm-parent
* @NAME: GeneralStatusTypeEnum
* @DATE: 2020-12-30/20:08
* @DAY_NAME_SHORT: 周三
* @Description: 通用状态枚举
**/
public enum GeneralStatusTypeEnum {
/**
* 启用
*/
ENABLE("启用"),
/**
* 停用
*/
UNABLE("停用"),
/**
* 有效'
*/
VALID("有效"),
/**
* 无效
*/
UN_VALID("无效");
private String text;
GeneralStatusTypeEnum(String text) {
this.text = text;
}
public String getText() {
return text;
}
}
...@@ -28,6 +28,18 @@ public class ProducerController { ...@@ -28,6 +28,18 @@ public class ProducerController {
@Autowired @Autowired
private ProducerService producerService; private ProducerService producerService;
/**
* @Description:Api制作(自定义)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(获取文件夹列表)")
@GetMapping(value = "/getFileCatalog")
public Mono<Result> getFileCatalog(@RequestParam(name = "pageNum",defaultValue = "1",required = false)String pageNum,
@RequestParam(name = "pageSize",defaultValue = "10",required = false)String pageSize) {
return Mono.fromSupplier(() -> Result.of_success(producerService.getFileCatalog(pageNum,pageSize)));
}
/** /**
* @Description:Api制作(自定义) * @Description:Api制作(自定义)
* @Author: Mr.zhang * @Author: Mr.zhang
......
package com.jz.dm.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.dm.models.domian.ApiInterfaceFile;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.mapper
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceFileMapper
* @DATE: 2020-12-30/20:34
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public interface ApiInterfaceFileMapper extends BaseMapper<ApiInterfaceFile> {
}
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_interface_file")
public class ApiInterfaceFile extends BaseObject implements Serializable {
/**
* api唯一标识
*/
@TableField("api_key")
private String apiKey;
/**
* apiInterfaceId
*/
@TableField("api_interface_id")
private Long apiInterfaceId;
/**
* 文件类型
*/
@TableField("file_type")
private String apiType;
/**
* 文件名称
*/
@TableField("file_name")
private String fileName;
/**
* 文件英文名称
*/
@TableField("file_en_name")
private String fileEnName;
/**
* 'VALID 有效,UNVALID 无效'
*/
@TableField("status")
private String status;
}
package com.jz.dm.service; package com.jz.dm.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.req.make.*; import com.jz.dm.models.req.make.*;
/** /**
...@@ -86,4 +88,12 @@ public interface ProducerService { ...@@ -86,4 +88,12 @@ public interface ProducerService {
* @return * @return
*/ */
Result saveInterfaceAPi(ApiInterfaceReq req); Result saveInterfaceAPi(ApiInterfaceReq req);
/**
* 获取文件列表
* @param pageNum
* @param pageSize
* @return
*/
IPage<ApiInterfaceFile> getFileCatalog( String pageNum, String pageSize);
} }
...@@ -3,6 +3,8 @@ package com.jz.dm.service.impl; ...@@ -3,6 +3,8 @@ package com.jz.dm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jz.common.bean.SysUserDto;
import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.constant.ResultMsg; import com.jz.common.constant.ResultMsg;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.common.constant.Constants; import com.jz.dm.common.constant.Constants;
...@@ -74,10 +76,10 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -74,10 +76,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/ */
@Override @Override
public Result add(OrganizationManageAddReq req) { public Result add(OrganizationManageAddReq req) {
//SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS); SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
//if (null == currentUser){ if (null == currentUser){
// return Result.of_error(ResultMsg.USER_NOT_EXIST); return Result.of_error(ResultMsg.USER_NOT_EXIST);
//} }
if (StringUtils.isNotBlank(req.getOrgName())) { if (StringUtils.isNotBlank(req.getOrgName())) {
ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName()); ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName());
if (null != orgNameInfo) { if (null != orgNameInfo) {
...@@ -98,7 +100,7 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -98,7 +100,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
} }
apiOrg.setOrgCode(coding);//组织编码需要生成 apiOrg.setOrgCode(coding);//组织编码需要生成
apiOrg.setStatus("1");//正常 apiOrg.setStatus("1");//正常
//apiOrg.setCreateUser(currentUser.getUserName()); apiOrg.setCreateUser(currentUser.getUserName());
if (apiOrgMapper.insert(apiOrg) > 0) { if (apiOrgMapper.insert(apiOrg) > 0) {
return Result.of_success(ResultMsg.INSERT_SUCCESS); return Result.of_success(ResultMsg.INSERT_SUCCESS);
} }
...@@ -130,10 +132,10 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -130,10 +132,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/ */
@Override @Override
public Result update(OrganizationManageUpdateReq req) { public Result update(OrganizationManageUpdateReq req) {
//SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS); SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
//if (null == currentUser){ if (null == currentUser){
// return Result.of_error(ResultMsg.USER_NOT_EXIST); return Result.of_error(ResultMsg.USER_NOT_EXIST);
//} }
ApiOrg apiOrg = apiOrgMapper.selectById(req.getId()); ApiOrg apiOrg = apiOrgMapper.selectById(req.getId());
if (null == apiOrg) { if (null == apiOrg) {
return Result.of_error("组织信息不存在!"); return Result.of_error("组织信息不存在!");
...@@ -148,7 +150,7 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -148,7 +150,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
apiOrgUpdate.setId(apiOrg.getId()); apiOrgUpdate.setId(apiOrg.getId());
BeanUtils.copyProperties(req, apiOrgUpdate); BeanUtils.copyProperties(req, apiOrgUpdate);
apiOrgUpdate.setUpdateDate(new Date()); apiOrgUpdate.setUpdateDate(new Date());
//apiOrgUpdate.setUpdateUser(currentUser.getUserName()); apiOrgUpdate.setUpdateUser(currentUser.getUserName());
if (apiOrgMapper.updateById(apiOrgUpdate) > 0) { if (apiOrgMapper.updateById(apiOrgUpdate) > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS); return Result.of_success(ResultMsg.UPDATE_SUCCESS);
} }
......
...@@ -3,7 +3,9 @@ package com.jz.dm.service.impl; ...@@ -3,7 +3,9 @@ package com.jz.dm.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jz.common.bean.SysUserDto; import com.jz.common.bean.SysUserDto;
import com.jz.common.constant.ResultMsg; import com.jz.common.constant.ResultMsg;
import com.jz.common.utils.RedisUtils; import com.jz.common.utils.RedisUtils;
...@@ -54,6 +56,8 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -54,6 +56,8 @@ public class ProducerServiceImpl implements ProducerService {
private ApiOpenApiEsTagconfigMapper apiOpenApiEsTagconfigMapper; private ApiOpenApiEsTagconfigMapper apiOpenApiEsTagconfigMapper;
@Resource @Resource
private ApiInterfaceCustomMapper apiInterfaceCustomMapper; private ApiInterfaceCustomMapper apiInterfaceCustomMapper;
@Resource
private ApiInterfaceFileMapper apiInterfaceFileMapper;
@Autowired @Autowired
private RedisTemplate<String, Object> redisTemplate; private RedisTemplate<String, Object> redisTemplate;
@Autowired @Autowired
...@@ -68,6 +72,21 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -68,6 +72,21 @@ public class ProducerServiceImpl implements ProducerService {
@Value("${dmp.ignoreRedis}") @Value("${dmp.ignoreRedis}")
protected boolean ignoreRedis; protected boolean ignoreRedis;
/**
* 获取文件列表
* @param pageSize
* @param pageNum
* @return
*/
@Override
public IPage<ApiInterfaceFile> getFileCatalog(String pageNum,String pageSize) {
Integer pageN = Integer.valueOf(pageNum);
Integer pageS = Integer.valueOf(pageSize);
IPage<ApiInterfaceFile> page = new Page<>(pageN, pageS);
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.orderByDesc("create_time");
return apiInterfaceFileMapper.selectPage(page, query);
}
/** /**
* 制作自定义Api * 制作自定义Api
...@@ -251,6 +270,8 @@ public class ProducerServiceImpl implements ProducerService { ...@@ -251,6 +270,8 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(ResultMsg.INSERT_SUCCESS); return Result.of_success(ResultMsg.INSERT_SUCCESS);
} }
/** /**
* 保存修改的api信息 * 保存修改的api信息
* *
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jz.dm.mapper.ApiInterfaceMapper"> <mapper namespace="com.jz.dm.mapper.ApiInterfaceCustomMapper">
</mapper> </mapper>
\ No newline at end of file
<?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.ApiInterfaceFileMapper">
</mapper>
\ No newline at end of file
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