【org】【position】更新模块实体和数据库对应

pull/3/head
fengshuonan 2020-12-20 17:41:55 +08:00
parent ffd0f854e9
commit 43cd3574c1
12 changed files with 168 additions and 168 deletions

View File

@ -18,7 +18,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysOrganizationRequest extends BaseRequest {
public class HrOrganizationRequest extends BaseRequest {
/**
*

View File

@ -18,7 +18,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysPositionRequest extends BaseRequest {
public class HrPositionRequest extends BaseRequest {
/**
*

View File

@ -5,8 +5,8 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.system.modular.organization.service.SysOrganizationService;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysOrganizationRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@ -21,10 +21,10 @@ import javax.annotation.Resource;
*/
@RestController
@ApiResource(name = "系统组织机构管理")
public class SysOrganizationController {
public class HrOrganizationController {
@Resource
private SysOrganizationService sysorganizationService;
private HrOrganizationService hrOrganizationService;
/**
*
@ -32,9 +32,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@PostResource(name = "添加系统组织机构", path = "/sysOrganization/add")
public ResponseData add(@RequestBody @Validated(SysOrganizationRequest.add.class) SysOrganizationRequest sysOrganizationRequest) {
sysorganizationService.add(sysOrganizationRequest);
@PostResource(name = "添加系统组织机构", path = "/hrOrganization/add")
public ResponseData add(@RequestBody @Validated(HrOrganizationRequest.add.class) HrOrganizationRequest hrOrganizationRequest) {
hrOrganizationService.add(hrOrganizationRequest);
return new SuccessResponseData();
}
@ -44,9 +44,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@PostResource(name = "编辑系统组织机构", path = "/sysOrganization/edit")
public ResponseData edit(@RequestBody @Validated(SysOrganizationRequest.edit.class) SysOrganizationRequest sysOrganizationRequest) {
sysorganizationService.edit(sysOrganizationRequest);
@PostResource(name = "编辑系统组织机构", path = "/hrOrganization/edit")
public ResponseData edit(@RequestBody @Validated(HrOrganizationRequest.edit.class) HrOrganizationRequest hrOrganizationRequest) {
hrOrganizationService.edit(hrOrganizationRequest);
return new SuccessResponseData();
}
@ -56,9 +56,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@PostResource(name = "删除系统组织机构", path = "/sysOrganization/delete")
public ResponseData delete(@RequestBody @Validated(SysOrganizationRequest.delete.class) SysOrganizationRequest sysOrganizationRequest) {
sysorganizationService.delete(sysOrganizationRequest);
@PostResource(name = "删除系统组织机构", path = "/hrOrganization/delete")
public ResponseData delete(@RequestBody @Validated(HrOrganizationRequest.delete.class) HrOrganizationRequest hrOrganizationRequest) {
hrOrganizationService.delete(hrOrganizationRequest);
return new SuccessResponseData();
}
@ -68,9 +68,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@PostResource(name = "修改组织机构状态", path = "/sysOrganization/updateStatus")
public ResponseData updateStatus(@RequestBody @Validated(SysOrganizationRequest.updateStatus.class) SysOrganizationRequest sysOrganizationRequest) {
sysorganizationService.updateStatus(sysOrganizationRequest);
@PostResource(name = "修改组织机构状态", path = "/hrOrganization/updateStatus")
public ResponseData updateStatus(@RequestBody @Validated(HrOrganizationRequest.updateStatus.class) HrOrganizationRequest hrOrganizationRequest) {
hrOrganizationService.updateStatus(hrOrganizationRequest);
return new SuccessResponseData();
}
@ -80,9 +80,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "查看详情系统组织机构", path = "/sysOrganization/detail")
public ResponseData detail(@Validated(SysOrganizationRequest.detail.class) SysOrganizationRequest sysOrganizationRequest) {
return new SuccessResponseData(sysorganizationService.detail(sysOrganizationRequest));
@GetResource(name = "查看详情系统组织机构", path = "/hrOrganization/detail")
public ResponseData detail(@Validated(HrOrganizationRequest.detail.class) HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.detail(hrOrganizationRequest));
}
/**
@ -91,9 +91,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "分页查询系统组织机构", path = "/sysOrganization/page")
public ResponseData page(SysOrganizationRequest sysOrganizationRequest) {
return new SuccessResponseData(sysorganizationService.page(sysOrganizationRequest));
@GetResource(name = "分页查询系统组织机构", path = "/hrOrganization/page")
public ResponseData page(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.page(hrOrganizationRequest));
}
/**
@ -102,9 +102,9 @@ public class SysOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "获取全部系统组织机构", path = "/sysOrganization/list")
public ResponseData list(SysOrganizationRequest sysOrganizationRequest) {
return new SuccessResponseData(sysorganizationService.list(sysOrganizationRequest));
@GetResource(name = "获取全部系统组织机构", path = "/hrOrganization/list")
public ResponseData list(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.list(hrOrganizationRequest));
}

View File

@ -6,8 +6,8 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.system.modular.organization.service.SysPositionService;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysPositionRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrPositionService;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@ -22,10 +22,10 @@ import javax.annotation.Resource;
*/
@RestController
@ApiResource(name = "系统职位管理")
public class SysPositionController {
public class HrPositionController {
@Resource
private SysPositionService syspositionService;
private HrPositionService syspositionService;
/**
*
@ -34,8 +34,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@PostResource(name = "添加系统职位", path = "/sysPosition/add")
public ResponseData add(@RequestBody @Validated(SysPositionRequest.add.class) SysPositionRequest sysPositionRequest) {
syspositionService.add(sysPositionRequest);
public ResponseData add(@RequestBody @Validated(HrPositionRequest.add.class) HrPositionRequest hrPositionRequest) {
syspositionService.add(hrPositionRequest);
return new SuccessResponseData();
}
@ -46,8 +46,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@PostResource(name = "编辑系统职位", path = "/sysPosition/edit")
public ResponseData edit(@RequestBody @Validated(SysPositionRequest.edit.class) SysPositionRequest sysPositionRequest) {
syspositionService.edit(sysPositionRequest);
public ResponseData edit(@RequestBody @Validated(HrPositionRequest.edit.class) HrPositionRequest hrPositionRequest) {
syspositionService.edit(hrPositionRequest);
return new SuccessResponseData();
}
@ -58,8 +58,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@PostResource(name = "删除系统职位", path = "/sysPosition/delete")
public ResponseData delete(@RequestBody @Validated(SysPositionRequest.delete.class) SysPositionRequest sysPositionRequest) {
syspositionService.delete(sysPositionRequest);
public ResponseData delete(@RequestBody @Validated(HrPositionRequest.delete.class) HrPositionRequest hrPositionRequest) {
syspositionService.delete(hrPositionRequest);
return new SuccessResponseData();
}
@ -70,8 +70,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@PostResource(name = "更新职位状态", path = "/sysPosition/updateStatus")
public ResponseData updateStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) SysPositionRequest sysPositionRequest) {
syspositionService.updateStatus(sysPositionRequest);
public ResponseData updateStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) HrPositionRequest hrPositionRequest) {
syspositionService.updateStatus(hrPositionRequest);
return new SuccessResponseData();
}
@ -82,8 +82,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@GetResource(name = "查看详情系统职位", path = "/sysPosition/detail")
public ResponseData detail(@Validated(SysPositionRequest.detail.class) SysPositionRequest sysPositionRequest) {
return new SuccessResponseData(syspositionService.detail(sysPositionRequest));
public ResponseData detail(@Validated(HrPositionRequest.detail.class) HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(syspositionService.detail(hrPositionRequest));
}
/**
@ -93,8 +93,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@GetResource(name = "分页查询系统职位", path = "/sysPosition/page")
public ResponseData page(SysPositionRequest sysPositionRequest) {
return new SuccessResponseData(syspositionService.page(sysPositionRequest));
public ResponseData page(HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(syspositionService.page(hrPositionRequest));
}
/**
@ -104,8 +104,8 @@ public class SysPositionController {
* @date 2020/11/04 11:07
*/
@GetResource(name = "获取全部系统职位", path = "/sysPosition/list")
public ResponseData list(SysPositionRequest sysPositionRequest) {
return new SuccessResponseData(syspositionService.list(sysPositionRequest));
public ResponseData list(HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(syspositionService.list(hrPositionRequest));
}
}

View File

@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author fengshuonan
* @date 2020/11/04 11:05
*/
public interface SysOrganizationMapper extends BaseMapper<HrOrganization> {
public interface HrOrganizationMapper extends BaseMapper<HrOrganization> {
}

View File

@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author fengshuonan
* @date 2020/11/04 11:07
*/
public interface SysPositionMapper extends BaseMapper<HrPosition> {
public interface HrPositionMapper extends BaseMapper<HrPosition> {
}

View File

@ -1,5 +1,5 @@
<?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="cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysOrganizationMapper">
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrganizationMapper">
</mapper>

View File

@ -1,5 +1,5 @@
<?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="cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysPositionMapper">
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrPositionMapper">
</mapper>

View File

@ -3,7 +3,7 @@ package cn.stylefeng.roses.kernel.system.modular.organization.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.tree.DefaultTreeNode;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysOrganizationRequest;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationRequest;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -15,83 +15,83 @@ import java.util.Set;
* @author fengshuonan
* @date 2020/11/04 11:05
*/
public interface SysOrganizationService extends IService<HrOrganization> {
public interface HrOrganizationService extends IService<HrOrganization> {
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @author fengshuonan
* @date 2020/11/04 11:05
*/
void add(SysOrganizationRequest sysOrganizationRequest);
void add(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @author fengshuonan
* @date 2020/11/04 11:05
*/
void edit(SysOrganizationRequest sysOrganizationRequest);
void edit(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @author fengshuonan
* @date 2020/11/04 11:05
*/
void delete(SysOrganizationRequest sysOrganizationRequest);
void delete(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @author fengshuonan
* @date 2020/11/18 22:38
*/
void updateStatus(SysOrganizationRequest sysOrganizationRequest);
void updateStatus(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:05
*/
HrOrganization detail(SysOrganizationRequest sysOrganizationRequest);
HrOrganization detail(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:05
*/
PageResult<HrOrganization> page(SysOrganizationRequest sysOrganizationRequest);
PageResult<HrOrganization> page(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:05
*/
List<HrOrganization> list(SysOrganizationRequest sysOrganizationRequest);
List<HrOrganization> list(HrOrganizationRequest hrOrganizationRequest);
/**
*
*
* @param sysOrganizationRequest
* @param hrOrganizationRequest
* @return
* @author fengshuonan
* @date 2020/11/6 13:41
*/
List<DefaultTreeNode> tree(SysOrganizationRequest sysOrganizationRequest);
List<DefaultTreeNode> tree(HrOrganizationRequest hrOrganizationRequest);
/**
* idid

View File

@ -2,7 +2,7 @@ package cn.stylefeng.roses.kernel.system.modular.organization.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysPositionRequest;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -13,73 +13,73 @@ import java.util.List;
* @author fengshuonan
* @date 2020/11/04 11:07
*/
public interface SysPositionService extends IService<HrPosition> {
public interface HrPositionService extends IService<HrPosition> {
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @author fengshuonan
* @date 2020/11/04 11:07
*/
void add(SysPositionRequest sysPositionRequest);
void add(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @author fengshuonan
* @date 2020/11/04 11:07
*/
void edit(SysPositionRequest sysPositionRequest);
void edit(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @author fengshuonan
* @date 2020/11/04 11:07
*/
void delete(SysPositionRequest sysPositionRequest);
void delete(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @author fengshuonan
* @date 2020/11/18 23:00
*/
void updateStatus(SysPositionRequest sysPositionRequest);
void updateStatus(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:07
*/
HrPosition detail(SysPositionRequest sysPositionRequest);
HrPosition detail(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:07
*/
PageResult<HrPosition> page(SysPositionRequest sysPositionRequest);
PageResult<HrPosition> page(HrPositionRequest hrPositionRequest);
/**
*
*
* @param sysPositionRequest
* @param hrPositionRequest
* @return
* @author fengshuonan
* @date 2020/11/04 11:07
*/
List<HrPosition> list(SysPositionRequest sysPositionRequest);
List<HrPosition> list(HrPositionRequest hrPositionRequest);
/**
* id

View File

@ -23,9 +23,9 @@ import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.exception.enums.DataScopeExceptionEnum;
import cn.stylefeng.roses.kernel.system.exception.enums.OrganizationExceptionEnum;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysOrganizationMapper;
import cn.stylefeng.roses.kernel.system.modular.organization.service.SysOrganizationService;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysOrganizationRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrOrganizationMapper;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrOrganizationRequest;
import cn.stylefeng.roses.kernel.system.util.DataScopeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -46,7 +46,7 @@ import java.util.Set;
* @date 2020/11/04 11:05
*/
@Service
public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMapper, HrOrganization> implements SysOrganizationService {
public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper, HrOrganization> implements HrOrganizationService {
@Resource
private UserOrgServiceApi userOrgServiceApi;
@ -58,10 +58,10 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
private UserServiceApi userServiceApi;
@Override
public void add(SysOrganizationRequest sysOrganizationRequest) {
public void add(HrOrganizationRequest hrOrganizationRequest) {
// 获取父id
Long pid = sysOrganizationRequest.getOrgParentId();
Long pid = hrOrganizationRequest.getOrgParentId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(pid)) {
@ -69,23 +69,23 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
throw new SystemModularException(DataScopeExceptionEnum.DATA_SCOPE_ERROR, userTip);
}
HrOrganization sysOrganization = new HrOrganization();
BeanUtil.copyProperties(sysOrganizationRequest, sysOrganization);
HrOrganization hrOrganization = new HrOrganization();
BeanUtil.copyProperties(hrOrganizationRequest, hrOrganization);
// 填充parentIds
this.fillParentIds(sysOrganization);
this.fillParentIds(hrOrganization);
// 设置状态为启用,未删除状态
sysOrganization.setStatusFlag(StatusEnum.ENABLE.getCode());
hrOrganization.setStatusFlag(StatusEnum.ENABLE.getCode());
this.save(sysOrganization);
this.save(hrOrganization);
}
@Override
public void edit(SysOrganizationRequest sysOrganizationRequest) {
public void edit(HrOrganizationRequest hrOrganizationRequest) {
HrOrganization sysOrganization = this.querySysOrganization(sysOrganizationRequest);
Long id = sysOrganization.getOrgId();
HrOrganization hrOrganization = this.queryOrganization(hrOrganizationRequest);
Long id = hrOrganization.getOrgId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(id)) {
@ -93,24 +93,24 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
throw new SystemModularException(DataScopeExceptionEnum.DATA_SCOPE_ERROR, userTip);
}
BeanUtil.copyProperties(sysOrganizationRequest, sysOrganization);
BeanUtil.copyProperties(hrOrganizationRequest, hrOrganization);
// 填充parentIds
this.fillParentIds(sysOrganization);
this.fillParentIds(hrOrganization);
// 不能修改状态,用修改状态接口修改状态
sysOrganization.setStatusFlag(null);
hrOrganization.setStatusFlag(null);
// 更新这条记录
this.updateById(sysOrganization);
this.updateById(hrOrganization);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(SysOrganizationRequest sysOrganizationRequest) {
public void delete(HrOrganizationRequest hrOrganizationRequest) {
HrOrganization sysOrganization = this.querySysOrganization(sysOrganizationRequest);
Long organizationId = sysOrganization.getOrgId();
HrOrganization hrOrganization = this.queryOrganization(hrOrganizationRequest);
Long organizationId = hrOrganization.getOrgId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(organizationId)) {
@ -140,25 +140,25 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
}
@Override
public void updateStatus(SysOrganizationRequest sysOrganizationRequest) {
public void updateStatus(HrOrganizationRequest hrOrganizationRequest) {
LambdaUpdateWrapper<HrOrganization> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(HrOrganization::getOrgId, sysOrganizationRequest.getOrgId());
updateWrapper.set(HrOrganization::getStatusFlag, sysOrganizationRequest.getStatusFlag());
updateWrapper.eq(HrOrganization::getOrgId, hrOrganizationRequest.getOrgId());
updateWrapper.set(HrOrganization::getStatusFlag, hrOrganizationRequest.getStatusFlag());
this.update(updateWrapper);
}
@Override
public HrOrganization detail(SysOrganizationRequest sysOrganizationRequest) {
return this.querySysOrganization(sysOrganizationRequest);
public HrOrganization detail(HrOrganizationRequest hrOrganizationRequest) {
return this.queryOrganization(hrOrganizationRequest);
}
@Override
public PageResult<HrOrganization> page(SysOrganizationRequest sysOrganizationRequest) {
public PageResult<HrOrganization> page(HrOrganizationRequest hrOrganizationRequest) {
// 构造条件
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(sysOrganizationRequest);
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
// 获取分页参数
Page<HrOrganization> page = PageFactory.defaultPage();
@ -168,16 +168,16 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
}
@Override
public List<HrOrganization> list(SysOrganizationRequest sysOrganizationRequest) {
public List<HrOrganization> list(HrOrganizationRequest hrOrganizationRequest) {
// 构造条件
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(sysOrganizationRequest);
LambdaQueryWrapper<HrOrganization> wrapper = createWrapper(hrOrganizationRequest);
return this.list(wrapper);
}
@Override
public List<DefaultTreeNode> tree(SysOrganizationRequest sysOrganizationRequest) {
public List<DefaultTreeNode> tree(HrOrganizationRequest hrOrganizationRequest) {
// 定义返回结果
List<DefaultTreeNode> treeNodeList = CollectionUtil.newArrayList();
@ -217,12 +217,12 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
// 组装节点
List<HrOrganization> list = this.list(queryWrapper);
for (HrOrganization sysOrganization : list) {
for (HrOrganization hrOrganization : list) {
DefaultTreeNode orgTreeNode = new DefaultTreeNode();
orgTreeNode.setId(String.valueOf(sysOrganization.getOrgId()));
orgTreeNode.setPId(String.valueOf(sysOrganization.getOrgParentId()));
orgTreeNode.setName(sysOrganization.getOrgName());
orgTreeNode.setSort(sysOrganization.getOrgSort());
orgTreeNode.setId(String.valueOf(hrOrganization.getOrgId()));
orgTreeNode.setPId(String.valueOf(hrOrganization.getOrgParentId()));
orgTreeNode.setName(hrOrganization.getOrgName());
orgTreeNode.setSort(hrOrganization.getOrgSort());
treeNodeList.add(orgTreeNode);
}
@ -247,10 +247,10 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
}
// 把所有的pids分割并放入到set中
for (HrOrganization sysOrganization : organizationList) {
for (HrOrganization hrOrganization : organizationList) {
// 获取pids值
String pids = sysOrganization.getOrgPids();
String pids = hrOrganization.getOrgPids();
// 去掉所有的左中括号
String cutLeft = StrUtil.removeAll(pids, SystemConstants.PID_LEFT_DIVIDE_SYMBOL);
@ -276,26 +276,26 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
* @author fengshuonan
* @date 2020/11/6 10:16
*/
private LambdaQueryWrapper<HrOrganization> createWrapper(SysOrganizationRequest sysOrganizationRequest) {
private LambdaQueryWrapper<HrOrganization> createWrapper(HrOrganizationRequest hrOrganizationRequest) {
LambdaQueryWrapper<HrOrganization> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotNull(sysOrganizationRequest)) {
if (ObjectUtil.isNotNull(hrOrganizationRequest)) {
// 拼接机构名称查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgName())) {
queryWrapper.like(HrOrganization::getOrgName, sysOrganizationRequest.getOrgName());
if (ObjectUtil.isNotEmpty(hrOrganizationRequest.getOrgName())) {
queryWrapper.like(HrOrganization::getOrgName, hrOrganizationRequest.getOrgName());
}
// 拼接机构id查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgId())) {
queryWrapper.eq(HrOrganization::getOrgId, sysOrganizationRequest.getOrgId());
if (ObjectUtil.isNotEmpty(hrOrganizationRequest.getOrgId())) {
queryWrapper.eq(HrOrganization::getOrgId, hrOrganizationRequest.getOrgId());
}
// 拼接父机构id查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgParentId())) {
if (ObjectUtil.isNotEmpty(hrOrganizationRequest.getOrgParentId())) {
queryWrapper
.eq(HrOrganization::getOrgId, sysOrganizationRequest.getOrgParentId())
.eq(HrOrganization::getOrgId, hrOrganizationRequest.getOrgParentId())
.or()
.like(HrOrganization::getOrgPids, sysOrganizationRequest.getOrgParentId());
.like(HrOrganization::getOrgPids, hrOrganizationRequest.getOrgParentId());
}
}
@ -315,12 +315,12 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
* @author fengshuonan
* @date 2020/11/04 11:05
*/
private HrOrganization querySysOrganization(SysOrganizationRequest sysOrganizationRequest) {
HrOrganization sysorganization = this.getById(sysOrganizationRequest.getOrgId());
if (ObjectUtil.isEmpty(sysorganization)) {
private HrOrganization queryOrganization(HrOrganizationRequest hrOrganizationRequest) {
HrOrganization hrOrganization = this.getById(hrOrganizationRequest.getOrgId());
if (ObjectUtil.isEmpty(hrOrganization)) {
throw new SystemModularException(OrganizationExceptionEnum.CANT_FIND_ORG);
}
return sysorganization;
return hrOrganization;
}
/**
@ -329,19 +329,19 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
* @author fengshuonan
* @date 2020/11/5 13:45
*/
private void fillParentIds(HrOrganization sysOrganization) {
private void fillParentIds(HrOrganization hrOrganization) {
// 如果是一级节点一级节点的pid是0
if (sysOrganization.getOrgParentId().equals(SystemConstants.DEFAULT_PARENT_ID)) {
if (hrOrganization.getOrgParentId().equals(SystemConstants.DEFAULT_PARENT_ID)) {
// 设置一级节点的pid为[0],
sysOrganization.setOrgPids(SystemConstants.PID_LEFT_DIVIDE_SYMBOL + SystemConstants.DEFAULT_PARENT_ID + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
hrOrganization.setOrgPids(SystemConstants.PID_LEFT_DIVIDE_SYMBOL + SystemConstants.DEFAULT_PARENT_ID + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
} else {
// 获取父组织机构
HrOrganization parentSysOrganization = this.getById(sysOrganization.getOrgParentId());
HrOrganization parentOrganization = this.getById(hrOrganization.getOrgParentId());
// 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) )
sysOrganization.setOrgPids(
parentSysOrganization.getOrgPids() + SystemConstants.PID_LEFT_DIVIDE_SYMBOL + parentSysOrganization.getOrgId() + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
hrOrganization.setOrgPids(
parentOrganization.getOrgPids() + SystemConstants.PID_LEFT_DIVIDE_SYMBOL + parentOrganization.getOrgId() + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
}
}

View File

@ -12,9 +12,9 @@ import cn.stylefeng.roses.kernel.system.UserOrgServiceApi;
import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.exception.enums.PositionExceptionEnum;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysPositionMapper;
import cn.stylefeng.roses.kernel.system.modular.organization.service.SysPositionService;
import cn.stylefeng.roses.kernel.system.pojo.organization.SysPositionRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.mapper.HrPositionMapper;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrPositionService;
import cn.stylefeng.roses.kernel.system.pojo.organization.HrPositionRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -33,15 +33,15 @@ import java.util.stream.Collectors;
* @date 2020/11/04 11:07
*/
@Service
public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPosition> implements SysPositionService {
public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosition> implements HrPositionService {
@Resource
private UserOrgServiceApi userOrgServiceApi;
@Override
public void add(SysPositionRequest sysPositionRequest) {
public void add(HrPositionRequest hrPositionRequest) {
HrPosition sysPosition = new HrPosition();
BeanUtil.copyProperties(sysPositionRequest, sysPosition);
BeanUtil.copyProperties(hrPositionRequest, sysPosition);
// 设置状态为启用
sysPosition.setStatusFlag(StatusEnum.ENABLE.getCode());
@ -50,10 +50,10 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPos
}
@Override
public void edit(SysPositionRequest sysPositionRequest) {
public void edit(HrPositionRequest hrPositionRequest) {
HrPosition sysPosition = this.querySysPosition(sysPositionRequest);
BeanUtil.copyProperties(sysPositionRequest, sysPosition);
HrPosition sysPosition = this.querySysPosition(hrPositionRequest);
BeanUtil.copyProperties(hrPositionRequest, sysPosition);
// 不能修改状态,用修改状态接口修改状态
sysPosition.setStatusFlag(null);
@ -63,9 +63,9 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPos
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(SysPositionRequest sysPositionRequest) {
public void delete(HrPositionRequest hrPositionRequest) {
HrPosition sysPosition = this.querySysPosition(sysPositionRequest);
HrPosition sysPosition = this.querySysPosition(hrPositionRequest);
// 该职位下是否有员工
// 职位有绑定员工,不能删除
@ -81,30 +81,30 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPos
}
@Override
public void updateStatus(SysPositionRequest sysPositionRequest) {
public void updateStatus(HrPositionRequest hrPositionRequest) {
LambdaUpdateWrapper<HrPosition> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(HrPosition::getPositionId, sysPositionRequest.getPositionId());
updateWrapper.set(HrPosition::getStatusFlag, sysPositionRequest.getStatusFlag());
updateWrapper.eq(HrPosition::getPositionId, hrPositionRequest.getPositionId());
updateWrapper.set(HrPosition::getStatusFlag, hrPositionRequest.getStatusFlag());
this.update(updateWrapper);
}
@Override
public HrPosition detail(SysPositionRequest sysPositionRequest) {
return this.querySysPosition(sysPositionRequest);
public HrPosition detail(HrPositionRequest hrPositionRequest) {
return this.querySysPosition(hrPositionRequest);
}
@Override
public PageResult<HrPosition> page(SysPositionRequest sysPositionRequest) {
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(sysPositionRequest);
public PageResult<HrPosition> page(HrPositionRequest hrPositionRequest) {
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(hrPositionRequest);
Page<HrPosition> page = this.page(PageFactory.defaultPage(), wrapper);
return PageResultFactory.createPageResult(page);
}
@Override
public List<HrPosition> list(SysPositionRequest sysPositionRequest) {
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(sysPositionRequest);
public List<HrPosition> list(HrPositionRequest hrPositionRequest) {
LambdaQueryWrapper<HrPosition> wrapper = createWrapper(hrPositionRequest);
return this.list(wrapper);
}
@ -129,18 +129,18 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPos
* @author fengshuonan
* @date 2020/11/6 18:35
*/
private LambdaQueryWrapper<HrPosition> createWrapper(SysPositionRequest sysPositionRequest) {
private LambdaQueryWrapper<HrPosition> createWrapper(HrPositionRequest hrPositionRequest) {
LambdaQueryWrapper<HrPosition> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotNull(sysPositionRequest)) {
if (ObjectUtil.isNotNull(hrPositionRequest)) {
// 拼接职位名称条件
if (ObjectUtil.isNotEmpty(sysPositionRequest.getPositionName())) {
queryWrapper.like(HrPosition::getPositionName, sysPositionRequest.getPositionName());
if (ObjectUtil.isNotEmpty(hrPositionRequest.getPositionName())) {
queryWrapper.like(HrPosition::getPositionName, hrPositionRequest.getPositionName());
}
// 拼接职位编码条件
if (ObjectUtil.isNotEmpty(sysPositionRequest.getPositionCode())) {
queryWrapper.eq(HrPosition::getPositionCode, sysPositionRequest.getPositionCode());
if (ObjectUtil.isNotEmpty(hrPositionRequest.getPositionCode())) {
queryWrapper.eq(HrPosition::getPositionCode, hrPositionRequest.getPositionCode());
}
}
@ -159,8 +159,8 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, HrPos
* @author fengshuonan
* @date 2020/11/18 22:59
*/
private HrPosition querySysPosition(SysPositionRequest sysPositionRequest) {
HrPosition sysposition = this.getById(sysPositionRequest.getPositionId());
private HrPosition querySysPosition(HrPositionRequest hrPositionRequest) {
HrPosition sysposition = this.getById(hrPositionRequest.getPositionId());
if (ObjectUtil.isEmpty(sysposition)) {
String userTip = StrUtil.format(PositionExceptionEnum.CANT_FIND_POSITION.getUserTip(), sysposition.getPositionId());
throw new SystemModularException(PositionExceptionEnum.CANT_FIND_POSITION, userTip);