Commit 9179df67 by renrui

[add]fegin直接调用

1 parent c456888d
......@@ -21,6 +21,17 @@
<groupId>com.github.davidfantasy</groupId>
<artifactId>mybatis-plus-generator-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.arch</groupId>
<artifactId>office</artifactId>
......
......@@ -3,12 +3,14 @@ package org.arch.overall;
import org.dromara.x.file.storage.spring.EnableFileStorage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.jmx.support.RegistrationPolicy;
@SpringBootApplication
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
@EnableFileStorage
@EnableFeignClients
public class AssetApp {
public static void main(String[] args) {
SpringApplication.run(AssetApp.class, args);
......
package org.arch.overall.config;
import feign.Logger;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FeignConfiguration {
@Bean
public Logger.Level level() {
return Logger.Level.BASIC;
}
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}
\ No newline at end of file
package org.arch.overall.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.arch.base.Result;
import org.arch.common.modules.archsystem.dto.PrjInfoDTO;
import org.arch.common.modules.sysmange.entity.Org;
import org.arch.log.annotation.OperLog;
import org.arch.log.logenum.LogOperTypeEnum;
import org.arch.log.logenum.LogTypeEnum;
import org.arch.overall.service.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author audit
* @since 2020-08-21
*/
@RestController
@RequestMapping("/org")
@Api(tags = "系统功能")
@Log
public class OrgController {
@Autowired
private OrgService orgService;
@PostMapping(value = "/getOrgOption")
@ApiOperation(value = "获取组织下拉", notes = "获取组织下拉")
//@AutoLog(value = LogEventTypeEnum.SEARCH, LogTypeValue = LogTypeEnum.BUSI_LOG, LogLevValue = LogLevEnum.LOW, description = "获取组织下拉")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取组织下拉", moduleName = "获取组织信息")
public Result<List<Org>> getOrgOption() {
return orgService.getOrgOption();
}
@PostMapping(value = "/getDeptOption")
@ApiOperation(value = "获取部门下拉", notes = "获取部门下拉")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取组织下拉", moduleName = "获取组织信息")
//@AutoLog(value = LogEventTypeEnum.SEARCH, LogTypeValue = LogTypeEnum.BUSI_LOG, LogLevValue = LogLevEnum.LOW, description = "获取部门下拉")
public Result<List<Org>> getDeptOption() {
return orgService.getDeptOption();
}
@PostMapping(value = "/selectById")
@ApiOperation(value = "获取部门下拉", notes = "获取部门下拉")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取组织下拉", moduleName = "获取组织信息")
//@AutoLog(value = LogEventTypeEnum.SEARCH, LogTypeValue = LogTypeEnum.BUSI_LOG, LogLevValue = LogLevEnum.LOW, description = "获取部门下拉")
public Org selectById(@RequestBody PrjInfoDTO dto) {
return orgService.selectById(dto.getPrjId());
}
}
package org.arch.overall.fegin;
import org.arch.base.Result;
import org.arch.common.modules.sysmange.entity.Org;
import org.arch.overall.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "framework-system-manage", configuration = FeignConfiguration.class)
public interface SystemManageClient {
@PostMapping(value = "org/getOrgOption")
Result<List<Org>> getDocContent();
@PostMapping(value = "org/getDeptOption")
Result<List<Org>> getDeptOption();
@PostMapping(value = "org/selectById")
Org selectById(@RequestParam("manageOrgId")Long manageOrgId);
}
package org.arch.overall.mapper;
package org.arch.overall.service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.arch.common.modules.archsystem.dto.OrgDTO;
import org.arch.common.modules.archsystem.vo.CockpitOrgVO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.arch.base.Result;
import org.arch.common.modules.sysmange.entity.Org;
import java.util.List;
/**
* <p>
* Mapper 接口
* 服务类
* </p>
*
* @author audit
* @since 2020-08-21
*/
public interface OrgMapper extends BaseMapper<Org> {
/**
* 查询组织机构列表
*
* @param objectPage 对象页面
* @param params 查询包装器
* @return {@link Page}<{@link Org}>
*/
Page<Org> selectForPage(Page<Object> objectPage, @Param("params") OrgDTO params);
public interface OrgService{
/**
* 获取组织机构下拉框
*
* @return List<Org>
*/
List<Org> getOrgOption();
Result<List<Org>> getOrgOption();
/**
* 获取部门下拉框
* 获取组织机构下拉框
*
* @return List<Org>
*/
List<Org> getDeptOption();
Result<List<Org>> getDeptOption();
/**
* 查询组织列表
*
* @return {@link List }<{@link Org }>
*/
List<CockpitOrgVO> queryOrgList();
Org selectById(Long manageOrgId);
}
package org.arch.overall.service.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.arch.base.Result;
import org.arch.common.modules.sysmange.entity.Org;
import org.arch.overall.fegin.SystemManageClient;
import org.arch.overall.service.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author audit
* @since 2020-08-21
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class OrgServiceImpl implements OrgService {
@Autowired
private SystemManageClient manageClient;
@Override
public Result<List<Org>> getOrgOption() {
return manageClient.getDocContent();
}
@Override
public Result<List<Org>> getDeptOption() {
return manageClient.getDeptOption();
}
@Override
public Org selectById(Long manageOrgId) {
return manageClient.selectById(manageOrgId);
}
}
......@@ -18,12 +18,13 @@ import org.arch.common.modules.archsystem.eneiity.AppInfo;
import org.arch.common.modules.archsystem.eneiity.PrjInfo;
import org.arch.common.modules.archsystem.eneiity.PrjNeedFile;
import org.arch.common.modules.sysmange.entity.Org;
import org.arch.overall.fegin.SystemManageClient;
import org.arch.overall.mapper.AppInfoMapper;
import org.arch.overall.mapper.OrgMapper;
import org.arch.overall.mapper.PrjInfoMapper;
import org.arch.overall.mapper.PrjNeedFileMapper;
import org.arch.overall.service.PrjInfoService;
import org.arch.overall.service.PrjNeedFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -49,7 +50,8 @@ public class PrjInfoServiceImpl extends ServiceImpl<PrjInfoMapper, PrjInfo> impl
private final AppInfoMapper appInfoMapper;
private final OrgMapper orgMapper;
@Autowired
private SystemManageClient manageClient;
@Override
public IPage<PrjInfo> iPage(PrjInfoDTO params, Page<PrjInfo> page) {
......@@ -71,7 +73,8 @@ public class PrjInfoServiceImpl extends ServiceImpl<PrjInfoMapper, PrjInfo> impl
BeanUtil.copyProperties(params, model);
model.setPrjCode(IdUtil.fastUUID());
model.setProjectManager(appInfo.getProjectManager());
Org org = orgMapper.selectById(params.getManageOrgId());
Org org = manageClient.selectById(params.getManageOrgId());
// Org org = null;
Assert.notNull(org, "建管单位不存在");
model.setManageOrgCode(org.getOrgCode());
boolean save = save(model);
......@@ -99,7 +102,8 @@ public class PrjInfoServiceImpl extends ServiceImpl<PrjInfoMapper, PrjInfo> impl
prjNeedFileService.insertPrjNeedFile(params.getFilesValue(), prjId, null);
BeanUtil.copyProperties(params, model);
Org org = orgMapper.selectById(params.getManageOrgId());
Org org = manageClient.selectById(params.getManageOrgId());
//Org org = null;
Assert.notNull(org, "建管单位不存在");
model.setManageOrgCode(org.getOrgCode());
model.setProjectManager(appInfo.getProjectManager());
......
......@@ -76,7 +76,7 @@
<!-- 本地环境 -->
<springProfile name="local">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
......@@ -85,7 +85,7 @@
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,sit,uat,default">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
......
......@@ -226,7 +226,6 @@ public class OrgController extends MenuController.BaseController {
@ApiImplicitParam(name = "id", value = "部门id", required = true, dataType = "Long", paramType = "path")
@ApiOperation(value = "获取本部下部门的处室", notes = "获取本部下部门的处室")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "系统功能-获取本部下部门的处室", moduleName = "系统功能")
//public Result<List<Org>> getdepttmentList(Long id) {
public Result<List<Org>> getdepttmentList(@RequestBody Long id) {
QueryWrapper wrapper = new QueryWrapper();
......@@ -234,4 +233,28 @@ public class OrgController extends MenuController.BaseController {
List<Org> orgs = orgService.getBaseMapper().selectList(wrapper);
return Result.success(orgs);
}
@PostMapping(value = "/getOrgOption")
@ApiOperation(value = "获取组织下拉", notes = "获取组织下拉")
//@AutoLog(value = LogEventTypeEnum.SEARCH, LogTypeValue = LogTypeEnum.BUSI_LOG, LogLevValue = LogLevEnum.LOW, description = "获取组织下拉")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取组织下拉", moduleName = "系统功能")
public Result<List<Org>> getOrgOption() {
return Result.success(orgService.getOrgOption());
}
@PostMapping(value = "/getDeptOption")
@ApiOperation(value = "获取部门下拉", notes = "获取部门下拉")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "获取组织下拉", moduleName = "获取部门下拉")
//@AutoLog(value = LogEventTypeEnum.SEARCH, LogTypeValue = LogTypeEnum.BUSI_LOG, LogLevValue = LogLevEnum.LOW, description = "获取部门下拉")
public Result<List<Org>> getDeptOption() {
return Result.success(orgService.getDeptOption());
}
@PostMapping(value = "/selectById")
@ApiOperation(value = "根据id查询部门", notes = "根据id查询部门")
@OperLog(value = LogOperTypeEnum.QUERY, logTypeValue = LogTypeEnum.BUSI_LOG, operDes = "根据id查询部门", moduleName = "获取组织信息")
public Org selectById(@RequestParam("manageOrgId") Long manageOrgId) {
return orgService.selectById(manageOrgId);
}
}
......@@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.arch.common.modules.sysmange.entity.Org;
import java.util.List;
/**
* <p>
* Mapper 接口
......@@ -23,4 +25,18 @@ public interface OrgMapper extends BaseMapper<Org> {
@Select("select a.*, b.name as createManName from sys_org a left join sys_user b on a.create_man = b.id " +
"${ew.customSqlSegment}")
Page<Org> selectForPage(Page<Object> objectPage, @Param(Constants.WRAPPER) QueryWrapper<Org> queryWrapper);
/**
* 获取组织机构下拉框
*
* @return List<Org>
*/
List<Org> getOrgOption();
/**
* 获取部门下拉框
*
* @return List<Org>
*/
List<Org> getDeptOption();
}
......@@ -25,4 +25,20 @@ public interface OrgService extends IService<Org> {
Page<Org> selectForPage(Page<Object> objectPage, QueryWrapper<Org> queryWrapper);
List<Org> getSelect();
/**
* 获取组织机构下拉框
*
* @return List<Org>
*/
List<Org> getOrgOption();
/**
* 获取组织机构下拉框
*
* @return List<Org>
*/
List<Org> getDeptOption();
Org selectById(Long manageOrgId);
}
......@@ -149,6 +149,21 @@ public class OrgServiceImpl extends ServiceImpl<OrgMapper, Org> implements OrgSe
return orgs;
}
@Override
public List<Org> getOrgOption() {
return baseMapper.getOrgOption();
}
@Override
public List<Org> getDeptOption() {
return baseMapper.getDeptOption();
}
@Override
public Org selectById(Long manageOrgId) {
return baseMapper.selectById(manageOrgId);
}
private void createTreeData(Org parent, List<Org> officeList) {
if (officeList == null) return;
Iterator<Org> iterator = officeList.iterator();
......
......@@ -76,7 +76,7 @@
<!-- 本地环境 -->
<springProfile name="local">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
......@@ -85,7 +85,7 @@
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,sit,uat,default">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_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="org.arch.overall.mapper.OrgMapper">
<mapper namespace="org.arch.manage.mapper.OrgMapper">
<resultMap id="BaseResultMap" type="org.arch.common.modules.sysmange.entity.Org">
<!--@mbg.generated-->
<!--@Table sys_org-->
......
......@@ -81,6 +81,7 @@
<httpclient.version>3.1</httpclient.version>
<configuration.version>1.10</configuration.version>
<mybatisPlus.version>1.4.11</mybatisPlus.version>
<openFeign.version>3.1.5</openFeign.version>
</properties>
<dependencyManagement>
<dependencies>
......@@ -111,6 +112,19 @@
<version>${xmlpull.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>${openFeign.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>${openFeign.version}</version>
</dependency>
<!--jwt-->
<dependency>
<groupId>com.auth0</groupId>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!