公司/分部管理 列表接口
parent
273e29fbe9
commit
6978eb5246
@ -0,0 +1,13 @@
|
||||
package com.api.organization.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Path("/bs/hrmorganization/comp")
|
||||
public class CompController extends com.engine.organization.web.CompController{
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.engine.organization.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description: 基础查询参数
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BaseQueryParam {
|
||||
//当前页码
|
||||
private Integer current = 1;
|
||||
|
||||
//每页数据条数
|
||||
private Integer pageSize = 10;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.engine.organization.entity.comp.bo;
|
||||
|
||||
import com.engine.organization.entity.comp.dto.CompListDTO;
|
||||
import com.engine.organization.entity.comp.po.CompPO;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CompBO {
|
||||
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<CompListDTO> dtoList = list.stream().map(e -> CompListDTO.builder()
|
||||
.id(e.getId())
|
||||
.compNo(e.getCompNo())
|
||||
.compName(e.getCompName())
|
||||
.compNameShort(e.getCompNameShort())
|
||||
.parentCompany(e.getParentCompany())
|
||||
.orgCode(e.getOrgCode())
|
||||
.industry(e.getIndustry())
|
||||
.compPrincipal(e.getCompPrincipal())
|
||||
.description(e.getDescription())
|
||||
.forbiddenTag(e.getForbiddenTag())
|
||||
.build()
|
||||
).collect(Collectors.toList());
|
||||
Map<Long, List<CompListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany));
|
||||
return dtoList.stream().filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).map(e -> {
|
||||
e.setChildren(collects.get(e.getId()));
|
||||
return e;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.engine.organization.entity.comp.dto;
|
||||
|
||||
import com.cloudstore.eccom.pc.table.WeaTableType;
|
||||
import com.engine.organization.annotation.OrganizationTable;
|
||||
import com.engine.organization.annotation.OrganizationTableOperate;
|
||||
import com.engine.organization.annotation.TableTitle;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@OrganizationTable(pageId = "2c66b3a4-d4f8-11ec-9774-00ffcbed7508",
|
||||
tableType = WeaTableType.NONE,
|
||||
operates = {
|
||||
@OrganizationTableOperate(index = "0", text = "编辑"),
|
||||
@OrganizationTableOperate(index = "1", text = "删除"),
|
||||
@OrganizationTableOperate(index = "2", text = "查看部门")
|
||||
})
|
||||
public class CompListDTO {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableTitle(title = "id", dataIndex = "id", key = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableTitle(title = "编号", dataIndex = "compNo", key = "compNo")
|
||||
private String compNo;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableTitle(title = "名称", dataIndex = "compName", key = "compName")
|
||||
private String compName;
|
||||
|
||||
/**
|
||||
* 简称
|
||||
*/
|
||||
@TableTitle(title = "简称", dataIndex = "compNameShort", key = "compNameShort")
|
||||
private String compNameShort;
|
||||
|
||||
/**
|
||||
* 上级公司
|
||||
*/
|
||||
@TableTitle(title = "上级公司", dataIndex = "parentCompany", key = "parentCompany")
|
||||
private Long parentCompany;
|
||||
|
||||
/**
|
||||
* 组织机构代码
|
||||
*/
|
||||
@TableTitle(title = "组织机构代码", dataIndex = "orgCode", key = "orgCode")
|
||||
private String orgCode;
|
||||
|
||||
/**
|
||||
* 行业
|
||||
*/
|
||||
@TableTitle(title = "行业", dataIndex = "industry", key = "industry")
|
||||
private Integer industry;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@TableTitle(title = "负责人", dataIndex = "compPrincipal", key = "compPrincipal")
|
||||
private Integer compPrincipal;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@TableTitle(title = "说明", dataIndex = "description", key = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 禁用标记
|
||||
*/
|
||||
@TableTitle(title = "禁用标记", dataIndex = "forbiddenTag", key = "forbiddenTag")
|
||||
private String forbiddenTag;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<CompListDTO> children;
|
||||
|
||||
private Long creator;
|
||||
private int deleteType;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.engine.organization.mapper.comp;
|
||||
|
||||
import com.engine.organization.common.BaseQueryParam;
|
||||
import com.engine.organization.entity.comp.po.CompPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface CompMapper {
|
||||
/**
|
||||
* 列表查询
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
List<CompPO> list(@Param("param") BaseQueryParam queryParam);
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.comp.CompMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.organization.entity.comp.po.CompPO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="comp_no" property="compNo"/>
|
||||
<result column="comp_name" property="compName"/>
|
||||
<result column="comp_name_short" property="compNameShort"/>
|
||||
<result column="parent_company" property="parentCompany"/>
|
||||
<result column="org_code" property="orgCode"/>
|
||||
<result column="industry" property="industry"/>
|
||||
<result column="comp_principal" property="compPrincipal"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="forbidden_tag" property="forbiddenTag"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.comp_no
|
||||
, t.comp_name
|
||||
, t.comp_name_short
|
||||
, t.parent_company
|
||||
, t.org_code
|
||||
, t.industry
|
||||
, t.comp_principal
|
||||
, t.description
|
||||
, t.forbidden_tag
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
</sql>
|
||||
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM
|
||||
jcl_org_comp t
|
||||
WHERE t.delete_type = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,21 @@
|
||||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.common.BaseQueryParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface CompService {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param baseQueryParam
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> listPage(BaseQueryParam baseQueryParam);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.engine.organization.service.impl;
|
||||
|
||||
|
||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.common.BaseQueryParam;
|
||||
import com.engine.organization.component.OrganizationWeaTable;
|
||||
import com.engine.organization.entity.comp.bo.CompBO;
|
||||
import com.engine.organization.entity.comp.dto.CompListDTO;
|
||||
import com.engine.organization.entity.comp.po.CompPO;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.service.CompService;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.page.Column;
|
||||
import com.engine.organization.util.page.PageInfo;
|
||||
import com.engine.organization.util.page.PageUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CompServiceImpl extends Service implements CompService {
|
||||
private CompMapper getCompMapper() {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> listPage(BaseQueryParam queryParam) {
|
||||
Map<String,Object> datas = new HashMap<>();
|
||||
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
||||
List<CompPO> list = getCompMapper().list(queryParam);
|
||||
PageInfo<CompPO> pageInfo = new PageInfo<>(list, CompPO.class);
|
||||
Collection<CompPO> compPOS = pageInfo.getList();
|
||||
|
||||
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(compPOS);
|
||||
PageInfo<CompListDTO> pageInfos = new PageInfo<>(compListDTOS, CompListDTO.class);
|
||||
pageInfos.setTotal(pageInfo.getTotal());
|
||||
pageInfos.setPageNum(queryParam.getCurrent());
|
||||
pageInfos.setPageSize(queryParam.getPageSize());
|
||||
|
||||
OrganizationWeaTable<CompListDTO> table = new OrganizationWeaTable<>(user, CompListDTO.class);
|
||||
List<Column> columns = pageInfos.getColumns();
|
||||
List<WeaTableColumn> weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList());
|
||||
|
||||
table.setColumns(weaTableColumn);
|
||||
|
||||
WeaResultMsg result = new WeaResultMsg(false);
|
||||
result.putAll(table.makeDataResult());
|
||||
result.success();
|
||||
|
||||
|
||||
datas.put("pageInfo", pageInfos);
|
||||
datas.put("dataKey",result.getResultMap());
|
||||
return datas;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.engine.organization.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.common.BaseQueryParam;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.engine.organization.wrapper.CompWrapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CompController {
|
||||
public CompWrapper getCompWrapper(User user) {
|
||||
return ServiceUtil.getService(CompWrapper.class, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取list列表
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/listComp")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult listComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody BaseQueryParam queryParam) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getCompWrapper(user).listPage(queryParam));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.engine.organization.wrapper;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.common.BaseQueryParam;
|
||||
import com.engine.organization.service.CompService;
|
||||
import com.engine.organization.service.impl.CompServiceImpl;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CompWrapper extends Service {
|
||||
private CompService getCompService(User user) {
|
||||
return ServiceUtil.getService(CompServiceImpl.class, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> listPage(BaseQueryParam params) {
|
||||
return getCompService(user).listPage(params);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue