This commit is contained in:
parent
7e72b8b392
commit
42a9a604cd
|
@ -26,6 +26,9 @@ public interface UrlConstant {
|
|||
|
||||
String MENU = API + "/menu";
|
||||
|
||||
|
||||
String JOB = API + "/job";
|
||||
|
||||
String PERSON = API + "/person";
|
||||
String EXCHANGE = API + "/exchange";
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class Generator {
|
|||
|
||||
public static void main(String[] args) {
|
||||
//表名
|
||||
String tableName = "t_sys_menu";
|
||||
String tableName = "t_sys_job";
|
||||
//表前缀
|
||||
String tablePrefix = "t_sys_";
|
||||
//作者—
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
package com.ydool.system.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
|
||||
import com.ydool.common.base.BaseController;
|
||||
import com.ydool.common.constant.UrlConstant;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.system.entity.Job;
|
||||
import com.ydool.system.entity.Role;
|
||||
import com.ydool.system.request.IdsRequest;
|
||||
import com.ydool.system.request.JobRequest;
|
||||
import com.ydool.system.request.RoleMenuRequest;
|
||||
import com.ydool.system.request.RoleRequest;
|
||||
import com.ydool.system.service.IJobService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(UrlConstant.JOB)
|
||||
@Api(tags = "岗位", value = "岗位")
|
||||
@ApiSupport(order = 10)
|
||||
public class JobController extends BaseController {
|
||||
@Autowired
|
||||
private IJobService jobService;
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @param value
|
||||
* @param column
|
||||
* @param orderBy
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "list")
|
||||
@ApiOperation(value = "岗位列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "current", value = "当前页", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "size", value = "每页条数", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "value", value = "搜索框中的内容(只支持字符串类型)"),
|
||||
@ApiImplicitParam(name = "column", value = "排序字段 字段名"),
|
||||
@ApiImplicitParam(name = "orderBy", value = "排序顺序 降序:desc,升序:asc"),
|
||||
@ApiImplicitParam(name = "status", value = "启用状态", dataType = "Boolean"),
|
||||
})
|
||||
@ApiOperationSupport(
|
||||
responses = @DynamicResponseParameters(properties = {
|
||||
@DynamicParameter(name = "data", dataTypeClass = Job.class)
|
||||
}),
|
||||
order = 1
|
||||
)
|
||||
public AjaxResult jobList(String value,
|
||||
String column,
|
||||
String orderBy,
|
||||
Boolean status
|
||||
) {
|
||||
return jobService.jobList(getPage(), value, column, orderBy, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "detail")
|
||||
@ApiOperation(value = "岗位详情")
|
||||
@ApiOperationSupport(
|
||||
responses = @DynamicResponseParameters(properties = {
|
||||
@DynamicParameter(name = "data", dataTypeClass = Job.class)
|
||||
}), order = 2
|
||||
)
|
||||
@ApiImplicitParam(name = "id", value = "岗位Id")
|
||||
public AjaxResult jobDetail(String id) {
|
||||
return jobService.jobDetail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存岗位
|
||||
*
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "save")
|
||||
@ApiOperation(value = "保存岗位")
|
||||
@ApiOperationSupport(order = 3)
|
||||
public AjaxResult saveJob(@RequestBody @Validated JobRequest jobRequest) {
|
||||
return jobService.saveJob(jobRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑岗位
|
||||
*
|
||||
* @param id
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "edit")
|
||||
@ApiOperation(value = "编辑岗位")
|
||||
@ApiImplicitParam(name = "id", value = "岗位Id")
|
||||
@ApiOperationSupport(order = 4)
|
||||
public AjaxResult editJob(String id, @RequestBody @Validated JobRequest jobRequest) {
|
||||
return jobService.editJob(id, jobRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个删除岗位
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "remove")
|
||||
@ApiOperation(value = "删除岗位")
|
||||
@ApiImplicitParam(name = "id", value = "岗位Id")
|
||||
@ApiOperationSupport(order = 5)
|
||||
public AjaxResult removeJob(String id) {
|
||||
return jobService.removeJob(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除岗位
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "removeBatch")
|
||||
@ApiOperation(value = "批量删除岗位")
|
||||
@ApiOperationSupport(order = 6)
|
||||
public AjaxResult removeJobs(@RequestBody @Validated IdsRequest ids) {
|
||||
return jobService.removeJobs(ids);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 岗位列表下拉框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "jobs")
|
||||
@ApiOperation(value = "岗位列表下拉框")
|
||||
@ApiOperationSupport(
|
||||
responses = @DynamicResponseParameters(properties = {
|
||||
@DynamicParameter(name = "data", dataTypeClass = Job.class)
|
||||
}), order = 7
|
||||
)
|
||||
public AjaxResult jobs() {
|
||||
return jobService.jobs();
|
||||
}
|
||||
}
|
|
@ -12,4 +12,7 @@ public class UserDto extends User {
|
|||
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
private String rolesName;
|
||||
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String jobName;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.ydool.system.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ydool.common.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
/**
|
||||
* <p>
|
||||
* 系统岗位
|
||||
* </p>
|
||||
*
|
||||
* @author ljq
|
||||
* @since 2023-02-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_sys_job")
|
||||
@ApiModel(value="Job对象", description="系统岗位")
|
||||
public class Job extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "岗位编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sortNo;
|
||||
|
||||
@ApiModelProperty(value = "启用状态")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
}
|
|
@ -70,4 +70,7 @@ public class User extends BaseEntity{
|
|||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty(value = "岗位")
|
||||
private String job;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.ydool.system.mapper;
|
||||
|
||||
import com.ydool.system.entity.Job;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统岗位 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ljq
|
||||
* @since 2023-02-08
|
||||
*/
|
||||
@Mapper
|
||||
public interface JobMapper extends MPJBaseMapper<Job> {
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ydool.system.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class JobRequest {
|
||||
@ApiModelProperty(value = "岗位编码")
|
||||
@NotBlank(message = "岗位编码不能为空")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
@NotBlank(message = "岗位名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sortNo;
|
||||
|
||||
@ApiModelProperty(value = "启用状态")
|
||||
@NotNull(message = "启用状态不能为空")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
}
|
|
@ -36,4 +36,8 @@ public class UserRequest {
|
|||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty(value = "岗位")
|
||||
@NotBlank(message = "岗位不能为空")
|
||||
private String job;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package com.ydool.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.system.request.IdsRequest;
|
||||
import com.ydool.system.request.JobRequest;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统岗位 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ljq
|
||||
* @since 2023-02-08
|
||||
*/
|
||||
public interface IJobService {
|
||||
|
||||
/**
|
||||
* 保存岗位
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
AjaxResult saveJob(JobRequest jobRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑岗位
|
||||
* @param id
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
AjaxResult editJob(String id,JobRequest jobRequest);
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult removeJob(String id);
|
||||
|
||||
/**
|
||||
* 批量删除岗位
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
AjaxResult removeJobs(IdsRequest ids);
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult jobDetail(String id);
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
* @param page
|
||||
* @param value
|
||||
* @param column
|
||||
* @param orderBy
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
AjaxResult jobList(Page page, String value, String column, String orderBy, Boolean status);
|
||||
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
* @return
|
||||
*/
|
||||
AjaxResult jobs();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
package com.ydool.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.base.BaseService;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.system.entity.Job;
|
||||
import com.ydool.system.entity.Role;
|
||||
import com.ydool.system.mapper.JobMapper;
|
||||
import com.ydool.system.request.IdsRequest;
|
||||
import com.ydool.system.request.JobRequest;
|
||||
import com.ydool.system.service.IJobService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统岗位 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ljq
|
||||
* @since 2023-02-08
|
||||
*/
|
||||
@Service
|
||||
public class JobServiceImpl extends BaseService<JobMapper, Job> implements IJobService {
|
||||
|
||||
/**
|
||||
* 保存岗位
|
||||
*
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult saveJob(JobRequest jobRequest) {
|
||||
String message = checkJob("", jobRequest);
|
||||
if (StrUtil.isNotBlank(message)) return AjaxResult.fail(message);
|
||||
Job job = BeanUtil.copyProperties(jobRequest, Job.class);
|
||||
boolean flag = save(job);
|
||||
return flag ? AjaxResult.ok().msg("保存成功") : AjaxResult.fail("保存失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑岗位
|
||||
*
|
||||
* @param id
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult editJob(String id, JobRequest jobRequest) {
|
||||
if (StrUtil.isBlank(id)) return AjaxResult.fail("id不能为空");
|
||||
String message = checkJob(id, jobRequest);
|
||||
if (StrUtil.isNotBlank(message)) return AjaxResult.fail(message);
|
||||
Job job = getById(id);
|
||||
if (ObjectUtil.isNull(job)) return AjaxResult.fail("该岗位不存在");
|
||||
BeanUtil.copyProperties(jobRequest, job);
|
||||
boolean flag = updateById(job);
|
||||
return flag ? AjaxResult.ok().msg("编辑成功") : AjaxResult.fail("编辑失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult removeJob(String id) {
|
||||
if (StrUtil.isBlank(id)) return AjaxResult.fail("id不能为空");
|
||||
Job job = getById(id);
|
||||
if (ObjectUtil.isNull(job)) return AjaxResult.fail("该岗位不存在");
|
||||
return removeById(id) ? AjaxResult.ok().msg("删除成功") : AjaxResult.fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除岗位
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult removeJobs(IdsRequest ids) {
|
||||
String[] idList = ids.getIds();
|
||||
if (ArrayUtil.isEmpty(idList)) return AjaxResult.fail("岗位Id集合不能为空");
|
||||
List<Job> jobList = listByIds(Arrays.asList(idList));
|
||||
if (CollUtil.isEmpty(jobList)) return AjaxResult.fail("该岗位集合全部不存在");
|
||||
return removeByIds(Arrays.asList(idList)) ? AjaxResult.ok().msg("批量删除成功") : AjaxResult.fail("批量删除失败");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult jobDetail(String id) {
|
||||
if (StrUtil.isBlank(id)) return AjaxResult.fail("id不能为空");
|
||||
Job job = getById(id);
|
||||
return AjaxResult.ok().data(job);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @param page
|
||||
* @param value
|
||||
* @param column
|
||||
* @param orderBy
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult jobList(Page page, String value, String column, String orderBy, Boolean status) {
|
||||
QueryWrapper<Job> qw = new QueryWrapper<Job>();
|
||||
if (StrUtil.isNotBlank(value)) {
|
||||
qw.lambda().like(Job::getName, value)
|
||||
.or().like(Job::getRemarks, value)
|
||||
.or().like(Job::getCode, value);
|
||||
}
|
||||
|
||||
qw.lambda().eq(ObjectUtil.isNotNull(status), Job::getStatus, status);
|
||||
|
||||
if ("desc".equals(orderBy) && StrUtil.isNotBlank(column)) {
|
||||
qw.orderByDesc(StrUtil.toUnderlineCase(column));
|
||||
}
|
||||
|
||||
if ("asc".equals(orderBy) && StrUtil.isNotBlank(column)) {
|
||||
qw.orderByAsc(StrUtil.toUnderlineCase(column));
|
||||
}
|
||||
|
||||
Page<Job> pageList = page(page, qw);
|
||||
|
||||
return AjaxResult.ok().data(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult jobs() {
|
||||
List<Job> jobs = list(new QueryWrapper<Job>().lambda()
|
||||
.eq(Job::getStatus, true)
|
||||
);
|
||||
return AjaxResult.ok().data(jobs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验岗位
|
||||
*
|
||||
* @param id
|
||||
* @param jobRequest
|
||||
* @return
|
||||
*/
|
||||
private String checkJob(String id, JobRequest jobRequest) {
|
||||
Job job = getOne(new QueryWrapper<Job>().lambda()
|
||||
.eq(Job::getCode, jobRequest.getCode())
|
||||
.ne(StrUtil.isNotBlank(id), Job::getId, id)
|
||||
.last("limit 1")
|
||||
);
|
||||
if(ObjUtil.isNotEmpty(job)) return "岗位编码不能重复";
|
||||
|
||||
job = getOne(new QueryWrapper<Job>().lambda()
|
||||
.eq(Job::getName, jobRequest.getName())
|
||||
.ne(StrUtil.isNotBlank(id), Job::getId, id)
|
||||
.last("limit 1")
|
||||
);
|
||||
if(ObjUtil.isNotEmpty(job)) return "岗位名称不能重复";
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,15 +2,18 @@ package com.ydool.system.wrapper;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydool.common.base.BaseWrapper;
|
||||
import com.ydool.common.utils.CodecUtils;
|
||||
import com.ydool.system.dto.UserDto;
|
||||
import com.ydool.system.entity.Dept;
|
||||
import com.ydool.system.entity.Job;
|
||||
import com.ydool.system.entity.Role;
|
||||
import com.ydool.system.entity.User;
|
||||
import com.ydool.system.service.impl.DeptServiceImpl;
|
||||
import com.ydool.system.service.impl.JobServiceImpl;
|
||||
import com.ydool.system.service.impl.RoleServiceImpl;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
|
@ -29,9 +32,11 @@ public interface UserWrapper extends BaseWrapper<User, UserDto> {
|
|||
default void setOtherField(User obj, @MappingTarget UserDto dto) {
|
||||
DeptServiceImpl deptService = SpringUtil.getBean(DeptServiceImpl.class);
|
||||
RoleServiceImpl roleService = SpringUtil.getBean(RoleServiceImpl.class);
|
||||
JobServiceImpl jobService = SpringUtil.getBean(JobServiceImpl.class);
|
||||
dto.setPhone(CodecUtils.decrypt(obj.getPhone()));
|
||||
Dept dept = deptService.getById(obj.getDept());
|
||||
if (ObjectUtil.isNotNull(dept)) dto.setDeptName(dept.getName());
|
||||
if (StrUtil.isNotBlank(obj.getRoles())) {
|
||||
List<Role> roles = roleService.list(new QueryWrapper<Role>().lambda()
|
||||
.in(Role::getId, Arrays.asList(obj.getRoles().split(
|
||||
",")))
|
||||
|
@ -41,4 +46,11 @@ public interface UserWrapper extends BaseWrapper<User, UserDto> {
|
|||
if (CollUtil.isNotEmpty(roles))
|
||||
dto.setRolesName(roles.stream().map(Role::getName).collect(Collectors.joining(",")));
|
||||
}
|
||||
Job job = jobService.getOne(new QueryWrapper<Job>().lambda()
|
||||
.eq(Job::getStatus, true)
|
||||
.eq(Job::getId, obj.getJob())
|
||||
.last("limit 1")
|
||||
);
|
||||
if (ObjectUtil.isNotNull(job)) dto.setJobName(job.getName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue