修改用户服务为单数据源模式,新增机构管理功能

This commit is contained in:
lhc
2021-03-19 10:50:21 +08:00
parent 0a1414e829
commit 105f43472f
7 changed files with 153 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
package com.hcframe.user;
import com.hcframe.base.module.datasource.config.DataSourceConfiguration;
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
import net.unicon.cas.client.configuration.EnableCasClient;
import org.springframework.boot.SpringApplication;
@@ -10,17 +11,19 @@ import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import tk.mybatis.spring.annotation.MapperScan;
import java.net.URLEncoder;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@SpringBootApplication()
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableSwagger2
@ServletComponentScan
@EnableCaching
@ComponentScan(basePackages = {"com.hcframe.**"})
@MapperScan(basePackages = "com.hcframe.**.dao")
@ComponentScan(basePackages = {"com.hcframe.**"},excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DataSourceConfiguration.class}))
@EnableDiscoveryClient
@Import(CasClientConfigurationProperties.class)
//@EnableCasClient

View File

@@ -26,7 +26,7 @@ public class CommandLineRunnerImpl implements CommandLineRunner {
@Override
public void run(String... args) {
DataSourceUtil.initDataSource();
// DataSourceUtil.initDataSource();
// 初始化缓存
// for (CacheService cacheService : cacheServices) {
// cacheService.initTableCache();

View File

@@ -66,6 +66,6 @@ public class CasController {
String headerToken = request.getHeader("X-Access-Token");
redisUtil.hdel("session", token);
redisUtil.hdel("session", headerToken);
return ResultVO.getSuccess(casClientConfigurationProperties.getServerUrlPrefix()+"/cas/logout");
return ResultVO.getSuccess(casClientConfigurationProperties.getServerUrlPrefix()+"/logout");
}
}

View File

@@ -0,0 +1,53 @@
package com.hcframe.user.module.userinfo.controller;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.user.module.userinfo.service.OrgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author lhc
*/
@RestController
@RequestMapping("org")
@Api(tags = "机构管理")
public class OrgController {
final OrgService orgService;
public OrgController(OrgService orgService) {
this.orgService = orgService;
}
@PostMapping()
@ApiOperation(value = "新增org", notes = "将自动传承key-value对象模式即可")
public ResultVO<Object> addOrg(@RequestParam Map<String,Object> org) {
return orgService.addOrg(org);
}
@PutMapping("/{version}")
@ApiOperation(value = "更新org")
public ResultVO<Integer> updateOrg(@RequestParam Map<String,Object> org,@PathVariable Integer version) {
return orgService.updateOrg(org,version);
}
@DeleteMapping("/{ids}")
@ApiOperation(value = "删除org", notes = "删除后职位也会被删除")
public ResultVO<Object> deleteOrg(@PathVariable String ids) {
return orgService.deleteOrg(ids);
}
@GetMapping()
@ApiOperation(value = "获取职位列表", notes = "删除后职位也会被删除")
public ResultVO<PageInfo<Map<String,Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
return orgService.getOrgList(data, webPageInfo);
}
}

View File

@@ -0,0 +1,17 @@
package com.hcframe.user.module.userinfo.service;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import java.util.Map;
public interface OrgService {
ResultVO<Object> addOrg(Map<String, Object> org);
ResultVO<Integer> updateOrg(Map<String, Object> org, Integer version);
ResultVO<Object> deleteOrg(String ids);
ResultVO<PageInfo<Map<String, Object>>> getOrgList(String data, WebPageInfo webPageInfo);
}

View File

@@ -0,0 +1,70 @@
package com.hcframe.user.module.userinfo.service.impl;
import com.github.pagehelper.PageInfo;
import com.hcframe.base.common.ResultVO;
import com.hcframe.base.common.WebPageInfo;
import com.hcframe.base.module.data.module.BaseMapper;
import com.hcframe.base.module.data.module.BaseMapperImpl;
import com.hcframe.base.module.data.module.Condition;
import com.hcframe.base.module.data.service.TableService;
import com.hcframe.base.module.tableconfig.entity.OsSysTable;
import com.hcframe.user.module.userinfo.service.OrgService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Map;
/**
* @author lhc
*/
@Service
public class OrgServiceImpl implements OrgService {
private static final String ORG_ID = "ORG_ID";
private static final String OS_SYS_ORG = "OS_SYS_ORG";
private static final String OS_SYS_POSITION = "OS_SYS_POSITION";
private static final OsSysTable TABLE_INFO = OsSysTable.builder().tableName(OS_SYS_ORG).tablePk(ORG_ID).build();
final BaseMapper baseMapper;
final TableService tableService;
public OrgServiceImpl(@Qualifier(BaseMapperImpl.BASE) BaseMapper baseMapper,
TableService tableService) {
this.baseMapper = baseMapper;
this.tableService = tableService;
}
@Override
public ResultVO<Object> addOrg(Map<String, Object> org) {
baseMapper.save(OS_SYS_ORG,ORG_ID,org);
return ResultVO.getSuccess();
}
@Override
public ResultVO<Integer> updateOrg(Map<String, Object> org, Integer version) {
return tableService.updateWithDate(TABLE_INFO,org,version);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultVO<Object> deleteOrg(String ids) {
String[] idArr = ids.split(",");
Condition condition = Condition
.creatCriteria()
.andIn(ORG_ID,Arrays.asList(idArr))
.build();
baseMapper.deleteByCondition(OS_SYS_POSITION,condition);
tableService.delete(TABLE_INFO, ids);
return ResultVO.getSuccess();
}
@Override
public ResultVO<PageInfo<Map<String, Object>>> getOrgList(String data, WebPageInfo webPageInfo) {
PageInfo<Map<String,Object>> pageInfo = tableService.searchSingleTables(data, TABLE_INFO, webPageInfo);
return ResultVO.getSuccess(pageInfo);
}
}

View File

@@ -51,10 +51,10 @@ spring:
datasource:
druid:
# 配置sqlite文件路径需要填写绝对路径推荐将sqlite文件放入到服务器上而非程序jar包或war包中
driver-class-name: org.sqlite.JDBC
url: jdbc:sqlite:/Volumes/DATA/ideaProject/user/src/main/resources/datasource.db
username:
password:
driver-class-name: dm.jdbc.driver.DmDriver
url: jdbc:dm://192.168.1.131:5236/GBCAS?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
username: GBCAS
password: 123456789
#使用Druid数据源
initialSize: 5
# 初始化大小,最小,最大
@@ -96,7 +96,7 @@ hcframe:
# swagger配置
swagger:
# 配置controller包路径
path: com.hcframe.module.**.controller
# path: com.hcframe.module.**.controller
# 是否开启权限
enableAuth: false
# 用户名