diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java index 17b7c21b99..13b7d37057 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java @@ -54,6 +54,7 @@ public enum RequirePermissionEnum { ORG_STAFF_CREATE("org_staff_create", "组织:工作人员:新增", "组织:工作人员:新增"), ORG_STAFF_UPDATE("org_staff_update", "组织:工作人员:编辑", "组织:工作人员:编辑"), ORG_STAFF_FORBIDDEN("org_staff_forbidden", "组织:工作人员:禁用", "组织:工作人员:禁用"), + ORG_STAFF_ENABLE("org_staff_enable", "组织:工作人员:解禁", "组织:工作人员:解禁"), ORG_STAFF_TRANSFER("org_staff_transfer", "组织:工作人员:调动", "组织:工作人员:调动"), /** diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 52d33309e4..25a944403b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -211,9 +211,10 @@ public class EpmetUserController { * @Description 通讯录】姓名检索工作人员 * @author sun */ - @PostMapping("stafflist") - public Result> staffList(@RequestBody ListStaffFormDTO formDTO) { + @PostMapping("stafflistbyrealname") + public Result> staffListByRealName(@LoginUser TokenDto tokenDto, @RequestBody ListStaffFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, ListStaffFormDTO.Staff.class); + formDTO.setCustomerId(formDTO.getCustomerId()); return new Result>().ok(epmetUserService.listStaff(formDTO)); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffOrgRelationDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffOrgRelationDTO.java new file mode 100644 index 0000000000..9e29a92560 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffOrgRelationDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@Data +public class StaffOrgRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所有上级组织机构ID(以英文:隔开)部门/网格得拼上所属组织Id + */ + private String pids; + + /** + * 工作人员Id + */ + private String staffId; + + /** + * 工作人员添加入口Id(agencyId;deptId;gridId) + */ + private String orgId; + + /** + * 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + */ + private String orgType; + + /** + * 删除标识 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffOrgRelationController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffOrgRelationController.java new file mode 100644 index 0000000000..065ad9d578 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffOrgRelationController.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.StaffOrgRelationDTO; +import com.epmet.service.StaffOrgRelationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@RestController +@RequestMapping("stafforgrelation") +public class StaffOrgRelationController { + + @Autowired + private StaffOrgRelationService staffOrgRelationService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = staffOrgRelationService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + StaffOrgRelationDTO data = staffOrgRelationService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody StaffOrgRelationDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + staffOrgRelationService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody StaffOrgRelationDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + staffOrgRelationService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + staffOrgRelationService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffOrgRelationDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffOrgRelationDao.java new file mode 100644 index 0000000000..a4d6610658 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/StaffOrgRelationDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.StaffOrgRelationEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@Mapper +public interface StaffOrgRelationDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/StaffOrgRelationEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/StaffOrgRelationEntity.java new file mode 100644 index 0000000000..f9c31b49d9 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/StaffOrgRelationEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("staff_org_relation") +public class StaffOrgRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所有上级组织机构ID(以英文:隔开)部门/网格得拼上所属组织Id + */ + private String pids; + + /** + * 工作人员Id + */ + private String staffId; + + /** + * 工作人员添加入口Id(agencyId;deptId;gridId) + */ + private String orgId; + + /** + * 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + */ + private String orgType; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffOrgRelationService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffOrgRelationService.java new file mode 100644 index 0000000000..ce5d6ba496 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffOrgRelationService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.StaffOrgRelationDTO; +import com.epmet.entity.StaffOrgRelationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +public interface StaffOrgRelationService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-08-19 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-08-19 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return StaffOrgRelationDTO + * @author generator + * @date 2021-08-19 + */ + StaffOrgRelationDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-08-19 + */ + void save(StaffOrgRelationDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-08-19 + */ + void update(StaffOrgRelationDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-08-19 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffOrgRelationServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffOrgRelationServiceImpl.java new file mode 100644 index 0000000000..a4e528a1cc --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffOrgRelationServiceImpl.java @@ -0,0 +1,100 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.StaffOrgRelationDao; +import com.epmet.dto.StaffOrgRelationDTO; +import com.epmet.entity.StaffOrgRelationEntity; +import com.epmet.service.StaffOrgRelationService; +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 generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@Service +public class StaffOrgRelationServiceImpl extends BaseServiceImpl implements StaffOrgRelationService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StaffOrgRelationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StaffOrgRelationDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public StaffOrgRelationDTO get(String id) { + StaffOrgRelationEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StaffOrgRelationDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StaffOrgRelationDTO dto) { + StaffOrgRelationEntity entity = ConvertUtils.sourceToTarget(dto, StaffOrgRelationEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StaffOrgRelationDTO dto) { + StaffOrgRelationEntity entity = ConvertUtils.sourceToTarget(dto, StaffOrgRelationEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index 2004327484..2c9bcd51b0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -66,6 +66,8 @@ public class StaffServiceImpl implements StaffService { private CustomerStaffDepartmentService customerStaffDepartmentService; @Autowired private CustomerStaffGridService customerStaffGridService; + @Autowired + private StaffOrgRelationService staffOrgRelationService; @Override public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { @@ -374,6 +376,19 @@ public class StaffServiceImpl implements StaffService { customerGridService.updateById(gridEntity); } + //5.工作人员注册组织关系表新增数据 + StaffOrgRelationEntity staffOrgRelationEntity = new StaffOrgRelationEntity(); + staffOrgRelationEntity.setCustomerId(fromDTO.getCustomerId()); + if("agency".equals(fromDTO.getOrgType())){ + staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":")); + }else { + staffOrgRelationEntity.setPids(("".equals(orgDTO.getPids()) ? "" : orgDTO.getPids() + ":") + orgDTO.getAgencyId()); + } + staffOrgRelationEntity.setStaffId(result.getData().getUserId()); + staffOrgRelationEntity.setOrgId(fromDTO.getOrgId()); + staffOrgRelationEntity.setOrgType(fromDTO.getOrgType()); + staffOrgRelationService.insert(staffOrgRelationEntity); + return new Result(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffOrgRelationDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffOrgRelationDao.xml new file mode 100644 index 0000000000..350dae73ac --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffOrgRelationDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EnableStaffFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EnableStaffFormDTO.java index f0788499c1..beb2fae20f 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EnableStaffFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EnableStaffFormDTO.java @@ -10,7 +10,7 @@ import java.util.List; /** * @author sun - * @dscription 接口入参--【通讯录】工作人员解禁 + * @dscription 【通讯录】工作人员解禁-接口入参 */ @NoArgsConstructor @Data @@ -18,8 +18,8 @@ public class EnableStaffFormDTO implements Serializable { private static final long serialVersionUID = -5220529162950147825L; /** - * 徽章名称 + * 被解禁用户Id */ - @NotBlank(message = "徽章名称不能为空") - private String badgeName; + private String staffId; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 83dc575ed8..f467d60712 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -18,6 +18,10 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.RequirePermission; +import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; @@ -433,7 +437,11 @@ public class CustomerStaffController { * @author sun */ @PostMapping("enablestaff") - public Result enableStaff(@RequestBody EnableStaffFormDTO fromDTO){ + @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_ENABLE) + public Result enableStaff(@LoginUser TokenDto tokenDto, @RequestBody EnableStaffFormDTO fromDTO){ + if (tokenDto.getUserId().equals(fromDTO.getStaffId())) { + throw new RenException("工作人员自己不能解禁自己"); + } customerStaffService.enableStaff(fromDTO); return new Result(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 4a0bdfa05d..70962eaaa7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -744,7 +744,15 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl%s", fromDTO.getStaffId())); + throw new RenException("未查询到被解禁人信息,请核对后操作"); + } + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setEnableFlag(CustomerStaffConstant.ENABLE); + baseDao.updateById(staffEntity); } }