Commit b5bdfe5f authored by zhangc's avatar zhangc

添加组织管理相关接口

parent 78b48b8b
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
......
...@@ -28,7 +28,7 @@ public class BaseObject implements Serializable { ...@@ -28,7 +28,7 @@ public class BaseObject implements Serializable {
*/ */
@ApiModelProperty("主健ID") @ApiModelProperty("主健ID")
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private long id; private Long id;
/** /**
* 创建日期 * 创建日期
......
package com.jz.dm.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import java.net.UnknownHostException;
@Configuration
public class RedisConfig {
@Bean
@ConditionalOnMissingBean(name = "redisTemplate")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)throws UnknownHostException {
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(redisConnectionFactory);
template.setKeySerializer(jackson2JsonRedisSerializer);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setHashKeySerializer(jackson2JsonRedisSerializer);
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
@Bean
@ConditionalOnMissingBean(StringRedisTemplate.class)
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory)throws UnknownHostException {
StringRedisTemplate template = new StringRedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
return template;
}
}
...@@ -26,7 +26,7 @@ public class SwaggerConfiguration { ...@@ -26,7 +26,7 @@ public class SwaggerConfiguration {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.select() .select()
.apis(RequestHandlerSelectors.basePackage("com.jz.dm.mall.controller")) .apis(RequestHandlerSelectors.basePackage("com.jz.dm.controller"))
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build(); .build();
} }
......
package com.jz.dm.controller; package com.jz.dm.controller;
import com.jz.common.utils.Result;
import com.jz.dm.models.req.OrganizationManageAddReq;
import com.jz.dm.models.req.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.OrganizationManageListQueryReq;
import com.jz.dm.models.req.OrganizationManageUpdateReq;
import com.jz.dm.service.OrganizationManageService; import com.jz.dm.service.OrganizationManageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import javax.validation.Valid;
/** /**
* @author ZC * @author ZC
...@@ -23,46 +34,46 @@ public class OrganizationManageController { ...@@ -23,46 +34,46 @@ public class OrganizationManageController {
@Autowired @Autowired
private OrganizationManageService organizationManageService; private OrganizationManageService organizationManageService;
///** /**
//* @Description:组织列表查询 * @Description:组织列表查询
//* @return: 组织列表 * @return: 组织列表
//* @Author: Mr.zhang * @Author: Mr.zhang
//* @Date: 2020-12-24 * @Date: 2020-12-24
//*/ */
//@ApiOperation("组织列表查询") @ApiOperation("组织列表查询")
//@PostMapping(value = "/listOrg") @PostMapping(value = "/listOrg")
//public Mono<Result> listOrganization(@RequestBody @Valid OrganizationManageListQueryReq req) { public Mono<Result> listOrganization(@RequestBody @Valid OrganizationManageListQueryReq req) {
// return Mono.fromSupplier(() -> Result.of_success(organizationManageService.listOrganization(req))); return Mono.fromSupplier(() -> Result.of_success(organizationManageService.listOrganization(req)));
//} }
///** /**
//* @Description:组织信息详情信息查询 * @Description:组织信息详情信息查询
//* @return: 组织详情 * @return: 组织详情
//* @Author: Mr.zhang * @Author: Mr.zhang
//* @Date: 2020-12-24 * @Date: 2020-12-24
//*/ */
//@ApiOperation("组织详情查询") @ApiOperation("组织详情查询")
//@PostMapping(value = "/getOrgDetail") @PostMapping(value = "/getOrgDetail")
//public Mono<Result> getOrganizationDetail(@RequestBody @Valid OrganizationManageDetailQueryReq req) { public Mono<Result> getOrganizationDetail(@RequestBody @Valid OrganizationManageDetailQueryReq req) {
// return Mono.fromSupplier(() -> Result.of_success(organizationManageService.getOrganizationDetail(req))); return Mono.fromSupplier(() -> organizationManageService.getOrganizationDetail(req));
//} }
///** /**
// * @Description:添加组织信息 * @Description:添加组织信息
// * @Author: Mr.zhang * @Author: Mr.zhang
// * @Date: 2020-12-24 * @Date: 2020-12-24
// */ */
//@ApiOperation("添加组织") @ApiOperation("添加组织")
//@PostMapping(value = "/add") @PostMapping(value = "/add")
//public Mono<Result> add(@RequestBody @Valid OrganizationManageAddReq req) { public Mono<Result> add(@RequestBody @Valid OrganizationManageAddReq req) {
// return Mono.fromSupplier(() -> Result.of_success(organizationManageService.add(req))); return Mono.fromSupplier(() -> organizationManageService.add(req));
//} }
///** /**
// * @Description:更新组织信息 * @Description:更新组织信息
// * @Author: Mr.zhang * @Author: Mr.zhang
// * @Date: 2020-12-24 * @Date: 2020-12-24
// */ */
//@ApiOperation("更新组织信息") @ApiOperation("更新组织信息")
//@PostMapping(value = "/update") @PostMapping(value = "/update")
//public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) { public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) {
// return Mono.fromSupplier(() -> Result.of_success(organizationManageService.update(req))); return Mono.fromSupplier(() -> organizationManageService.update(req));
//} }
} }
...@@ -70,4 +70,5 @@ public class ApiOrg extends BaseObject implements Serializable { ...@@ -70,4 +70,5 @@ public class ApiOrg extends BaseObject implements Serializable {
@TableField("parent_id") @TableField("parent_id")
private String parentId; private String parentId;
} }
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.dm.models.domian.ApiOrg;
import com.jz.dm.models.req.OrganizationManageAddReq;
import com.jz.dm.models.req.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.OrganizationManageListQueryReq;
import com.jz.dm.models.req.OrganizationManageUpdateReq;
/** /**
* @author ZC * @author ZC
* @PACKAGE_NAME: com.jz.dm.service * @PACKAGE_NAME: com.jz.dm.service
...@@ -10,31 +18,31 @@ package com.jz.dm.service; ...@@ -10,31 +18,31 @@ package com.jz.dm.service;
* @Description: * @Description:
**/ **/
public interface OrganizationManageService { public interface OrganizationManageService {
///** /**
// * 分页查询组织列表信息 * 分页查询组织列表信息
// * @param req * @param req
// * @return * @return
// */ */
//IPage<ApiOrg> listOrganization(OrganizationManageListQueryReq req); IPage<ApiOrg> listOrganization(OrganizationManageListQueryReq req);
//
///** /**
// * 查询组织详情信息 * 查询组织详情信息
// * @param req * @param req
// * @return * @return
// */ */
//Result getOrganizationDetail(OrganizationManageDetailQueryReq req); Result getOrganizationDetail(OrganizationManageDetailQueryReq req);
//
///** /**
// * 添加组织 * 添加组织
// * @param req * @param req
// * @return * @return
// */ */
//Result add(OrganizationManageAddReq req); Result add(OrganizationManageAddReq req);
//
///** /**
// * 更新组织信息 * 更新组织信息
// * @param req * @param req
// * @return * @return
// */ */
//Result update(OrganizationManageUpdateReq req); Result update(OrganizationManageUpdateReq req);
} }
...@@ -13,7 +13,9 @@ import com.jz.dm.models.req.OrganizationManageListQueryReq; ...@@ -13,7 +13,9 @@ import com.jz.dm.models.req.OrganizationManageListQueryReq;
import com.jz.dm.models.req.OrganizationManageUpdateReq; import com.jz.dm.models.req.OrganizationManageUpdateReq;
import com.jz.dm.service.OrganizationManageService; import com.jz.dm.service.OrganizationManageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -34,75 +36,105 @@ public class OrganizationManageImpl implements OrganizationManageService { ...@@ -34,75 +36,105 @@ public class OrganizationManageImpl implements OrganizationManageService {
@Resource @Resource
private ApiOrgMapper apiOrgMapper; private ApiOrgMapper apiOrgMapper;
//@Resource @Resource
//private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
///** /**
// * 组织列表信息查询 * 组织列表信息查询
// * @param req * @param req
// * @return * @return
// */ */
//@Override @Override
//public IPage<ApiOrg> listOrganization(OrganizationManageListQueryReq req) { public IPage<ApiOrg> listOrganization(OrganizationManageListQueryReq req) {
// IPage<ApiOrg> page = new Page<>(req.getPageNum(), req.getPageSize()); IPage<ApiOrg> page = new Page<>(req.getPageNum(), req.getPageSize());
// QueryWrapper<ApiOrg> query = new QueryWrapper<>(); QueryWrapper<ApiOrg> query = new QueryWrapper<>();
// query.orderByDesc("create_time"); query.orderByDesc("create_date");
// return apiOrgMapper.selectPage(page,query); return apiOrgMapper.selectPage(page,query);
//} }
//
///** /**
// * 获取组织详情 * 获取组织详情
// * @param req * @param req
// * @return * @return
// */ */
//@Override @Override
//public Result getOrganizationDetail(OrganizationManageDetailQueryReq req) { public Result getOrganizationDetail(OrganizationManageDetailQueryReq req) {
// return Result.of_success(apiOrgMapper.selectById(req.getId())); return Result.of_success(apiOrgMapper.selectById(req.getId()));
//} }
//
///** /**
// * 添加组织 * 添加组织
// * @param req * @param req
// * @return * @return
// */ */
//@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);
// //}
// ApiOrg apiOrg = new ApiOrg();
// BeanUtils.copyProperties(req,apiOrg);
// apiOrg.setOrgCode("1111");//组织编码需要生成
// //apiOrg.setCreateUser(currentUser.getUserName());
// if (apiOrgMapper.insert(apiOrg) > 0){
// return Result.of_success(ResultMsg.INSERT_SUCCESS);
// }
// return Result.of_error(ResultMsg.INSERT_FAIL);
//} //}
// if (StringUtils.isNotBlank(req.getOrgName())){
///** ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName());
// * 更新组织 if (null != orgNameInfo){
// * @param req return Result.of_error("组织名称已存在");
// * @return }
// */ }
//@Override ApiOrg apiOrg = new ApiOrg();
//public Result update(OrganizationManageUpdateReq req) { BeanUtils.copyProperties(req,apiOrg);
// //SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS); apiOrg.setOrgCode("111eef33");//组织编码需要生成
// //if (null == currentUser){ apiOrg.setStatus("1");//正常
// // return Result.of_error(ResultMsg.USER_NOT_EXIST); //apiOrg.setCreateUser(currentUser.getUserName());
// //} if (apiOrgMapper.insert(apiOrg) > 0){
// ApiOrg apiOrg = apiOrgMapper.selectById(req.getId()); return Result.of_success(ResultMsg.INSERT_SUCCESS);
// if (null == apiOrg){ }
// return Result.of_error("组织信息不存在!"); return Result.of_error(ResultMsg.INSERT_FAIL);
// } }
// ApiOrg apiOrgUpdate = new ApiOrg();
// apiOrgUpdate.setId(apiOrg.getId()); /**
// BeanUtils.copyProperties(req,apiOrgUpdate); * 更新组织
// apiOrgUpdate.setUpdateDate(new Date()); * @param req
// //apiOrgUpdate.setUpdateUser(currentUser.getUserName()); * @return
// if (apiOrgMapper.updateById(apiOrgUpdate) > 0){ */
// return Result.of_success(ResultMsg.UPDATE_SUCCESS); @Override
// } public Result update(OrganizationManageUpdateReq req) {
// return Result.of_success(ResultMsg.UPDATE_FAIL); //SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
//if (null == currentUser){
// return Result.of_error(ResultMsg.USER_NOT_EXIST);
//} //}
ApiOrg apiOrg = apiOrgMapper.selectById(req.getId());
if (null == apiOrg){
return Result.of_error("组织信息不存在!");
}
if (StringUtils.isNotBlank(req.getOrgName())){
ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName());
if (null != orgNameInfo){
return Result.of_error("组织名称已存在");
}
}
ApiOrg apiOrgUpdate = new ApiOrg();
apiOrgUpdate.setId(apiOrg.getId());
BeanUtils.copyProperties(req,apiOrgUpdate);
apiOrgUpdate.setUpdateDate(new Date());
//apiOrgUpdate.setUpdateUser(currentUser.getUserName());
if (apiOrgMapper.updateById(apiOrgUpdate) > 0){
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_success(ResultMsg.UPDATE_FAIL);
}
/**
* 根据名称获取组织信息
* @param orgName 组织名称
* @return
*/
private ApiOrg getOrgNameInfo(String orgName){
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
query.eq("org_name",orgName);
query.eq("is_deleted",0);
query.eq("status","3");
ApiOrg apiOrg = apiOrgMapper.selectOne(query);
if (null != apiOrg){
return apiOrg;
}
return null;
}
} }
...@@ -5,8 +5,8 @@ spring: ...@@ -5,8 +5,8 @@ spring:
enabled: false enabled: false
datasource: datasource:
url: jdbc:mysql://119.23.32.151:3306/api_gateway?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false url: jdbc:mysql://119.23.32.151:3306/api_gateway?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
username: root username: dmp
password: I%ou$buy!ok password: Ioubuy@2019@!
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
druid: druid:
# 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时 # 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
...@@ -54,8 +54,9 @@ spring: ...@@ -54,8 +54,9 @@ spring:
public-key: rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq public-key: rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq
redis: redis:
#database: 0 #database: 0
host: 192.168.1.139 host: 47.115.53.1
port: 6379 port: 6379
password: 123456
#timeout: 5000 #timeout: 5000
# cluster: # cluster:
# nodes: # nodes:
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
......
...@@ -109,19 +109,32 @@ public class Result<T> implements Serializable { ...@@ -109,19 +109,32 @@ public class Result<T> implements Serializable {
public Result() { public Result() {
this.code = ResultCode.SUCCESS.getCode(); this.code = ResultCode.SUCCESS.getCode();
} }
public static Result of_success(ResultMsg msg,Object data) { public static Result of_success() {
Result resultJson = new Result(ResultCode.SUCCESS.getCode(),data,msg); Result resultJson = new Result(ResultCode.SUCCESS.getCode());
resultJson.setMsg(ResultMsg.SUCCESS);
return resultJson; return resultJson;
} }
public static Result of_success(Object data) { public static Result of_success(Object data) {
Result resultJson = new Result(ResultCode.SUCCESS.getCode(),data); Result resultJson = new Result(ResultCode.SUCCESS.getCode(),data);
resultJson.setMessage(ResultMsg.SUCCESS.getMsg()); resultJson.setMsg(ResultMsg.SUCCESS);
return resultJson; return resultJson;
} }
public static Result of_success(ResultMsg msg,Object data) {
Result resultJson = new Result(ResultCode.SUCCESS.getCode(),data,msg);
return resultJson;
}
public static Result of_success(ResultMsg msg) { public static Result of_success(ResultMsg msg) {
Result resultJson = new Result(ResultCode.SUCCESS.getCode(),null,msg); Result resultJson = new Result(ResultCode.SUCCESS.getCode(),null,msg);
return resultJson; return resultJson;
} }
public static Result of_success(String msg) {
Result resultJson = new Result(ResultCode.SUCCESS.getCode(),null,msg);
return resultJson;
}
public static Result of_error(ResultMsg msg) { public static Result of_error(ResultMsg msg) {
Result resultJson = new Result(ResultCode.FAILURE.getCode(),null,msg); Result resultJson = new Result(ResultCode.FAILURE.getCode(),null,msg);
return resultJson; return resultJson;
......
...@@ -44,18 +44,19 @@ spring: ...@@ -44,18 +44,19 @@ spring:
spec: maximumSize=1000,expireAfterWrite=30s spec: maximumSize=1000,expireAfterWrite=30s
public-key: rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq public-key: rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq
redis: redis:
#database: 0 # database: 0
#host: 119.23.13.83 host: 47.115.53.1
#port: 8007 port: 6379
#timeout: 5000 password: 123456
cluster: # timeout: 5000
nodes: # cluster:
- 192.168.31.167:6379 # nodes:
- 192.168.31.167:6380 # - 192.168.31.167:6379
- 192.168.31.167:6381 # - 192.168.31.167:6380
- 192.168.31.167:6382 # - 192.168.31.167:6381
- 192.168.31.167:6383 # - 192.168.31.167:6382
- 192.168.31.167:6384 # - 192.168.31.167:6383
# - 192.168.31.167:6384
#mybatis的配置 #mybatis的配置
mybatis: mybatis:
......
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