Commit b5bdfe5f authored by zhangc's avatar zhangc

添加组织管理相关接口

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