feat:增加职位管理功能
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.tiesheng.core.service.JobService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class TestJobConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
JobService jobService;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
jobService.refreshPoint("230328001", "demo", "辅导员统计", "辅导员责任班级,学生展示");
|
||||||
|
|
||||||
|
// 辅导员职位
|
||||||
|
jobService.refresh("class_fdy", "辅导员", "辅导员", 1, CollUtil.newArrayList("230328001"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.tiesheng.util.pojos;
|
||||||
|
|
||||||
|
public class IdName {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra(String extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package com.tiesheng.core.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJob;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJobPoint;
|
||||||
|
import com.tiesheng.core.pojos.dto.IdDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.PageDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.job.JobUpdateDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.job.JobUpdateRxDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.job.JobUserAssignDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.job.JobUserOwner;
|
||||||
|
import com.tiesheng.core.service.JobService;
|
||||||
|
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/job")
|
||||||
|
public class JobController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
JobService jobService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取职位列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public ApiResp<List<CoreJob>> list(PageDTO dto) {
|
||||||
|
QueryWrapper<CoreJob> queryWrapper = new QueryWrapper<CoreJob>().eq("is_deleted", 0);
|
||||||
|
dto.likeColumns(queryWrapper, "name");
|
||||||
|
List<CoreJob> jobList = jobService.list(queryWrapper);
|
||||||
|
return ApiResp.respOK(jobList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加、编辑职位
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ApiResp<String> update(@Valid @RequestBody JobUpdateDTO dto) {
|
||||||
|
CoreJob job = BeanUtil.copyProperties(dto, CoreJob.class);
|
||||||
|
if (!StrUtil.isEmpty(job.getId())) {
|
||||||
|
CoreJob byId = jobService.getById(job.getId());
|
||||||
|
if (byId != null && byId.getIsSystem() == 1) {
|
||||||
|
throw new ApiException("系统配置,无法编辑");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jobService.saveOrUpdate(job);
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取职位功能点
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/point/list")
|
||||||
|
public ApiResp<List<CoreJobPoint>> pointList() {
|
||||||
|
List<CoreJobPoint> pointList = jobService.getJobPointMapper().selectList(new QueryWrapper<CoreJobPoint>()
|
||||||
|
.eq("is_deleted", 0)
|
||||||
|
);
|
||||||
|
return ApiResp.respOK(pointList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关系
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/point/rx")
|
||||||
|
public ApiResp<List<String>> pointRx(@Valid IdDTO dto) {
|
||||||
|
List<String> list = jobService.getJobPointMapper().getJobRx(dto.getId());
|
||||||
|
return ApiResp.respOK(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新职位关系
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/point/rx")
|
||||||
|
public ApiResp<String> updateJobRx(@Valid @RequestBody JobUpdateRxDTO dto) {
|
||||||
|
jobService.updateJobRx(dto.getJobId(), StrUtil.split(dto.getPoints(), ","));
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户职位分配
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/assign")
|
||||||
|
public ApiResp<String> userAssign(@Valid @RequestBody JobUserAssignDTO dto) {
|
||||||
|
jobService.userAssign(dto.getUserId(), dto.getJobId());
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户自己的
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/owner")
|
||||||
|
public ApiResp<List<JobUserOwner>> userOwner() {
|
||||||
|
List<JobUserOwner> coreJobUsers = jobService.getJobUserMapper().list(TsTokenConfig.get().getId());
|
||||||
|
coreJobUsers.forEach(it -> {
|
||||||
|
List<String> list = jobService.getJobPointMapper().getJobRx(it.getJobId());
|
||||||
|
it.setPoints(list);
|
||||||
|
});
|
||||||
|
return ApiResp.respOK(coreJobUsers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.tiesheng.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJob;
|
||||||
|
|
||||||
|
public interface CoreJobMapper extends BaseMapper<CoreJob> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.tiesheng.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJobPoint;
|
||||||
|
import com.tiesheng.util.pojos.IdName;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CoreJobPointMapper extends BaseMapper<CoreJobPoint> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除职位的关联关系
|
||||||
|
*
|
||||||
|
* @param jobId
|
||||||
|
*/
|
||||||
|
void clearJobRx(@Param("jobId") String jobId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联关系
|
||||||
|
*
|
||||||
|
* @param pointList
|
||||||
|
*/
|
||||||
|
void updateJobRx(@Param("list") List<IdName> pointList);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联的point
|
||||||
|
*
|
||||||
|
* @param jobId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getJobRx(@Param("jobId") String jobId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tiesheng.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJobUser;
|
||||||
|
import com.tiesheng.core.pojos.dto.job.JobUserOwner;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CoreJobUserMapper extends BaseMapper<CoreJobUser> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定用户的职位和功能点
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<JobUserOwner> list(@Param("userId") String userId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.tiesheng.core.pojos.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.tiesheng.core.pojos.DaoBase;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 职位
|
||||||
|
*/
|
||||||
|
@TableName(value = "core_job")
|
||||||
|
public class CoreJob extends DaoBase {
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@TableField(value = "`name`")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他说明
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否系统
|
||||||
|
*/
|
||||||
|
@TableField(value = "is_system")
|
||||||
|
private Integer isSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取名称
|
||||||
|
*
|
||||||
|
* @return name - 名称
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置名称
|
||||||
|
*
|
||||||
|
* @param name 名称
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取其他说明
|
||||||
|
*
|
||||||
|
* @return remark - 其他说明
|
||||||
|
*/
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置其他说明
|
||||||
|
*
|
||||||
|
* @param remark 其他说明
|
||||||
|
*/
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取是否系统
|
||||||
|
*
|
||||||
|
* @return is_system - 是否系统
|
||||||
|
*/
|
||||||
|
public Integer getIsSystem() {
|
||||||
|
return isSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否系统
|
||||||
|
*
|
||||||
|
* @param isSystem 是否系统
|
||||||
|
*/
|
||||||
|
public void setIsSystem(Integer isSystem) {
|
||||||
|
this.isSystem = isSystem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.tiesheng.core.pojos.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.tiesheng.core.pojos.DaoBase;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 职位-功能点
|
||||||
|
*/
|
||||||
|
@TableName(value = "core_job_point")
|
||||||
|
public class CoreJobPoint extends DaoBase {
|
||||||
|
/**
|
||||||
|
* 业务
|
||||||
|
*/
|
||||||
|
@TableField(value = "service")
|
||||||
|
private String service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@TableField(value = "`name`")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他说明
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取业务
|
||||||
|
*
|
||||||
|
* @return service - 业务
|
||||||
|
*/
|
||||||
|
public String getService() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置业务
|
||||||
|
*
|
||||||
|
* @param service 业务
|
||||||
|
*/
|
||||||
|
public void setService(String service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取名称
|
||||||
|
*
|
||||||
|
* @return name - 名称
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置名称
|
||||||
|
*
|
||||||
|
* @param name 名称
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取其他说明
|
||||||
|
*
|
||||||
|
* @return remark - 其他说明
|
||||||
|
*/
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置其他说明
|
||||||
|
*
|
||||||
|
* @param remark 其他说明
|
||||||
|
*/
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.tiesheng.core.pojos.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.tiesheng.core.pojos.DaoBase;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 职位-用户
|
||||||
|
*/
|
||||||
|
@TableName(value = "core_job_user")
|
||||||
|
public class CoreJobUser extends DaoBase {
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@TableField(value = "user_id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
*/
|
||||||
|
@TableField(value = "job_id")
|
||||||
|
private String jobId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户id
|
||||||
|
*
|
||||||
|
* @return user_id - 用户id
|
||||||
|
*/
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户id
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
*/
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户
|
||||||
|
*
|
||||||
|
* @return job_id - 用户
|
||||||
|
*/
|
||||||
|
public String getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户
|
||||||
|
*
|
||||||
|
* @param jobId 用户
|
||||||
|
*/
|
||||||
|
public void setJobId(String jobId) {
|
||||||
|
this.jobId = jobId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class IdDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "需要ID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto.job;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class JobUpdateDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@NotEmpty(message = "请输入职位名称")
|
||||||
|
private String name;
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto.job;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class JobUpdateRxDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "请选择职位")
|
||||||
|
private String jobId;
|
||||||
|
private String points;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobId(String jobId) {
|
||||||
|
this.jobId = jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(String points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto.job;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class JobUserAssignDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "请选择用户")
|
||||||
|
private String userId;
|
||||||
|
@NotEmpty(message = "请选择职位")
|
||||||
|
private String jobId;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobId(String jobId) {
|
||||||
|
this.jobId = jobId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto.job;
|
||||||
|
|
||||||
|
import com.tiesheng.util.pojos.IdName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JobUserOwner {
|
||||||
|
|
||||||
|
private String jobId;
|
||||||
|
private String jobName;
|
||||||
|
private List<String> points;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobId(String jobId) {
|
||||||
|
this.jobId = jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJobName() {
|
||||||
|
return jobName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobName(String jobName) {
|
||||||
|
this.jobName = jobName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(List<String> points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package com.tiesheng.core.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.tiesheng.core.mapper.CoreJobMapper;
|
||||||
|
import com.tiesheng.core.mapper.CoreJobPointMapper;
|
||||||
|
import com.tiesheng.core.mapper.CoreJobUserMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJob;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJobPoint;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreJobUser;
|
||||||
|
import com.tiesheng.util.pojos.IdName;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class JobService extends TsServiceBase<CoreJobMapper, CoreJob> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreJobPointMapper coreJobPointMapper;
|
||||||
|
@Autowired
|
||||||
|
CoreJobUserMapper coreJobUserMapper;
|
||||||
|
|
||||||
|
public CoreJobPointMapper getJobPointMapper() {
|
||||||
|
return coreJobPointMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreJobUserMapper getJobUserMapper() {
|
||||||
|
return coreJobUserMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新职位
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param remark
|
||||||
|
* @param isSystem
|
||||||
|
*/
|
||||||
|
public void refresh(String id, String name, String remark, Integer isSystem, List<String> points) {
|
||||||
|
CoreJob coreJob = new CoreJob();
|
||||||
|
coreJob.setId(id);
|
||||||
|
coreJob.setName(name);
|
||||||
|
coreJob.setRemark(remark);
|
||||||
|
coreJob.setIsSystem(isSystem);
|
||||||
|
saveOrUpdate(coreJob);
|
||||||
|
|
||||||
|
// 增加关联关系
|
||||||
|
updateJobRx(coreJob.getId(), points);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新功能点
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param service
|
||||||
|
* @param name
|
||||||
|
* @param remark
|
||||||
|
*/
|
||||||
|
public void refreshPoint(String id, String service, String name, String remark) {
|
||||||
|
CoreJobPoint jobPoint = new CoreJobPoint();
|
||||||
|
jobPoint.setId(id);
|
||||||
|
jobPoint.setService(service);
|
||||||
|
jobPoint.setName(name);
|
||||||
|
jobPoint.setRemark(remark);
|
||||||
|
try {
|
||||||
|
coreJobPointMapper.insert(jobPoint);
|
||||||
|
} catch (Exception e) {
|
||||||
|
coreJobPointMapper.updateById(jobPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联关系
|
||||||
|
*
|
||||||
|
* @param jobId
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
|
public void updateJobRx(String jobId, List<String> points) {
|
||||||
|
List<IdName> nameList = new ArrayList<>();
|
||||||
|
for (String s : points) {
|
||||||
|
IdName id = new IdName();
|
||||||
|
id.setId(IdUtil.getSnowflakeNextIdStr());
|
||||||
|
id.setName(jobId);
|
||||||
|
id.setExtra(s);
|
||||||
|
nameList.add(id);
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(jobId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
coreJobPointMapper.clearJobRx(jobId);
|
||||||
|
if (CollUtil.isNotEmpty(nameList)) {
|
||||||
|
coreJobPointMapper.updateJobRx(nameList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配职位
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param jobId
|
||||||
|
*/
|
||||||
|
public void userAssign(String userId, String jobId) {
|
||||||
|
CoreJobUser jobUser = coreJobUserMapper.selectOne(new QueryWrapper<CoreJobUser>()
|
||||||
|
.eq("is_deleted", 0)
|
||||||
|
.eq("user_id", userId)
|
||||||
|
.eq("job_id", jobId)
|
||||||
|
);
|
||||||
|
if (jobUser == null) {
|
||||||
|
jobUser = new CoreJobUser();
|
||||||
|
}
|
||||||
|
jobUser.setUserId(userId);
|
||||||
|
jobUser.setJobId(jobId);
|
||||||
|
if (StrUtil.isEmpty(jobUser.getId())) {
|
||||||
|
coreJobUserMapper.insert(jobUser);
|
||||||
|
} else {
|
||||||
|
coreJobUserMapper.updateById(jobUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
66
springboot-web/src/main/resources/db/migration/core_job.sql
Normal file
66
springboot-web/src/main/resources/db/migration/core_job.sql
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_job
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_job`
|
||||||
|
(
|
||||||
|
`id` varchar(50) NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||||
|
`name` varchar(255) DEFAULT NULL COMMENT '名称',
|
||||||
|
`remark` varchar(500) DEFAULT NULL COMMENT '其他说明',
|
||||||
|
`is_system` int(6) NOT NULL DEFAULT '0' COMMENT '是否系统',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='职位';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_job_point
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_job_point`
|
||||||
|
(
|
||||||
|
`id` varchar(50) NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||||
|
`service` varchar(20) DEFAULT NULL COMMENT '业务',
|
||||||
|
`name` varchar(255) DEFAULT NULL COMMENT '名称',
|
||||||
|
`remark` varchar(500) DEFAULT NULL COMMENT '其他说明',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='职位-功能点';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_job_rx
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_job_rx`
|
||||||
|
(
|
||||||
|
`id` varchar(50) NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||||
|
`job_id` varchar(50) DEFAULT NULL COMMENT '职位id',
|
||||||
|
`point_id` varchar(50) DEFAULT NULL COMMENT ' 功能点id',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='职位-功能关系';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_job_user
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_job_user`
|
||||||
|
(
|
||||||
|
`id` varchar(50) NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||||
|
`user_id` varchar(50) NOT NULL COMMENT '用户id',
|
||||||
|
`job_id` varchar(50) NOT NULL COMMENT '用户',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='职位-用户';
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
19
springboot-web/src/main/resources/mapper/CoreJobMapper.xml
Normal file
19
springboot-web/src/main/resources/mapper/CoreJobMapper.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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.tiesheng.core.mapper.CoreJobMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreJob">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table core_job-->
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
|
<result column="is_system" jdbcType="INTEGER" property="isSystem" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, create_time, update_time, is_deleted, `name`, remark, is_system
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?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.tiesheng.core.mapper.CoreJobPointMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreJobPoint">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table core_job_point-->
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
|
<result column="service" jdbcType="VARCHAR" property="service" />
|
||||||
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, create_time, update_time, is_deleted, service, `name`, remark
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<delete id="clearJobRx">
|
||||||
|
delete from core_job_rx where job_id=#{jobId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<update id="updateJobRx">
|
||||||
|
insert into core_job_rx(
|
||||||
|
id, create_time, update_time, is_deleted, job_id, point_id
|
||||||
|
) VALUES
|
||||||
|
<foreach collection="list" index="index" item="as" separator=",">
|
||||||
|
(#{as.id},
|
||||||
|
now(),
|
||||||
|
now(),
|
||||||
|
0,
|
||||||
|
#{as.name},
|
||||||
|
#{as.extra}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getJobRx" resultType="java.lang.String">
|
||||||
|
select point_id from core_job_rx where job_id=#{jobId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?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.tiesheng.core.mapper.CoreJobUserMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreJobUser">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table core_job_user-->
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
|
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||||
|
<result column="job_id" jdbcType="VARCHAR" property="jobId" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, create_time, update_time, is_deleted, user_id, job_id
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.tiesheng.core.pojos.dto.job.JobUserOwner">
|
||||||
|
select cju.job_id,
|
||||||
|
cj.name job_name
|
||||||
|
from core_job_user cju
|
||||||
|
left join core_job cj on cj.id = cju.job_id
|
||||||
|
where cju.is_deleted=0 and cju.user_id=#{userId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user