新增岗位管理
This commit is contained in:
parent
f36c8ac05d
commit
c22797cf87
|
|
@ -10,6 +10,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -22,6 +23,18 @@ public class SystemDeptController {
|
|||
@Resource
|
||||
ISystemDeptService iSystemDeptService;
|
||||
|
||||
/**
|
||||
* 部门所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<SystemDeptVo> vos = iSystemDeptService.all();
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,26 +1,94 @@
|
|||
package com.hxkj.admin.controller.system;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.hxkj.admin.service.ISystemPostService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemPostParam;
|
||||
import com.hxkj.admin.vo.system.SystemPostVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/post")
|
||||
@RequestMapping("api/system/post")
|
||||
public class SystemPostController {
|
||||
|
||||
public Object list() {
|
||||
return null;
|
||||
@Resource
|
||||
ISystemPostService iSystemPostService;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Object all() {
|
||||
List<SystemPostVo> vos = iSystemPostService.all();
|
||||
return AjaxResult.success(vos);
|
||||
}
|
||||
|
||||
public Object add() {
|
||||
return null;
|
||||
/**
|
||||
* 岗位列表
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Object list(@Validated PageParam pageParam,
|
||||
@RequestParam Map<String, String> params) {
|
||||
PageResult<SystemPostVo> list = iSystemPostService.list(pageParam, params);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
public Object edit() {
|
||||
return null;
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SystemPostVo vo = iSystemPostService.detail(id);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
public Object del() {
|
||||
return null;
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Object add(@Validated(value = SystemPostParam.create.class) @RequestBody SystemPostParam systemPostParam) {
|
||||
iSystemPostService.add(systemPostParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public Object edit(@Validated(value = SystemPostParam.update.class) @RequestBody SystemPostParam systemPostParam) {
|
||||
iSystemPostService.edit(systemPostParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public Object del(@Validated(value = SystemPostParam.delete.class) @RequestBody SystemPostParam systemPostParam) {
|
||||
iSystemPostService.del(systemPostParam.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ package com.hxkj.admin.service;
|
|||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.hxkj.admin.validate.system.SystemDeptParam;
|
||||
import com.hxkj.admin.validate.system.SystemMenuParam;
|
||||
import com.hxkj.admin.vo.system.SystemDeptVo;
|
||||
import com.hxkj.admin.vo.system.SystemMenuVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -13,6 +12,14 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ISystemDeptService {
|
||||
|
||||
/**
|
||||
* 部门所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemDeptVo>
|
||||
*/
|
||||
List<SystemDeptVo> all();
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package com.hxkj.admin.service;
|
||||
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemPostParam;
|
||||
import com.hxkj.admin.vo.system.SystemPostVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统岗位服务接口类
|
||||
*/
|
||||
public interface ISystemPostService {
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
List<SystemPostVo> all();
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SystemPostVo>
|
||||
*/
|
||||
PageResult<SystemPostVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SystemPostVo
|
||||
*/
|
||||
SystemPostVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
*/
|
||||
void add(SystemPostParam systemPostParam);
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
*/
|
||||
void edit(SystemPostParam systemPostParam);
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -25,6 +25,32 @@ public class SystemDeptServiceImpl implements ISystemDeptService {
|
|||
@Resource
|
||||
SystemDeptMapper systemDeptMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public List<SystemDeptVo> all() {
|
||||
List<SystemDept> systemDeptList = systemDeptMapper.selectList(new QueryWrapper<SystemDept>()
|
||||
.gt("pid", 0)
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc((Arrays.asList("id", "sort"))));
|
||||
|
||||
List<SystemDeptVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemDept systemDept : systemDeptList) {
|
||||
SystemDeptVo vo = new SystemDeptVo();
|
||||
BeanUtils.copyProperties(systemDept, vo);
|
||||
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemDept.getUpdateTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemDept.getCreateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return adminVoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,212 @@
|
|||
package com.hxkj.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.hxkj.admin.service.ISystemPostService;
|
||||
import com.hxkj.admin.validate.PageParam;
|
||||
import com.hxkj.admin.validate.system.SystemPostParam;
|
||||
import com.hxkj.admin.vo.system.SystemPostVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.entity.system.SystemPost;
|
||||
import com.hxkj.common.mapper.system.SystemPostMapper;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class SystemPostService implements ISystemPostService {
|
||||
|
||||
@Resource
|
||||
SystemPostMapper systemPostMapper;
|
||||
|
||||
/**
|
||||
* 岗位所有
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public List<SystemPostVo> all() {
|
||||
List<SystemPost> systemPostList = systemPostMapper.selectList(new QueryWrapper<SystemPost>()
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc((Arrays.asList("id", "sort"))));
|
||||
|
||||
List<SystemPostVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemPost systemPost : systemPostList) {
|
||||
SystemPostVo vo = new SystemPostVo();
|
||||
BeanUtils.copyProperties(systemPost, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemPost.getUpdateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return adminVoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam 分页参数
|
||||
* @param params 搜索参数
|
||||
* @return PageResult<SystemPostVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SystemPostVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer page = pageParam.getPageNo();
|
||||
Integer limit = pageParam.getPageSize();
|
||||
|
||||
QueryWrapper<SystemPost> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(SystemPost.class, info->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("is_delete", 0)
|
||||
.orderByDesc(Arrays.asList("id", "sort"));
|
||||
|
||||
systemPostMapper.setSearch(queryWrapper, params, new String[]{
|
||||
"like:code:str",
|
||||
"like:name:str",
|
||||
"=:isStop:int"
|
||||
});
|
||||
|
||||
IPage<SystemPost> iPage = systemPostMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SystemPostVo> adminVoArrayList = new ArrayList<>();
|
||||
for (SystemPost systemPost : iPage.getRecords()) {
|
||||
SystemPostVo vo = new SystemPostVo();
|
||||
BeanUtils.copyProperties(systemPost, vo);
|
||||
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemPost.getUpdateTime()));
|
||||
adminVoArrayList.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), adminVoArrayList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return SystemPostVo
|
||||
*/
|
||||
@Override
|
||||
public SystemPostVo detail(Integer id) {
|
||||
SystemPost systemPost = systemPostMapper.selectOne(new QueryWrapper<SystemPost>()
|
||||
.select(SystemPost.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(systemPost, "岗位不存在");
|
||||
|
||||
SystemPostVo vo = new SystemPostVo();
|
||||
BeanUtils.copyProperties(systemPost, vo);
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(systemPost.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtil.timestampToDate(systemPost.getUpdateTime()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位新增
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SystemPostParam systemPostParam) {
|
||||
Assert.isNull(systemPostMapper.selectOne(new QueryWrapper<SystemPost>()
|
||||
.select("id,code,name")
|
||||
.nested(
|
||||
wq->wq.eq("code", systemPostParam.getCode())
|
||||
.or()
|
||||
.eq("name", systemPostParam.getName())
|
||||
)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "该岗位已存在");
|
||||
|
||||
SystemPost model = new SystemPost();
|
||||
model.setCode(systemPostParam.getCode());
|
||||
model.setName(systemPostParam.getName());
|
||||
model.setSort(systemPostParam.getSort());
|
||||
model.setRemarks(systemPostParam.getRemarks());
|
||||
model.setIsStop(systemPostParam.getIsStop());
|
||||
model.setIsDelete(0);
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemPostMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位编辑
|
||||
*
|
||||
* @author fzr
|
||||
* @param systemPostParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SystemPostParam systemPostParam) {
|
||||
SystemPost model = systemPostMapper.selectOne(new QueryWrapper<SystemPost>()
|
||||
.select(SystemPost.class, info ->
|
||||
!info.getColumn().equals("is_delete") &&
|
||||
!info.getColumn().equals("delete_time"))
|
||||
.eq("id", systemPostParam.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "岗位不存在");
|
||||
|
||||
Assert.isNull(systemPostMapper.selectOne(new QueryWrapper<SystemPost>()
|
||||
.select("id,code,name")
|
||||
.ne("id", systemPostParam.getId())
|
||||
.nested(
|
||||
wq->wq.eq("code", systemPostParam.getCode())
|
||||
.or()
|
||||
.eq("name", systemPostParam.getName())
|
||||
)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1")), "该岗位已存在");
|
||||
|
||||
model.setCode(systemPostParam.getCode());
|
||||
model.setName(systemPostParam.getName());
|
||||
model.setSort(systemPostParam.getSort());
|
||||
model.setRemarks(systemPostParam.getRemarks());
|
||||
model.setIsStop(systemPostParam.getIsStop());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
systemPostMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
SystemPost model = systemPostMapper.selectOne(new QueryWrapper<SystemPost>()
|
||||
.select("id,code,name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "岗位不存在");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
systemPostMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,15 +35,15 @@ public class SystemDeptParam {
|
|||
private String name;
|
||||
|
||||
@Length(min = 1, max = 30, message = "负责人名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String duty;
|
||||
private String duty = "";
|
||||
|
||||
@Length(min = 11, max = 11, message = "手机号只能为11位", groups = {create.class, update.class})
|
||||
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误", groups = {create.class, update.class})
|
||||
private String mobile;
|
||||
private String mobile = "";
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isStop;
|
||||
private Integer isStop = 0;
|
||||
|
||||
private Integer sort;
|
||||
private Integer sort = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.hxkj.admin.validate.system;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IDMust;
|
||||
import com.hxkj.common.validator.annotation.IntegerContains;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 系统岗位Vo
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SystemPostParam {
|
||||
|
||||
public interface create{}
|
||||
public interface update{}
|
||||
public interface delete{}
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "code参数缺失", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "岗位编码必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String code;
|
||||
|
||||
@NotNull(message = "name参数缺失", groups = {create.class, update.class})
|
||||
@Length(min = 1, max = 30, message = "岗位名称必须在1~30个字符内", groups = {create.class, update.class})
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "请选择状态", groups = {create.class, update.class})
|
||||
@IntegerContains(values = {0, 1}, groups = {create.class, update.class})
|
||||
private Integer isStop = 0;
|
||||
|
||||
@Length( max = 250, message = "岗位备注不能大于250个字符内", groups = {create.class, update.class})
|
||||
private String remarks = "";
|
||||
|
||||
private Integer sort = 0;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.hxkj.admin.vo.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统岗位Vo
|
||||
*/
|
||||
@Data
|
||||
public class SystemPostVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String remarks;
|
||||
private Integer sort;
|
||||
private Integer isStop;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.hxkj.common.entity.system;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 岗位管理
|
||||
*/
|
||||
@Data
|
||||
public class SystemPost implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
private Integer id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String remarks;
|
||||
private Integer sort;
|
||||
private Integer isStop;
|
||||
private Integer isDelete;
|
||||
private Long createTime;
|
||||
private Long updateTime;
|
||||
private Long deleteTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.hxkj.common.mapper.system;
|
||||
|
||||
import com.hxkj.common.core.basics.IBaseMapper;
|
||||
import com.hxkj.common.entity.system.SystemPost;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统岗位
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemPostMapper extends IBaseMapper<SystemPost> {
|
||||
}
|
||||
Loading…
Reference in New Issue