Commit 815d8755 by wangnb

账户体系角色管理接口--think.wang

1 parent 412062d2
...@@ -32,5 +32,10 @@ ...@@ -32,5 +32,10 @@
<artifactId>rest-admin-common</artifactId> <artifactId>rest-admin-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-spring-boot-starter</artifactId>
<version>6.5.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -3,10 +3,9 @@ package cn.com.glsx.merchants.controller; ...@@ -3,10 +3,9 @@ package cn.com.glsx.merchants.controller;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse; import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse; import cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse;
import cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest; import cn.com.glsx.merchants.request.accounttype.*;
import cn.com.glsx.merchants.request.accounttype.AccountTypeListSearchRequest;
import cn.com.glsx.merchants.request.accounttype.AccountTypeSearchRequest;
import cn.com.glsx.merchants.service.MerchantAccountTypeService; import cn.com.glsx.merchants.service.MerchantAccountTypeService;
import cn.com.glsx.merchants.service.MerchantUserService;
import cn.com.glsx.merchants.util.Pagination; import cn.com.glsx.merchants.util.Pagination;
import com.rop.annotation.NeedInSessionType; import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod; import com.rop.annotation.ServiceMethod;
...@@ -32,6 +31,9 @@ public class MerchantAccountTypeController { ...@@ -32,6 +31,9 @@ public class MerchantAccountTypeController {
@Autowired @Autowired
private MerchantAccountTypeService accountTypeService; private MerchantAccountTypeService accountTypeService;
@Autowired
private MerchantUserService merchantUserService;
/** /**
* 账户类型获取列表接口 * 账户类型获取列表接口
* *
...@@ -92,6 +94,7 @@ public class MerchantAccountTypeController { ...@@ -92,6 +94,7 @@ public class MerchantAccountTypeController {
@ServiceMethod(method = "org.ore.api.accountType.deleteById", needInSession = NeedInSessionType.YES) @ServiceMethod(method = "org.ore.api.accountType.deleteById", needInSession = NeedInSessionType.YES)
@ApiOperation("根据id获取账户类型接口") @ApiOperation("根据id获取账户类型接口")
public RopResponse<Boolean> deleteById(AccountTypeDeleteRequest request) { public RopResponse<Boolean> deleteById(AccountTypeDeleteRequest request) {
merchantUserService.setUser(request);
try { try {
return RopResponse.success(accountTypeService.delete(request)); return RopResponse.success(accountTypeService.delete(request));
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
...@@ -100,4 +103,40 @@ public class MerchantAccountTypeController { ...@@ -100,4 +103,40 @@ public class MerchantAccountTypeController {
} }
} }
/**
* 账户类型新增接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.accountType.insert", needInSession = NeedInSessionType.YES)
@ApiOperation("账户类型新增接口")
public RopResponse<Boolean> insert(AccountTypeInsertRequest request) {
merchantUserService.setUser(request);
try {
return RopResponse.success(accountTypeService.insert(request));
} catch (RpcServiceException e) {
log.info("=======MerchantAccountTypeController__invoke__insert__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 账户类型更新接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.accountType.update", needInSession = NeedInSessionType.YES)
@ApiOperation("账户类型更新接口")
public RopResponse<Boolean> update(AccountTypeUpdateRequest request) {
merchantUserService.setUser(request);
try {
return RopResponse.success(accountTypeService.update(request));
} catch (RpcServiceException e) {
log.info("=======MerchantAccountTypeController__invoke__update__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
} }
package cn.com.glsx.merchants.controller; package cn.com.glsx.merchants.controller;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse; import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.request.example.LoginRequest; import cn.com.glsx.merchants.model.response.MerchantRoleResponse;
import cn.com.glsx.merchants.response.LoginResponse; import cn.com.glsx.merchants.request.accounttype.AccountTypeSearchRequest;
import cn.com.glsx.merchants.request.role.RoleDeleteRequest;
import cn.com.glsx.merchants.request.role.RoleListSearchRequest;
import cn.com.glsx.merchants.request.role.RoleInsertRequest;
import cn.com.glsx.merchants.request.role.RoleUpdateRequest;
import cn.com.glsx.merchants.service.MerchantRoleService; import cn.com.glsx.merchants.service.MerchantRoleService;
import cn.com.glsx.merchants.service.MerchantUserService;
import cn.com.glsx.merchants.util.Pagination;
import com.rop.annotation.NeedInSessionType; import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod; import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean; import com.rop.annotation.ServiceMethodBean;
...@@ -12,6 +19,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -12,6 +19,8 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/** /**
* @author zhouhaibao * @author zhouhaibao
* @version 1.0 * @version 1.0
...@@ -26,15 +35,112 @@ public class MerchantRoleController { ...@@ -26,15 +35,112 @@ public class MerchantRoleController {
@Autowired @Autowired
private MerchantRoleService roleService; private MerchantRoleService roleService;
@Autowired
private MerchantUserService merchantUserService;
/** /**
* 角色管理获取列表接口
* *
* @param request * @param request
* @return * @return
*/ */
@ServiceMethod(method = "org.ore.api.role.list", needInSession = NeedInSessionType.YES) @ServiceMethod(method = "org.ore.api.role.list", needInSession = NeedInSessionType.YES)
@ApiOperation("角色管理获取列表接口") @ApiOperation("角色管理获取列表接口")
public RopResponse<LoginResponse> getRoleList(LoginRequest request) { public RopResponse<List<MerchantRoleResponse>> getRoleList(RoleListSearchRequest request) {
return RopResponse.success(null); try {
return RopResponse.success(roleService.getRoleList(request));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__getRoleList__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 角色管理获取分页数据接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.role.page", needInSession = NeedInSessionType.YES)
@ApiOperation("角色管理获取分页数据接口")
public RopResponse<Pagination<MerchantRoleResponse>> getRolePage(RoleListSearchRequest request) {
try {
return RopResponse.success(roleService.getRolePage(request));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__getRolePage__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 根据id获取角色管理接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.role.getById", needInSession = NeedInSessionType.YES)
@ApiOperation("根据id获取角色管理接口")
public RopResponse<MerchantRoleResponse> getById(AccountTypeSearchRequest request) {
try {
return RopResponse.success(roleService.getById(request.getId()));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__getById__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 根据id获取角色管理接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.role.deleteById", needInSession = NeedInSessionType.YES)
@ApiOperation("根据id获取角色管理接口")
public RopResponse<Boolean> deleteById(RoleDeleteRequest request) {
merchantUserService.setUser(request);
try {
return RopResponse.success(roleService.delete(request));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__deleteById__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 角色管理新增接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.role.insert", needInSession = NeedInSessionType.YES)
@ApiOperation("角色管理新增接口")
public RopResponse<Boolean> insert(RoleInsertRequest request) {
merchantUserService.setUser(request);
try {
return RopResponse.success(roleService.insert(request));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__insert__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
}
/**
* 角色管理更新接口
*
* @param request
* @return
*/
@ServiceMethod(method = "org.ore.api.role.update", needInSession = NeedInSessionType.YES)
@ApiOperation("角色管理更新接口")
public RopResponse<Boolean> update(RoleUpdateRequest request) {
merchantUserService.setUser(request);
try {
return RopResponse.success(roleService.update(request));
} catch (RpcServiceException e) {
log.info("=======MerchantRoleController__invoke__update__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(),e.getMessage());
}
} }
} }
...@@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull; ...@@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@Data @Data
public class AccountTypeSaveRequest extends AbstractRopRequest { public class AccountTypeInsertRequest extends AbstractRopRequest {
/** /**
* 账户类型名称 * 账户类型名称
......
...@@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull; ...@@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@Data @Data
public class RoleSaveRequest extends AbstractRopRequest { public class RoleInsertRequest extends AbstractRopRequest {
/** /**
* 角色名称 * 角色名称
......
...@@ -10,9 +10,12 @@ import cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse; ...@@ -10,9 +10,12 @@ import cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse;
import cn.com.glsx.merchants.remote.MerchantAccountTypeRemote; import cn.com.glsx.merchants.remote.MerchantAccountTypeRemote;
import cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest; import cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest;
import cn.com.glsx.merchants.request.accounttype.AccountTypeListSearchRequest; import cn.com.glsx.merchants.request.accounttype.AccountTypeListSearchRequest;
import cn.com.glsx.merchants.request.accounttype.AccountTypeInsertRequest;
import cn.com.glsx.merchants.request.accounttype.AccountTypeUpdateRequest;
import cn.com.glsx.merchants.util.Pagination; import cn.com.glsx.merchants.util.Pagination;
import com.github.dozermapper.core.Mapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -31,6 +34,9 @@ public class MerchantAccountTypeService { ...@@ -31,6 +34,9 @@ public class MerchantAccountTypeService {
@Resource @Resource
private MerchantAccountTypeRemote accountTypeRemote; private MerchantAccountTypeRemote accountTypeRemote;
@Autowired
private Mapper dozerMapper;
/** /**
* id获取账户类型详情 * id获取账户类型详情
* *
...@@ -87,7 +93,7 @@ public class MerchantAccountTypeService { ...@@ -87,7 +93,7 @@ public class MerchantAccountTypeService {
*/ */
public Boolean delete(AccountTypeDeleteRequest request) { public Boolean delete(AccountTypeDeleteRequest request) {
MerchantAccountTypeRequest typeRequest = new MerchantAccountTypeRequest(); MerchantAccountTypeRequest typeRequest = new MerchantAccountTypeRequest();
BeanUtils.copyProperties(request, typeRequest); dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = accountTypeRemote.deleteRemote(typeRequest); RpcResponse<Boolean> response = accountTypeRemote.deleteRemote(typeRequest);
if(response.isSuccess()){ if(response.isSuccess()){
return response.getResult(); return response.getResult();
...@@ -95,4 +101,36 @@ public class MerchantAccountTypeService { ...@@ -95,4 +101,36 @@ public class MerchantAccountTypeService {
throw new RpcServiceException(response.getException().getErrId(),response.getMessage()); throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
} }
/**
* 新增账户类型数据
*
* @param request
* @return
*/
public Boolean insert(AccountTypeInsertRequest request) {
MerchantAccountTypeRequest typeRequest = new MerchantAccountTypeRequest();
dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = accountTypeRemote.insertRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* 更新账户类型数据
*
* @param request
* @return
*/
public Boolean update(AccountTypeUpdateRequest request) {
MerchantAccountTypeRequest typeRequest = new MerchantAccountTypeRequest();
dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = accountTypeRemote.updateRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
} }
package cn.com.glsx.merchants.service; package cn.com.glsx.merchants.service;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.convert.ConvertRequest;
import cn.com.glsx.merchants.convert.ConvertResponse;
import cn.com.glsx.merchants.model.request.MerchantRoleRequest;
import cn.com.glsx.merchants.model.response.MerchantRoleResponse;
import cn.com.glsx.merchants.remote.MerchantRoleRemote; import cn.com.glsx.merchants.remote.MerchantRoleRemote;
import cn.com.glsx.merchants.request.role.RoleDeleteRequest;
import cn.com.glsx.merchants.request.role.RoleListSearchRequest;
import cn.com.glsx.merchants.request.role.RoleInsertRequest;
import cn.com.glsx.merchants.request.role.RoleUpdateRequest;
import cn.com.glsx.merchants.util.Pagination;
import com.github.dozermapper.core.Mapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* @author zhouhaibao * @author zhouhaibao
...@@ -16,8 +31,108 @@ import javax.annotation.Resource; ...@@ -16,8 +31,108 @@ import javax.annotation.Resource;
@Service @Service
public class MerchantRoleService { public class MerchantRoleService {
@Autowired
private Mapper dozerMapper;
@Resource @Resource
private MerchantRoleRemote merchantRoleRemote; private MerchantRoleRemote roleRemote;
/**
* id获取角色管理详情
*
* @param id
* @return
*/
public MerchantRoleResponse getById(Integer id) {
RpcResponse<MerchantRoleResponse> response = roleRemote.getByIdRemote(id);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* 获取角色管理分页数据
*
* @param request
* @return
*/
public Pagination<MerchantRoleResponse> getRolePage(RoleListSearchRequest request) {
RpcPagination<MerchantRoleRequest> pagination =
ConvertRequest.convertPage(request, new MerchantRoleRequest());
RpcResponse<RpcPagination<MerchantRoleResponse>> response =
roleRemote.getRolePageRemote(pagination);
if(response.isSuccess()){
return ConvertResponse.convertPage(response.getResult(), MerchantRoleResponse.class);
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* 获取账户类型数据列表
*
* @param request
* @return
*/
public List<MerchantRoleResponse> getRoleList(RoleListSearchRequest request) {
MerchantRoleRequest typeRequest = new MerchantRoleRequest();
typeRequest.setMerchantId(request.getMerchantId());
typeRequest.setRoleName(request.getRoleName());
RpcResponse<List<MerchantRoleResponse>> response =
roleRemote.getRoleListRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* id删除角色管理
*
* @param request
* @return
*/
public Boolean delete(RoleDeleteRequest request) {
MerchantRoleRequest typeRequest = new MerchantRoleRequest();
dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = roleRemote.deleteRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* 新增角色管理数据
*
* @param request
* @return
*/
public Boolean insert(RoleInsertRequest request) {
MerchantRoleRequest typeRequest = new MerchantRoleRequest();
dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = roleRemote.insertRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
/**
* 更新角色管理数据
*
* @param request
* @return
*/
public Boolean update(RoleUpdateRequest request) {
MerchantRoleRequest typeRequest = new MerchantRoleRequest();
dozerMapper.map(request, typeRequest);
RpcResponse<Boolean> response = roleRemote.updateRemote(typeRequest);
if(response.isSuccess()){
return response.getResult();
}
throw new RpcServiceException(response.getException().getErrId(),response.getMessage());
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!