Skip to content

Commit

Permalink
完善组织架构管理
Browse files Browse the repository at this point in the history
  • Loading branch information
leecho committed Apr 20, 2018
1 parent c17d35d commit 2d2940b
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 161 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cola-cloud-organization</artifactId>
<groupId>com.honvay.cola</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cola-cloud-organization-client</artifactId>
<dependencies>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-framework-core</artifactId>
</dependency>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-organization-model</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.honvay.cola.cloud.organization.client;

import com.honvay.cola.cloud.framework.core.protocol.Result;
import com.honvay.cola.cloud.organization.model.SysEmployeeAddDTO;
import com.honvay.cola.cloud.organization.model.SysEmployeeDTO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;

/**
* @author LIQIU
* @date 2018-4-20
**/
@FeignClient(serviceId = "organization-service")
public interface SysEmployeeClient {

@PostMapping("/organization/employee/add")
Result<SysEmployeeDTO> add(SysEmployeeAddDTO SysEmployeeAddDTO);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.honvay.cola.cloud.organization.client;

import com.honvay.cola.cloud.framework.core.protocol.Result;
import com.honvay.cola.cloud.organization.model.SysOrganizationDTO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;

/**
* @author LIQIU
* @date 2018-4-20
**/
@FeignClient(serviceId = "organization-service")
public interface SysOrganizationClient {

@PostMapping("/organization/organization/add")
Result<SysOrganizationDTO> add(SysOrganizationDTO sysOrganizationDTO);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cola-cloud-organization</artifactId>
<groupId>com.honvay.cola</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cola-cloud-organization-model</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public class SysEmployeeDTO implements Serializable {
@NotNull(message = "用户名不能为空")
private String username;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.honvay.cola.cloud.organization.model;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;


/**
* 组织架构
*
* @author LIQIU
*/
@Data
public class SysOrganizationDTO {

private Long id;

/**
* 组织名称
*/
@NotNull(message = "组织名称不能为空")
@Length(max = 100, message = "组织名称长度必须{max}个字符内")
private String name;

/**
* 组织描述
*/
private String description;

/**
* 父组织编号
*/
@NotNull(message = "上级部门不能为空")
private Long parent;

/**
* 组织代码
*/
@NotNull(message = "组织编号不能为空")
@Length(max = 50, message = "组织编号长度必须{max}个字符内")
private String code;

private Long tenantId;

private String deleted;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cola-cloud-organization</artifactId>
<groupId>com.honvay.cola</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cola-cloud-organization-service</artifactId>

<dependencies>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-framework-base</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-uc-client</artifactId>
</dependency>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-tenancy-client</artifactId>
</dependency>
<dependency>
<groupId>com.honvay.cola</groupId>
<artifactId>cola-cloud-organization-model</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.honvay.cola.cloud.organization;

import com.honvay.cola.cloud.framework.oauth2.feign.EnableOAuth2ClientFeign;
import com.honvay.cola.cloud.framework.oauth2.token.EnableUserPrincipalExtractor;
import com.honvay.cola.cloud.framework.security.access.EnableSecurityAccess;
import org.springframework.boot.SpringApplication;
import org.springframework.cache.annotation.EnableCaching;
Expand All @@ -20,7 +19,6 @@
@EnableOAuth2Client
@EnableOAuth2ClientFeign
@EnableResourceServer
@EnableUserPrincipalExtractor
@EnableFeignClients("com.honvay")
@ComponentScan("com.honvay")
@EnableCaching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
* @author LIQIU
* @date 2018-1-10
**/
public class SysSqlBuilder {
public class SysOrganizationBuilder {

/**
* 构建获取员工列表SQL语句
*
* @param params
* @return
*/
public String buildGetEmployeeListByOrgIdSql(Map<String,Object> params){
return new SQL(){{SELECT("ase.id,asu.name,asu.username,asu.status,asu.email");
public String buildGetEmployeeListByOrgIdSql(Map<String, Object> params) {
return new SQL() {{
SELECT("ase.id,asu.name,asu.username,asu.status,asu.email");
SELECT("asu.phone_number as phoneNumber,ase.sys_org_id as orgId");
SELECT("asp.name as postName,asu.id as userId");
FROM("cola_sys_employee ase");
Expand All @@ -38,14 +40,16 @@ public String buildGetEmployeeListByOrgIdSql(Map<String,Object> params){

/**
* 构建组织机构列表SQL语句
*
* @param params
* @return
*/
public String buildListOrganizationSql(Map<String,Object> params){
return new SQL(){{SELECT("ado.id,ado.name,ado.description,ado.code,ado.pid,ado.status");
public String buildListOrganizationSql(Map<String, Object> params) {
return new SQL() {{
SELECT("ado.id,ado.name,ado.description,ado.code,ado.parent,ado.status");
SELECT("adop.code as pcode,adop.name as pname");
FROM("cola_sys_organization ado");
LEFT_OUTER_JOIN("cola_sys_organization adop on adop.id = ado.pid");
LEFT_OUTER_JOIN("cola_sys_organization adop on adop.id = ado.parent");
WHERE("ado.deleted <> '" + CommonConstant.COMMON_YES + "'");
if (Objects.nonNull(params.get("name"))) {
WHERE("ado.name like #{name}");
Expand All @@ -61,14 +65,16 @@ public String buildListOrganizationSql(Map<String,Object> params){

/**
* 构建组织机构详情SQL语句
*
* @param params
* @return
*/
public String buildGetOrganizationSql(Map<String,Object> params){
return new SQL(){{SELECT("ado.id,ado.name,ado.description,ado.code,ado.pid,ado.deleted,ado.status");
public String buildGetOrganizationSql(Map<String, Object> params) {
return new SQL() {{
SELECT("ado.id,ado.name,ado.description,ado.code,ado.parent,ado.deleted,ado.status");
SELECT("adop.code as pcode,adop.name as pname");
FROM("cola_sys_organization ado");
LEFT_OUTER_JOIN("cola_sys_organization adop on adop.id = ado.pid");
LEFT_OUTER_JOIN("cola_sys_organization adop on adop.id = ado.parent");
WHERE("ado.id = " + params.get("id"));
}}.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.honvay.cola.cloud.framework.core.protocol.Result;
import com.honvay.cola.cloud.framework.util.Assert;
import com.honvay.cola.cloud.organization.entity.SysOrganization;
import com.honvay.cola.cloud.organization.model.SysOrganizationDTO;
import com.honvay.cola.cloud.organization.model.SysOrganizationVO;
import com.honvay.cola.cloud.organization.service.SysOrganizationService;
import io.swagger.annotations.Api;
Expand All @@ -31,11 +32,11 @@ public class SysOrganizationController extends BaseController {
@Autowired
private SysOrganizationService sysOrganizationService;

@ApiOperation(value="获取机构列表")
@ApiOperation(value = "获取机构列表")
@GetMapping("/list")
public Result<Page<SysOrganization>> list(String name, String code, String status){
public Result<Page<SysOrganization>> list(String name, String code, String status) {
Page page = this.getPagination();
page.setRecords(this.sysOrganizationService.list(page,name,code,status));
page.setRecords(this.sysOrganizationService.list(page, name, code, status));
return this.success(page);
}

Expand All @@ -52,15 +53,17 @@ public Result<String> del(@RequestParam Long id) {
return this.success();
}

@ApiOperation(value = "新增/修改机构")
@PostMapping("/save")
public Result<String> save(@Validated SysOrganization t) {
if (t.getId() != null) {
this.sysOrganizationService.updateById(t);
} else {
Assert.notNull(t.getPid(), "所属部门不能为空");
this.sysOrganizationService.insert(t);
}
@ApiOperation(value = "新增机构")
@PostMapping("/add")
public Result<String> add(@Validated SysOrganizationDTO sysOrganizationDTO) {
this.sysOrganizationService.insert(sysOrganizationDTO);
return this.success();
}

@ApiOperation(value = "修改机构")
@PostMapping("/update")
public Result<String> update(@Validated SysOrganizationDTO sysOrganizationDTO) {
this.sysOrganizationService.update(sysOrganizationDTO);
return this.success();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,14 @@
public class SysEmployee implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;

private Long sysUserId;

private Long sysOrgId;

private Long createBy;
private Date createDate;
private Long modifyBy;
private Date modifyDate;
//private String name;
//private String account;

private Long sysPostId;
private String level;
private String idcard;
private String status;
private String picture;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class SysOrganization extends TenancyEntity implements Serializable {
/**
* 父组织编号
*/
private Long pid;
@NotNull(message = "上级组织架构不能为空")
private Long parent;

/**
* 组织代码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.honvay.cola.cloud.organization.builder.SysSqlBuilder;
import com.honvay.cola.cloud.organization.builder.SysOrganizationBuilder;
import com.honvay.cola.cloud.organization.entity.SysEmployee;
import com.honvay.cola.cloud.organization.model.SysEmployeeVO;
import org.apache.ibatis.annotations.Param;
Expand Down Expand Up @@ -31,7 +31,7 @@ public interface SysEmployeeMapper extends BaseMapper<SysEmployee> {
* @return
*/

@SelectProvider(type = SysSqlBuilder.class,method ="buildGetEmployeeListByOrgIdSql")
@SelectProvider(type = SysOrganizationBuilder.class,method ="buildGetEmployeeListByOrgIdSql")
List<SysEmployeeVO> getEmployeeListByOrgId(Page page, @Param("name") String name, @Param("username") String username, @Param("status") Integer status) ;

/**
Expand Down
Loading

0 comments on commit 2d2940b

Please sign in to comment.