新增公司

This commit is contained in:
sxu 2025-01-05 16:34:14 +08:00
parent 093093e650
commit 3e5b0245af
5 changed files with 47 additions and 8 deletions

View File

@ -35,6 +35,9 @@ public class SysPost extends BaseEntity
@Excel(name = "岗位名称")
private String postName;
/** 所属公司ID */
private Long companyId;
/** 岗位排序 */
@Excel(name = "岗位排序")
private Integer postSort;
@ -80,6 +83,14 @@ public class SysPost extends BaseEntity
this.postName = postName;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
@NotNull(message = "显示顺序不能为空")
public Integer getPostSort()
{

View File

@ -8,6 +8,7 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.config.SystemConfig;
import com.bonus.system.api.domain.SysPost;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,6 +41,9 @@ public class SysPostController extends BaseController {
@Autowired
private ISysPostService postService;
@Autowired
SystemConfig systemConfig;
/**
* 获取岗位列表
*/
@ -92,6 +96,8 @@ public class SysPostController extends BaseController {
@SysLog(title = "岗位管理", businessType = OperaType.INSERT, logType = 0, module = "系统管理->岗位管理", details = "新增岗位")
public AjaxResult add(@Validated @RequestBody SysPost post) {
try {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
post.setCompanyId(companyId);
if (!postService.checkPostNameUnique(post)) {
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) {

View File

@ -24,7 +24,7 @@ public interface SysPostMapper
*
* @return 岗位列表
*/
public List<SysPost> selectPostAll();
public List<SysPost> selectPostAll(SysPost sysPost);
/**
* 通过岗位ID查询岗位信息

View File

@ -2,6 +2,7 @@ package com.bonus.system.service.impl;
import java.util.List;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,7 +44,7 @@ public class SysPostServiceImpl implements ISysPostService
String str = post.getPostName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
post.setPostName(str);
}
post.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return postMapper.selectPostList(post);
}
@ -55,7 +56,9 @@ public class SysPostServiceImpl implements ISysPostService
@Override
public List<SysPost> selectPostAll()
{
return postMapper.selectPostAll();
SysPost sysPost = new SysPost();
sysPost.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return postMapper.selectPostAll(sysPost);
}
/**

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="postCode" column="post_code" />
<result property="postName" column="post_name" />
<result property="postSort" column="post_sort" />
<result property="companyId" column="company_id" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -18,13 +19,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
select post_id, post_code, post_name, post_sort, company_id, status, create_by, create_time, remark
from sys_post
</sql>
<select id="selectPostList" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
<where>
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
<if test="postCode != null and postCode != ''">
AND post_code like concat('%', #{postCode}, '%')
</if>
@ -38,8 +42,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by post_sort
</select>
<select id="selectPostAll" resultMap="SysPostResult">
<select id="selectPostAll" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where 1=1
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
</select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
@ -56,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
select p.post_id, p.post_name, p.post_code
select p.post_id, p.post_name, p.post_code, p.company_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
@ -65,12 +73,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_name=#{postName} limit 1
where post_name=#{postName}
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_code=#{postCode} limit 1
where post_code=#{postCode}
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<update id="updatePost" parameterType="com.bonus.system.api.domain.SysPost">
@ -79,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
<if test="postName != null and postName != ''">post_name = #{postName},</if>
<if test="postSort != null">post_sort = #{postSort},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@ -93,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">post_code,</if>
<if test="postName != null and postName != ''">post_name,</if>
<if test="postSort != null">post_sort,</if>
<if test="companyId != null">company_id,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -102,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">#{postCode},</if>
<if test="postName != null and postName != ''">#{postName},</if>
<if test="postSort != null">#{postSort},</if>
<if test="companyId != null">#{companyId},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>