
28 changed files with 368 additions and 21 deletions
@ -0,0 +1,19 @@ |
|||||
|
package com.yxt.anrui.portal.api.dictcommon; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class DictCommonH5Vo { |
||||
|
|
||||
|
@JsonProperty("id") |
||||
|
private String dictKey; |
||||
|
private String dictValue; |
||||
|
|
||||
|
private Extra extra; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.yxt.anrui.portal.api.dictcommon; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class Extra { |
||||
|
|
||||
|
private String name; |
||||
|
private String sid; |
||||
|
private String info; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.yxt.anrui.portal.api.sysorganization; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class OrgDeptVo { |
||||
|
|
||||
|
private String sid; |
||||
|
|
||||
|
private String name; |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.yxt.anrui.portal.api.syspost; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class SysPostAllVo { |
||||
|
@ApiModelProperty("岗位sid") |
||||
|
private String sid; |
||||
|
@ApiModelProperty("岗位名称") |
||||
|
private String name; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.yxt.anrui.terminal.api.oa.common; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class Extra { |
||||
|
|
||||
|
private String name; |
||||
|
private String sid; |
||||
|
private String info; |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.yxt.anrui.terminal.api.oa.common; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class OaCommonDictVo { |
||||
|
|
||||
|
private String id; |
||||
|
private String dictValue; |
||||
|
|
||||
|
private Extra extra; |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.yxt.anrui.terminal.api.oa.common; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: oa公共 |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@FeignClient( |
||||
|
contextId = "anrui-terminal-OaCommon", |
||||
|
name = "anrui-terminal", |
||||
|
path = "/oa/v1/common", |
||||
|
fallback = OaCommonFeignFallback.class) |
||||
|
public interface OaCommonFeign { |
||||
|
|
||||
|
@ApiOperation("查询岗位") |
||||
|
@GetMapping("/getAllPost") |
||||
|
ResultBean<List<OaCommonDictVo>> getAllPost(@RequestParam(required = false, value = "name") String name); |
||||
|
|
||||
|
@ApiOperation("查询部门") |
||||
|
@GetMapping("/getAllDeptByPath") |
||||
|
ResultBean<List<OaCommonDictVo>> getAllDeptByPath(@RequestParam("orgPath") String orgPath); |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.yxt.anrui.terminal.api.oa.common; |
||||
|
|
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Component |
||||
|
public class OaCommonFeignFallback { |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.yxt.anrui.terminal.biz.oa.common; |
||||
|
|
||||
|
import com.yxt.anrui.terminal.api.oa.common.OaCommonDictVo; |
||||
|
import com.yxt.anrui.terminal.api.oa.common.OaCommonFeign; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@RestController |
||||
|
@RequestMapping("oa/v1/common") |
||||
|
public class OaCommonRest implements OaCommonFeign { |
||||
|
|
||||
|
@Autowired |
||||
|
private OaCommonService oaCommonService; |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<List<OaCommonDictVo>> getAllPost(String name) { |
||||
|
return oaCommonService.getAllPost(name); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<List<OaCommonDictVo>> getAllDeptByPath(String orgPath) { |
||||
|
return oaCommonService.getAllDeptByPath(orgPath); |
||||
|
} |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
package com.yxt.anrui.terminal.biz.oa.common; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.yxt.anrui.portal.api.sysorganization.OrgDeptVo; |
||||
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
||||
|
import com.yxt.anrui.portal.api.syspost.SysPostAllVo; |
||||
|
import com.yxt.anrui.portal.api.syspost.SysPostFeign; |
||||
|
import com.yxt.anrui.terminal.api.base.common.PublicModelVo; |
||||
|
import com.yxt.anrui.terminal.api.oa.common.OaCommonDictVo; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
import java.util.Optional; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2025/1/16 |
||||
|
**/ |
||||
|
@Service |
||||
|
public class OaCommonService { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysPostFeign sysPostFeign; |
||||
|
@Autowired |
||||
|
private SysOrganizationFeign sysOrganizationFeign; |
||||
|
|
||||
|
public ResultBean<List<OaCommonDictVo>> getAllPost(String name) { |
||||
|
ResultBean<List<OaCommonDictVo>> rb = ResultBean.fireFail(); |
||||
|
ResultBean<List<SysPostAllVo>> resultBean = sysPostFeign.getAllPost(name); |
||||
|
List<OaCommonDictVo> voList = Optional.ofNullable(resultBean.getData()) |
||||
|
.orElse(Collections.emptyList()) // 如果为 null,则返回一个空列表
|
||||
|
.stream() |
||||
|
.map(post -> { |
||||
|
OaCommonDictVo oaCommonDictVo = new OaCommonDictVo(); |
||||
|
// 映射属性:手动指定属性名称和类型不一致时的赋值方式
|
||||
|
oaCommonDictVo.setId(post.getSid()); // 将 SysPostAllVo 的 postId 映射到 OaCommonDictVo 的 id
|
||||
|
oaCommonDictVo.setDictValue(post.getName()); // 将 SysPostAllVo 的 postName 映射到 OaCommonDictVo 的 name
|
||||
|
return oaCommonDictVo; |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
return rb.success().setData(voList); |
||||
|
} |
||||
|
|
||||
|
public ResultBean<List<OaCommonDictVo>> getAllDeptByPath(String orgPath) { |
||||
|
ResultBean<List<OaCommonDictVo>> rb = ResultBean.fireFail(); |
||||
|
ResultBean<List<OrgDeptVo>> resultBean = sysOrganizationFeign.getAllDept(orgPath); |
||||
|
List<OaCommonDictVo> voList = Optional.ofNullable(resultBean.getData()) |
||||
|
.orElse(Collections.emptyList()) // 如果为 null,则返回一个空列表
|
||||
|
.stream() |
||||
|
.map(dept -> { |
||||
|
OaCommonDictVo oaCommonDictVo = new OaCommonDictVo(); |
||||
|
// 映射属性:手动指定属性名称和类型不一致时的赋值方式
|
||||
|
oaCommonDictVo.setId(dept.getSid()); |
||||
|
oaCommonDictVo.setDictValue(dept.getName()); |
||||
|
return oaCommonDictVo; |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
return rb.success().setData(voList); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue