feat:移除job类的接口、方法
This commit is contained in:
@@ -23,6 +23,7 @@ import java.lang.annotation.*;
|
||||
LoginAutoConfigurer.class,
|
||||
DatabaseAutoConfigurer.class,
|
||||
EncryptAutoConfigurer.class,
|
||||
RoleAutoConfigurer.class,
|
||||
})
|
||||
public @interface EnableTieshengWeb {
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tiesheng.core;
|
||||
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@ComponentScan({
|
||||
"com.tiesheng.role.**.*",
|
||||
})
|
||||
@MapperScan("com.tiesheng.role.mapper")
|
||||
public class RoleAutoConfigurer {
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
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.util.pojos.IdDTO;
|
||||
import com.tiesheng.util.pojos.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.CoreJobService;
|
||||
import com.tiesheng.util.config.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
|
||||
CoreJobService coreJobService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取职位列表
|
||||
*
|
||||
* @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 = coreJobService.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 = coreJobService.getById(job.getId());
|
||||
if (byId != null && byId.getIsSystem() == 1) {
|
||||
throw new ApiException("系统配置,无法编辑");
|
||||
}
|
||||
}
|
||||
coreJobService.saveOrUpdate(job);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取关系
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/func/rx")
|
||||
public ApiResp<List<String>> funcRx(@Valid IdDTO dto) {
|
||||
List<String> list = coreJobService.getBaseMapper().getJobFunc(dto.getId(), null);
|
||||
return ApiResp.respOK(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新职位关系
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/func/rx")
|
||||
public ApiResp<String> updateJobRx(@Valid @RequestBody JobUpdateRxDTO dto) {
|
||||
coreJobService.updateJobRx(dto.getJobId(), StrUtil.split(dto.getPoints(), ","));
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户职位分配
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/assign")
|
||||
public ApiResp<String> userAssign(@Valid @RequestBody JobUserAssignDTO dto) {
|
||||
coreJobService.userAssign(dto.getUserId(), dto.getJobId());
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户自己的
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/owner")
|
||||
public ApiResp<List<JobUserOwner>> userOwner() {
|
||||
List<JobUserOwner> coreJobUsers = coreJobService.getJobUserMapper().list(TsTokenConfig.get().getId());
|
||||
coreJobUsers.forEach(it -> {
|
||||
List<String> list = coreJobService.getBaseMapper().getJobFunc(it.getJobId(), 1);
|
||||
it.setPoints(list);
|
||||
});
|
||||
return ApiResp.respOK(coreJobUsers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.tiesheng.core.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.core.pojos.dao.CoreJob;
|
||||
import com.tiesheng.util.pojos.IdName;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CoreJobMapper extends BaseMapper<CoreJob> {
|
||||
|
||||
/**
|
||||
* 清除职位的关联关系
|
||||
*
|
||||
* @param jobId
|
||||
*/
|
||||
void clearJobFunc(@Param("jobId") String jobId);
|
||||
|
||||
|
||||
/**
|
||||
* 更新关联关系
|
||||
*
|
||||
* @param pointList
|
||||
*/
|
||||
void updateJobFunc(@Param("list") List<IdName> pointList);
|
||||
|
||||
|
||||
/**
|
||||
* 获取关联的func
|
||||
*
|
||||
* @param jobId
|
||||
* @return
|
||||
*/
|
||||
List<String> getJobFunc(@Param("jobId") String jobId, @Param("isUsed") Integer isUsed);
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.tiesheng.core.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 职位
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package com.tiesheng.core.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
|
||||
/**
|
||||
* 职位-用户
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* 扩展1
|
||||
*/
|
||||
@TableField(value = "ext1")
|
||||
private String ext1;
|
||||
|
||||
/**
|
||||
* 扩展2
|
||||
*/
|
||||
@TableField(value = "ext2")
|
||||
private String ext2;
|
||||
|
||||
/**
|
||||
* 扩展3
|
||||
*/
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 扩展文本
|
||||
*/
|
||||
@TableField(value = "ext_text")
|
||||
private String extText;
|
||||
|
||||
/**
|
||||
* 获取用户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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展1
|
||||
*
|
||||
* @return ext1 - 扩展1
|
||||
*/
|
||||
public String getExt1() {
|
||||
return ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展1
|
||||
*
|
||||
* @param ext1 扩展1
|
||||
*/
|
||||
public void setExt1(String ext1) {
|
||||
this.ext1 = ext1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展2
|
||||
*
|
||||
* @return ext2 - 扩展2
|
||||
*/
|
||||
public String getExt2() {
|
||||
return ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展2
|
||||
*
|
||||
* @param ext2 扩展2
|
||||
*/
|
||||
public void setExt2(String ext2) {
|
||||
this.ext2 = ext2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展3
|
||||
*
|
||||
* @return ext3 - 扩展3
|
||||
*/
|
||||
public String getExt3() {
|
||||
return ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展3
|
||||
*
|
||||
* @param ext3 扩展3
|
||||
*/
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展文本
|
||||
*
|
||||
* @return ext_text - 扩展文本
|
||||
*/
|
||||
public String getExtText() {
|
||||
return extText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展文本
|
||||
*
|
||||
* @param extText 扩展文本
|
||||
*/
|
||||
public void setExtText(String extText) {
|
||||
this.extText = extText;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
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.CoreJobUserMapper;
|
||||
import com.tiesheng.core.pojos.dao.CoreJob;
|
||||
import com.tiesheng.core.pojos.dao.CoreJobUser;
|
||||
import com.tiesheng.util.pojos.IdName;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@Service
|
||||
public class CoreJobService extends TsServiceBase<CoreJobMapper, CoreJob> {
|
||||
|
||||
@Autowired
|
||||
CoreJobUserMapper coreJobUserMapper;
|
||||
|
||||
public CoreJobUserMapper getJobUserMapper() {
|
||||
return coreJobUserMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新职位
|
||||
*
|
||||
* @param name
|
||||
* @param remark
|
||||
* @param isSystem
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refresh(String id, String name, String remark, Integer isSystem) {
|
||||
CoreJob coreJob = new CoreJob();
|
||||
coreJob.setId(id);
|
||||
coreJob.setName(name);
|
||||
coreJob.setRemark(remark);
|
||||
coreJob.setIsSystem(isSystem);
|
||||
saveOrUpdate(coreJob);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新关联关系
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
getBaseMapper().clearJobFunc(jobId);
|
||||
if (CollUtil.isNotEmpty(nameList)) {
|
||||
getBaseMapper().updateJobFunc(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.tiesheng.core.util;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CharacterUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 移除特殊字符
|
||||
*
|
||||
* @param o 类
|
||||
*/
|
||||
public static void removeSymbol(Object o) {
|
||||
removeSymbol(o, "\n|\r|\t| ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除特殊字符
|
||||
*
|
||||
* @param o 类
|
||||
* @param searchStr 规则
|
||||
*/
|
||||
public static void removeSymbol(Object o, String searchStr) {
|
||||
JSONObject object = JSONUtil.parseObj(o, false);
|
||||
for (Map.Entry<String, Object> entry : object) {
|
||||
if (ObjectUtil.isEmpty(entry.getValue()) || StrUtil.equals("null", String.valueOf(entry.getValue()))) {
|
||||
entry.setValue("");
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.isNotEmpty(entry.getKey())) {
|
||||
entry.setValue(StrUtil.trim(StrUtil.replace(entry.getValue().toString(), searchStr, "")));
|
||||
}
|
||||
}
|
||||
BeanUtil.copyProperties(object, o);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user