parent
13c4681610
commit
76259580cd
@ -1,129 +0,0 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位信息操作处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/system/post")
|
|
||||||
public class SysPostController extends BaseController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private ISysPostService postService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取岗位列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(SysPost post)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(SysPost post)
|
|
||||||
{
|
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
|
||||||
return util.exportExcel(list, "岗位数据");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据岗位编号获取详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
|
||||||
@GetMapping(value = "/{postId}")
|
|
||||||
public AjaxResult getInfo(@PathVariable Long postId)
|
|
||||||
{
|
|
||||||
return AjaxResult.success(postService.selectPostById(postId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增岗位
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
|
||||||
{
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
|
||||||
}
|
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
|
||||||
}
|
|
||||||
post.setCreateBy(getUserId());
|
|
||||||
return toAjax(postService.insertPost(post));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改岗位
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
|
||||||
{
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
|
||||||
}
|
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
|
||||||
}
|
|
||||||
post.setUpdateBy(getUserId());
|
|
||||||
return toAjax(postService.updatePost(post));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除岗位
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{postIds}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
|
||||||
{
|
|
||||||
return toAjax(postService.deletePostByIds(postIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取岗位选择框列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/optionselect")
|
|
||||||
public AjaxResult optionselect()
|
|
||||||
{
|
|
||||||
List<SysPost> posts = postService.selectPostAll();
|
|
||||||
return AjaxResult.success(posts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,101 +0,0 @@
|
|||||||
package com.ruoyi.system.mapper;
|
|
||||||
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位信息 数据层
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface SysPostMapper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询岗位数据集合
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 岗位数据集合
|
|
||||||
*/
|
|
||||||
public List<SysPost> selectPostList(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有岗位
|
|
||||||
*
|
|
||||||
* @return 岗位列表
|
|
||||||
*/
|
|
||||||
public List<SysPost> selectPostAll(String tenantId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过岗位ID查询岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 角色对象信息
|
|
||||||
*/
|
|
||||||
public SysPost selectPostById(Long postId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户ID获取岗位选择框列表
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 选中岗位ID列表
|
|
||||||
*/
|
|
||||||
public List<Integer> selectPostListByUserId(@Param("userId") Long userId,@Param("tenantId") String tenantId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户所属岗位组
|
|
||||||
*
|
|
||||||
* @param userName 用户名
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public List<SysPost> selectPostsByUserName(String userName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deletePostById(Long postId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postIds 需要删除的岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deletePostByIds(Long[] postIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updatePost(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertPost(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位名称
|
|
||||||
*
|
|
||||||
* @param postName 岗位名称
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public SysPost checkPostNameUnique(String postName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位编码
|
|
||||||
*
|
|
||||||
* @param postCode 岗位编码
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public SysPost checkPostCodeUnique(String postCode);
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
package com.ruoyi.system.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位信息 服务层
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface ISysPostService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询岗位信息集合
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 岗位列表
|
|
||||||
*/
|
|
||||||
public List<SysPost> selectPostList(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有岗位
|
|
||||||
*
|
|
||||||
* @return 岗位列表
|
|
||||||
*/
|
|
||||||
public List<SysPost> selectPostAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过岗位ID查询岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 角色对象信息
|
|
||||||
*/
|
|
||||||
public SysPost selectPostById(Long postId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户ID获取岗位选择框列表
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 选中岗位ID列表
|
|
||||||
*/
|
|
||||||
public List<Integer> selectPostListByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位名称
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public String checkPostNameUnique(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位编码
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public String checkPostCodeUnique(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过岗位ID查询岗位使用数量
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int countUserPostById(Long postId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deletePostById(Long postId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postIds 需要删除的岗位ID
|
|
||||||
* @return 结果
|
|
||||||
* @throws Exception 异常
|
|
||||||
*/
|
|
||||||
public int deletePostByIds(Long[] postIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增保存岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertPost(SysPost post);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改保存岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updatePost(SysPost post);
|
|
||||||
}
|
|
||||||
@ -1,184 +0,0 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
|
||||||
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
|
||||||
import com.ruoyi.system.mapper.SysPostMapper;
|
|
||||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位信息 服务层处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysPostServiceImpl implements ISysPostService
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private SysPostMapper postMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserPostMapper userPostMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询岗位信息集合
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 岗位信息集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysPost> selectPostList(SysPost post)
|
|
||||||
{
|
|
||||||
post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
|
|
||||||
return postMapper.selectPostList(post);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有岗位
|
|
||||||
*
|
|
||||||
* @return 岗位列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysPost> selectPostAll()
|
|
||||||
{
|
|
||||||
return postMapper.selectPostAll(SecurityUtils.getLoginUser().getNowTenantId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过岗位ID查询岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 角色对象信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysPost selectPostById(Long postId)
|
|
||||||
{
|
|
||||||
return postMapper.selectPostById(postId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据用户ID获取岗位选择框列表
|
|
||||||
*
|
|
||||||
* @param userId 用户ID
|
|
||||||
* @return 选中岗位ID列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Integer> selectPostListByUserId(Long userId)
|
|
||||||
{
|
|
||||||
|
|
||||||
return postMapper.selectPostListByUserId(userId,SecurityUtils.getLoginUser().getNowTenantId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位名称是否唯一
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String checkPostNameUnique(SysPost post)
|
|
||||||
{
|
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
|
||||||
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
|
|
||||||
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
|
|
||||||
{
|
|
||||||
return UserConstants.NOT_UNIQUE;
|
|
||||||
}
|
|
||||||
return UserConstants.UNIQUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验岗位编码是否唯一
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String checkPostCodeUnique(SysPost post)
|
|
||||||
{
|
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
|
||||||
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
|
|
||||||
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
|
|
||||||
{
|
|
||||||
return UserConstants.NOT_UNIQUE;
|
|
||||||
}
|
|
||||||
return UserConstants.UNIQUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过岗位ID查询岗位使用数量
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int countUserPostById(Long postId)
|
|
||||||
{
|
|
||||||
return userPostMapper.countUserPostById(postId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postId 岗位ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deletePostById(Long postId)
|
|
||||||
{
|
|
||||||
return postMapper.deletePostById(postId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除岗位信息
|
|
||||||
*
|
|
||||||
* @param postIds 需要删除的岗位ID
|
|
||||||
* @return 结果
|
|
||||||
* @throws Exception 异常
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deletePostByIds(Long[] postIds)
|
|
||||||
{
|
|
||||||
for (Long postId : postIds)
|
|
||||||
{
|
|
||||||
SysPost post = selectPostById(postId);
|
|
||||||
if (countUserPostById(postId) > 0)
|
|
||||||
{
|
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return postMapper.deletePostByIds(postIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增保存岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int insertPost(SysPost post)
|
|
||||||
{
|
|
||||||
post.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
|
|
||||||
return postMapper.insertPost(post);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改保存岗位信息
|
|
||||||
*
|
|
||||||
* @param post 岗位信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int updatePost(SysPost post)
|
|
||||||
{
|
|
||||||
return postMapper.updatePost(post);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
<?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.ruoyi.system.mapper.SysPostMapper">
|
|
||||||
|
|
||||||
<resultMap type="SysPost" id="SysPostResult">
|
|
||||||
<id property="postId" column="post_id" />
|
|
||||||
<result property="postCode" column="post_code" />
|
|
||||||
<result property="postName" column="post_name" />
|
|
||||||
<result property="postSort" column="post_sort" />
|
|
||||||
<result property="status" column="status" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectPostVo">
|
|
||||||
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
|
|
||||||
from sys_post
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
|
|
||||||
<include refid="selectPostVo"/>
|
|
||||||
<where>
|
|
||||||
tenant_id = #{tenantId}
|
|
||||||
<if test="postCode != null and postCode != ''">
|
|
||||||
AND post_code like concat('%', #{postCode}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="status != null and status != ''">
|
|
||||||
AND status = #{status}
|
|
||||||
</if>
|
|
||||||
<if test="postName != null and postName != ''">
|
|
||||||
AND post_name like concat('%', #{postName}, '%')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPostAll" resultMap="SysPostResult">
|
|
||||||
<include refid="selectPostVo"/>
|
|
||||||
where 1=1
|
|
||||||
<if test="tenantId != null and tenantId != ''">
|
|
||||||
and tenant_id=#{tenantId}
|
|
||||||
</if>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
|
|
||||||
<include refid="selectPostVo"/>
|
|
||||||
where post_id = #{postId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPostListByUserId" resultType="Integer">
|
|
||||||
select p.post_id
|
|
||||||
from sys_post p
|
|
||||||
left join sys_user_post up on up.post_id = p.post_id
|
|
||||||
left join sys_user u on u.user_id = up.user_id
|
|
||||||
where u.user_id = #{userId} and p.tenant_id=#{tenantId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
|
|
||||||
select p.post_id, p.post_name, p.post_code
|
|
||||||
from sys_post p
|
|
||||||
left join sys_user_post up on up.post_id = p.post_id
|
|
||||||
left join sys_user u on u.user_id = up.user_id
|
|
||||||
where u.user_name = #{userName}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
|
|
||||||
<include refid="selectPostVo"/>
|
|
||||||
where post_name=#{postName} limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
|
|
||||||
<include refid="selectPostVo"/>
|
|
||||||
where post_code=#{postCode} limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="updatePost" parameterType="SysPost">
|
|
||||||
update sys_post
|
|
||||||
<set>
|
|
||||||
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
|
|
||||||
<if test="postName != null and postName != ''">post_name = #{postName},</if>
|
|
||||||
<if test="postSort != null and postSort != ''">post_sort = #{postSort},</if>
|
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where post_id = #{postId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
|
|
||||||
insert into sys_post(
|
|
||||||
<if test="postId != null and postId != 0">post_id,</if>
|
|
||||||
<if test="postCode != null and postCode != ''">post_code,</if>
|
|
||||||
<if test="postName != null and postName != ''">post_name,</if>
|
|
||||||
<if test="postSort != null and postSort != ''">post_sort,</if>
|
|
||||||
<if test="status != null and status != ''">status,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="tenantId != null">tenant_id,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="postId != null and postId != 0">#{postId},</if>
|
|
||||||
<if test="postCode != null and postCode != ''">#{postCode},</if>
|
|
||||||
<if test="postName != null and postName != ''">#{postName},</if>
|
|
||||||
<if test="postSort != null and postSort != ''">#{postSort},</if>
|
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="tenantId != null">#{tenantId},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<delete id="deletePostById" parameterType="Long">
|
|
||||||
delete from sys_post where post_id = #{postId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deletePostByIds" parameterType="Long">
|
|
||||||
delete from sys_post where post_id in
|
|
||||||
<foreach collection="array" item="postId" open="(" separator="," close=")">
|
|
||||||
#{postId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in new issue