15 changed files with 845 additions and 2 deletions
@ -0,0 +1,57 @@ |
|||
<?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> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-parent-yushan</artifactId> |
|||
<version>1.0.0</version> |
|||
<relativePath>../epdc-cloud-parent-yushan</relativePath> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<version>1.0.0</version> |
|||
<artifactId>epdc-cloud-optimize-department</artifactId> |
|||
<packaging>jar</packaging> |
|||
<description>党群e家部门机构优化微服务模块</description> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.projectlombok</groupId> |
|||
<artifactId>lombok</artifactId> |
|||
<scope>provided</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-autoconfigure</artifactId> |
|||
<scope>compile</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-mybatis</artifactId> |
|||
<version>${epdc-cloud-commons.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-api-version-control</artifactId> |
|||
<version>${epdc-cloud-commons.version}</version> |
|||
</dependency> |
|||
|
|||
<!--业务模块--> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-admin-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
|
|||
</project> |
@ -0,0 +1,8 @@ |
|||
-- 小程序码维护功能,新增表字段,不影响原本的代码及功能 |
|||
ALTER TABLE epdc_dept_ma_code ADD COLUMN `GRID` VARCHAR ( 128 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '网格名称'; |
|||
ALTER TABLE epdc_dept_ma_code ADD COLUMN `PARENT_DEPT_IDS` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '父所有部门'; |
|||
ALTER TABLE epdc_dept_ma_code ADD COLUMN `PARENT_DEPT_NAMES` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '父所有部门'; |
|||
ALTER TABLE epdc_dept_ma_code ADD COLUMN `ALL_DEPT_IDS` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所有部门ID'; |
|||
ALTER TABLE epdc_dept_ma_code ADD COLUMN `ALL_DEPT_NAMES` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所有部门名称'; |
|||
|
|||
|
@ -0,0 +1,101 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.DeptMaCodeDTO; |
|||
import com.elink.esua.epdc.optimize.modules.macode.excel.DeptMaCodeExcel; |
|||
import com.elink.esua.epdc.optimize.modules.macode.service.OptDeptMaCodeService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("optimize/deptmacode") |
|||
public class OptDeptMaCodeController { |
|||
|
|||
@Autowired |
|||
private OptDeptMaCodeService deptMaCodeService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<DeptMaCodeDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<DeptMaCodeDTO> page = deptMaCodeService.page(params); |
|||
return new Result<PageData<DeptMaCodeDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<DeptMaCodeDTO> get(@PathVariable("id") String id){ |
|||
DeptMaCodeDTO data = deptMaCodeService.get(id); |
|||
return new Result<DeptMaCodeDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody DeptMaCodeDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
deptMaCodeService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody DeptMaCodeDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
deptMaCodeService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
deptMaCodeService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<DeptMaCodeDTO> list = deptMaCodeService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, DeptMaCodeExcel.class); |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("initDeptForMaCode") |
|||
public Result initDeptForMaCode(){ |
|||
deptMaCodeService.initDeptForMaCode(); |
|||
return new Result(); |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Mapper |
|||
public interface OptDeptMaCodeDao extends BaseDao<OptDeptMaCodeEntity> { |
|||
|
|||
/** |
|||
* 根据机构类型,查询机构id及pids |
|||
* |
|||
* @param dataScopeDeptIds 用户部门数据权限 |
|||
* @param typeKey 机构类型{@link com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant} |
|||
* @return java.util.List<com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity> |
|||
* @author work@yujt.net.cn |
|||
* @date 2020/5/15 13:58 |
|||
*/ |
|||
List<OptDeptMaCodeEntity> selectListDeptIdByTypeKey(@Param("dataScopeDeptIds") List<Long> dataScopeDeptIds, @Param("typeKey") String typeKey); |
|||
|
|||
/** |
|||
* 根据机构id和机构父id,查询机构及父机构名称 |
|||
* |
|||
* @param deptId 机构id |
|||
* @param parentIds 父机构id |
|||
* @return java.util.List<com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity> |
|||
* @author work@yujt.net.cn |
|||
* @date 2020/5/15 14:10 |
|||
*/ |
|||
List<OptDeptMaCodeEntity> selectListDeptAndParents(@Param("deptId") String deptId, @Param("parentIds") String[] parentIds); |
|||
} |
@ -0,0 +1,111 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Data |
|||
public class DeptMaCodeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private Long gridId; |
|||
|
|||
/** |
|||
* 小程序码URL |
|||
*/ |
|||
private String codeUrl; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 删除标记 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 是否是网格长码,0否 1是 |
|||
*/ |
|||
private String leaderFlag; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String grid; |
|||
|
|||
/** |
|||
* 父所有部门 |
|||
*/ |
|||
private String parentDeptIds; |
|||
|
|||
/** |
|||
* 父所有部门 |
|||
*/ |
|||
private String parentDeptNames; |
|||
|
|||
/** |
|||
* 所有部门ID |
|||
*/ |
|||
private String allDeptIds; |
|||
|
|||
/** |
|||
* 所有部门名称 |
|||
*/ |
|||
private String allDeptNames; |
|||
|
|||
} |
@ -0,0 +1,60 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.entity.DeptScope; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_dept_ma_code_copy1") |
|||
public class OptDeptMaCodeEntity extends DeptScope { |
|||
|
|||
private static final long serialVersionUID = -6665011097985008073L; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private Long gridId; |
|||
|
|||
/** |
|||
* 小程序码URL |
|||
*/ |
|||
private String codeUrl; |
|||
|
|||
/** |
|||
* 是否是网格长码,0否 1是 |
|||
*/ |
|||
private String leaderFlag; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String grid; |
|||
|
|||
} |
@ -0,0 +1,80 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Data |
|||
public class DeptMaCodeExcel { |
|||
|
|||
@Excel(name = "主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "网格ID") |
|||
private Long gridId; |
|||
|
|||
@Excel(name = "小程序码URL") |
|||
private String codeUrl; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
@Excel(name = "删除标记") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "是否是网格长码,0否 1是") |
|||
private String leaderFlag; |
|||
|
|||
@Excel(name = "网格名称") |
|||
private String grid; |
|||
|
|||
@Excel(name = "父所有部门") |
|||
private String parentDeptIds; |
|||
|
|||
@Excel(name = "父所有部门") |
|||
private String parentDeptNames; |
|||
|
|||
@Excel(name = "所有部门ID") |
|||
private String allDeptIds; |
|||
|
|||
@Excel(name = "所有部门名称") |
|||
private String allDeptNames; |
|||
|
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.redis; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Component |
|||
public class DeptMaCodeRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,105 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.DeptMaCodeDTO; |
|||
import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
public interface OptDeptMaCodeService extends BaseService<OptDeptMaCodeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<DeptMaCodeDTO> |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
PageData<DeptMaCodeDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<DeptMaCodeDTO> |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
List<DeptMaCodeDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return DeptMaCodeDTO |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
DeptMaCodeDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
void save(DeptMaCodeDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
void update(DeptMaCodeDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-05-15 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* 根据部门权限,同步部门信息 |
|||
* |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author work@yujt.net.cn |
|||
* @date 2020/5/15 15:27 |
|||
*/ |
|||
Result initDeptForMaCode(); |
|||
} |
@ -0,0 +1,154 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.optimize.modules.macode.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.DeptMaCodeDTO; |
|||
import com.elink.esua.epdc.optimize.modules.macode.dao.OptDeptMaCodeDao; |
|||
import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity; |
|||
import com.elink.esua.epdc.optimize.modules.macode.service.OptDeptMaCodeService; |
|||
import com.google.common.collect.Lists; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 网格小程序码 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-15 |
|||
*/ |
|||
@Service |
|||
public class OptDeptMaCodeServiceImpl extends BaseServiceImpl<OptDeptMaCodeDao, OptDeptMaCodeEntity> implements OptDeptMaCodeService { |
|||
|
|||
@Override |
|||
public PageData<DeptMaCodeDTO> page(Map<String, Object> params) { |
|||
|
|||
IPage<OptDeptMaCodeEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, DeptMaCodeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public Result initDeptForMaCode() { |
|||
List<Long> dataScopeList = SecurityUser.getUser().getDeptIdList(); |
|||
List<OptDeptMaCodeEntity> deptIdList = baseDao.selectListDeptIdByTypeKey(dataScopeList, OrganizationTypeConstant.ORG_TYPE_GRID_PARTY); |
|||
if (CollUtil.isEmpty(deptIdList)) { |
|||
return new Result(); |
|||
} |
|||
List<OptDeptMaCodeEntity> insertList = Lists.newArrayList(); |
|||
for (OptDeptMaCodeEntity deptMaCodeEntity : deptIdList) { |
|||
insertList.add(packDeptBaseInfo(deptMaCodeEntity.getGrid(), deptMaCodeEntity.getParentDeptIds())); |
|||
} |
|||
insertBatch(insertList, NumConstant.FIFTY); |
|||
return new Result(); |
|||
} |
|||
|
|||
|
|||
private OptDeptMaCodeEntity packDeptBaseInfo(String deptId, String pids) { |
|||
// 查询机构及父级机构
|
|||
List<OptDeptMaCodeEntity> deptList = baseDao.selectListDeptAndParents(deptId, pids.split(StrConstant.COMMA)); |
|||
if (CollUtil.isEmpty(deptList)) { |
|||
return null; |
|||
} |
|||
int size = deptList.size(); |
|||
|
|||
String[] allDeptIds = new String[size]; |
|||
String[] allDeptNames = new String[size]; |
|||
String[] parentDeptIds = new String[size - NumConstant.ONE]; |
|||
String[] parentDeptNames = new String[size - NumConstant.ONE]; |
|||
for (int i = 0; i < size; i++) { |
|||
allDeptIds[i] = String.valueOf(deptList.get(i).getGridId()); |
|||
allDeptNames[i] = deptList.get(i).getGrid(); |
|||
if (i < size - NumConstant.ONE) { |
|||
parentDeptIds[i] = String.valueOf(deptList.get(i).getGridId()); |
|||
parentDeptNames[i] = deptList.get(i).getGrid(); |
|||
} |
|||
} |
|||
OptDeptMaCodeEntity deptMaCodeEntity = deptList.get(size - NumConstant.ONE); |
|||
deptMaCodeEntity.setLeaderFlag(YesOrNoEnum.NO.value()); |
|||
deptMaCodeEntity.setAllDeptIds(StringUtils.join(allDeptIds, StrConstant.COMMA)); |
|||
deptMaCodeEntity.setParentDeptIds(StringUtils.join(parentDeptIds, StrConstant.COMMA)); |
|||
deptMaCodeEntity.setAllDeptNames(StringUtils.join(allDeptNames, StrConstant.HYPHEN)); |
|||
deptMaCodeEntity.setParentDeptNames(StringUtils.join(parentDeptNames, StrConstant.HYPHEN)); |
|||
return deptMaCodeEntity; |
|||
} |
|||
|
|||
@Override |
|||
public List<DeptMaCodeDTO> list(Map<String, Object> params) { |
|||
List<OptDeptMaCodeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, DeptMaCodeDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<OptDeptMaCodeEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<OptDeptMaCodeEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public DeptMaCodeDTO get(String id) { |
|||
OptDeptMaCodeEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, DeptMaCodeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(DeptMaCodeDTO dto) { |
|||
OptDeptMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, OptDeptMaCodeEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(DeptMaCodeDTO dto) { |
|||
OptDeptMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, OptDeptMaCodeEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
|
|||
mybatis-plus: |
|||
mapper-locations: classpath:/mapper/**/*.xml |
|||
#实体扫描,多个package用逗号或者分号分隔 |
|||
typeAliasesPackage: com.elink.esua.epdc.optimize.modules.*.entity |
|||
global-config: |
|||
#数据库相关配置 |
|||
db-config: |
|||
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
|||
id-type: ID_WORKER |
|||
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
|||
field-strategy: NOT_NULL |
|||
#驼峰下划线转换 |
|||
column-underline: true |
|||
#db-type: mysql |
|||
#刷新mapper 调试神器 |
|||
refresh-mapper: true |
|||
banner: false |
|||
#原生配置 |
|||
configuration: |
|||
map-underscore-to-camel-case: true |
|||
cache-enabled: false |
|||
call-setters-on-nulls: true |
|||
jdbc-type-for-null: 'null' |
|||
|
@ -0,0 +1,32 @@ |
|||
<?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.elink.esua.epdc.optimize.modules.macode.dao.OptDeptMaCodeDao"> |
|||
|
|||
<select id="selectListDeptIdByTypeKey" |
|||
resultType="com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity"> |
|||
SELECT t.id as gridId,t.pids as parentDeptIds |
|||
FROM sys_dept t WHERE t.type_key = #{typeKey} |
|||
AND NOT EXISTS (SELECT 1 FROM epdc_dept_ma_code_copy1 c WHERE c.GRID_ID = t.id) |
|||
<if test="dataScopeDeptIds != null and dataScopeDeptIds.size() > 0"> |
|||
AND t.id IN <foreach collection="dataScopeDeptIds" open="(" separator="," close=")" item="deptId">#{deptId}</foreach> |
|||
</if> |
|||
ORDER BY t.update_date ASC; |
|||
</select> |
|||
|
|||
<select id="selectListDeptAndParents" |
|||
resultType="com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity"> |
|||
SELECT |
|||
t.id as gridId, t.`name` as grid |
|||
FROM |
|||
sys_dept t |
|||
WHERE |
|||
t.id = #{deptId} |
|||
<if test="parentIds != null and parentIds.size() > 0"> |
|||
OR t.id IN <foreach collection="parentIds" open="(" separator="," close=")" item="parentId">#{parentId}</foreach> |
|||
</if> |
|||
ORDER BY t.update_date ASC; |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue