|
@@ -0,0 +1,224 @@
|
|
|
+package com.hcloud.microservice.traced.web.sysmanager;
|
|
|
+
|
|
|
+import com.hcloud.microserver.commoncore.annotation.AuthOrgValidate;
|
|
|
+import com.hcloud.microserver.commoncore.base.ResponseBase;
|
|
|
+import com.hcloud.microserver.commoncore.base.ResultVO;
|
|
|
+import com.hcloud.microserver.commoncore.constant.GlobleConstant;
|
|
|
+import com.hcloud.microserver.commoncore.enums.OrgAuthEnum;
|
|
|
+import com.hcloud.microserver.commoncore.enums.ResultEnum;
|
|
|
+import com.hcloud.microserver.commoncore.service.RedisUtils;
|
|
|
+import com.hcloud.microserver.commoncore.util.BeanCopyUtil;
|
|
|
+import com.hcloud.microservice.org.facade.client.OrgManagerService;
|
|
|
+import com.hcloud.microservice.org.facade.client.UserManagerService;
|
|
|
+import com.hcloud.microservice.org.facade.entity.BaseOrg;
|
|
|
+import com.hcloud.microservice.org.facade.forms.BaseOrgForm;
|
|
|
+import com.hcloud.microservice.org.facade.forms.BaseUserForm;
|
|
|
+import com.hcloud.microservice.traced.common.BaseInfoDO;
|
|
|
+import com.hcloud.microservice.traced.common.TracedBaseController;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+
|
|
|
+ * @author xiezt
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/web/org")
|
|
|
+@Api(description = "企业管理服务")
|
|
|
+public class OrgManagerController extends TracedBaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrgManagerService orgManagerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserManagerService userManagerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisUtils redisUtils;
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询机构信息",notes = "根据机构信息查询机构权限记录")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseAuthForm",value = "查询条件",dataType = "BaseAuthForm")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "查询成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_QUERY)
|
|
|
+ @PostMapping("/searchByPage")
|
|
|
+ public ResponseBase getAuth(@RequestBody BaseOrgForm baseOrgForm){
|
|
|
+ ResultVO resultVO = orgManagerService.searchOrgInfoByPage(baseOrgForm);
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加机构信息",notes = "根据机构信息添加机构")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseOrgForm",value = "机构信息",dataType = "BaseOrgForm")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_ADD)
|
|
|
+ @PostMapping("/add")
|
|
|
+ public ResponseBase addOrgInfo(@RequestBody BaseOrgForm baseOrgForm){
|
|
|
+ BaseInfoDO infoDO = initiSaveObject();
|
|
|
+ if(infoDO==null){return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));}
|
|
|
+ baseOrgForm.setState(infoDO.getState());
|
|
|
+ baseOrgForm.setCreateUser(infoDO.getCreateUser());
|
|
|
+ baseOrgForm.setCreateTime(infoDO.getCreateTime());
|
|
|
+ baseOrgForm.setModifiedUser(infoDO.getModifiedUser());
|
|
|
+ baseOrgForm.setModifiedTime(infoDO.getModifiedTime());
|
|
|
+ ResultVO resultVO = orgManagerService.addOrgInfo(baseOrgForm);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改机构信息",notes = "根据机构信息修改机构基本信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseOrgForm",value = "机构信息",dataType = "BaseOrgForm")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_EDIT)
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public ResponseBase editOrgInfo(@RequestBody BaseOrgForm baseOrgForm){
|
|
|
+ ResultVO resultVO = orgManagerService.updateOrgInfo(baseOrgForm);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ BaseInfoDO baseInfoDO = this.initiSaveObject();
|
|
|
+ if(baseInfoDO.getFkOrgGuid().equals(baseOrgForm.getGuid())) {
|
|
|
+ String accessToke = this.getRequestObject().getHeader(ACCESS_TOKEN);
|
|
|
+ Map redisMap = (Map) redisUtils.getValue(accessToke);
|
|
|
+ BaseOrg baseOrg = (BaseOrg) redisMap.get(GlobleConstant.ORG_OBJECT);
|
|
|
+ baseOrg.setQrcodeUrlPrefixe(baseOrgForm.getQrcodeUrlPrefixe());
|
|
|
+ redisMap.put(GlobleConstant.ORG_OBJECT, baseOrg);
|
|
|
+ this.redisUtils.setValue(accessToke, redisMap);
|
|
|
+ }
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查看机构明细",notes = "根据机构Id查询机构基本信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "guid",value = "机构id",paramType = "query",dataType = "String")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_GET)
|
|
|
+ @GetMapping("/searchById")
|
|
|
+ public ResponseBase searchInfoById(@RequestParam("guid") String guid){
|
|
|
+ ResultVO resultVO = orgManagerService.searchOrgInfoById(guid);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除机构信息",notes = "根据机构信息删除机构基本信息(逻辑删除)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "orgGuid",value = "机构信息",paramType = "query",dataType = "String")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_DEL)
|
|
|
+ @GetMapping("/del")
|
|
|
+ public ResponseBase delOrgInfo(@RequestParam("guid") String orgGuid){
|
|
|
+ BaseOrgForm baseOrgForm = new BaseOrgForm();
|
|
|
+ baseOrgForm.setState(0);
|
|
|
+ baseOrgForm.setGuid(orgGuid);
|
|
|
+ ResultVO resultVO = orgManagerService.updateOrgInfo(baseOrgForm);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询机构权限信息",notes = "树型结构列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseOrgForm",value = "机构信息",paramType = "query",dataType = "BaseOrgForm")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_SEARCH_AUTH)
|
|
|
+ @GetMapping("/searchAuthInfo")
|
|
|
+ public ResponseBase searchAuthInfo(@RequestParam("orgGuid") String orgGuid){
|
|
|
+ ResultVO resultVO = orgManagerService.searchOrgAuthDistributioned(orgGuid);
|
|
|
+ if(null!= resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分配机构权限信息",notes = "组成json数组")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseOrgForm",value = "权限列表",dataType = " List<BaseOrgAuthForm>")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_DIS_AUTH)
|
|
|
+ @PostMapping("/distrOrgAuthInfo")
|
|
|
+ public ResponseBase distrOrgAuthInfo(@RequestBody BaseOrgForm baseOrgForm ) {
|
|
|
+ ResultVO resultVO = orgManagerService.distributionOrgAuthInfo(baseOrgForm.getGuid(),baseOrgForm.getMenuList());
|
|
|
+ if(resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加企业管理用户",notes = "用户信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseUserForm",value = "用户基本信息",dataType = "BaseUserForm")
|
|
|
+ })
|
|
|
+ @ApiResponses({
|
|
|
+ @ApiResponse(code =0,message = "操作成功"),
|
|
|
+ @ApiResponse(code =609,message = "账号重复")
|
|
|
+ })
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_USER_ADD)
|
|
|
+ @PostMapping("/addOrgUser")
|
|
|
+ public ResponseBase addOrgManagerUser(@RequestBody BaseUserForm baseUserForm){
|
|
|
+ BaseInfoDO infoDO = this.initiSaveObject();
|
|
|
+ if(infoDO==null){return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));}
|
|
|
+ baseUserForm.setFkProductGuid(GlobleConstant.PRODUCT_GUID);
|
|
|
+ baseUserForm.setLoginOrgGuid(this.getOrgGuid());
|
|
|
+ baseUserForm.setCreateUser(infoDO.getCreateUser());
|
|
|
+ baseUserForm.setModifiedUser(infoDO.getModifiedUser());
|
|
|
+ baseUserForm.setCreateTime(baseUserForm.getCreateTime());
|
|
|
+ baseUserForm.setModifiedTime(baseUserForm.getModifiedTime());
|
|
|
+ baseUserForm.setState(1);
|
|
|
+ ResultVO resultVO = userManagerService.addUserInfo(baseUserForm);
|
|
|
+ if(null!= resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "查看机构推广信息",notes = "查询登录用户所属机构的基本信息")
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_EXTENDS)
|
|
|
+ @GetMapping("/searchOrgInfo")
|
|
|
+ public ResponseBase searchOrgInfo(){
|
|
|
+ String guid = this.getOrgGuid();
|
|
|
+ if(guid==null){return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));}
|
|
|
+ ResultVO resultVO = orgManagerService.searchOrgInfoById(guid);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+ @ApiOperation(value = "修改企业推广信息",notes = "修改企业推广信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "baseOrgForm",value = "机构信息",dataType = "BaseOrgForm")
|
|
|
+ })
|
|
|
+ @ApiResponse(code =0,message = "操作成功")
|
|
|
+ @AuthOrgValidate(value = OrgAuthEnum.PLATFORM_ORG_EXTENDS)
|
|
|
+ @PostMapping("/editExtendInfo")
|
|
|
+ public ResponseBase editOrgExtendsInfo(@RequestBody BaseOrgForm baseOrgForm){
|
|
|
+ BaseInfoDO baseInfoDO = this.initiSaveObject();
|
|
|
+ if(baseInfoDO==null){return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));}
|
|
|
+ BeanCopyUtil.copyBean(baseOrgForm,baseInfoDO);
|
|
|
+ ResultVO resultVO = orgManagerService.updateOrgInfo(baseOrgForm);
|
|
|
+ if(null!=resultVO && resultVO.getCode()==0){
|
|
|
+ return responseSuccess(resultVO);
|
|
|
+ }
|
|
|
+ return responseError(resultVO);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|