优化mybatis方法去掉冗余方法

This commit is contained in:
wh
2026-04-23 17:00:02 +08:00
parent 9483bea005
commit 2beebbe469
7 changed files with 23 additions and 73 deletions

View File

@@ -14,17 +14,6 @@
id, company_code, company_name, status, created_at, updated_at
</sql>
<insert id="insert" parameterType="com.labelsys.backend.entity.SysCompany">
insert into sys_company (id, company_code, company_name, status, created_at, updated_at)
values (#{id}, #{companyCode}, #{companyName}, #{status}, current_timestamp, current_timestamp)
</insert>
<select id="findById" resultMap="SysCompanyResultMap">
select <include refid="CompanyColumns"/>
from sys_company
where id = #{id}
</select>
<select id="findByCompanyCode" resultMap="SysCompanyResultMap">
select <include refid="CompanyColumns"/>
from sys_company
@@ -41,19 +30,13 @@
order by c.id
</select>
<select id="listAll" resultMap="SysCompanyResultMap">
select <include refid="CompanyColumns"/>
from sys_company
order by id
</select>
<update id="updateStatus">
update sys_company
set status = #{status}, updated_at = current_timestamp
where id = #{id}
</update>
<delete id="deleteAll">
delete from sys_company
</delete>
</mapper>
</mapper>

View File

@@ -22,21 +22,6 @@
status, session_version, created_at, updated_at
</sql>
<insert id="insert" parameterType="com.labelsys.backend.entity.SysUser">
insert into sys_user (
id, company_id, phone, username, role, position, real_name, password_hash, must_change_password,
status, session_version, created_at, updated_at
)
values (
#{id}, #{companyId}, #{phone}, #{username}, #{role}, #{position}, #{realName}, #{passwordHash}, #{mustChangePassword},
#{status}, #{sessionVersion}, current_timestamp, current_timestamp
)
</insert>
<select id="findById" resultMap="SysUserResultMap">
select <include refid="UserColumns"/> from sys_user where id = #{id}
</select>
<select id="findByIdAndCompanyId" resultMap="SysUserResultMap">
select <include refid="UserColumns"/> from sys_user where id = #{id} and company_id = #{companyId}
</select>
@@ -45,10 +30,6 @@
select <include refid="UserColumns"/> from sys_user where company_id = #{companyId} and phone = #{phone}
</select>
<select id="listByCompanyId" resultMap="SysUserResultMap">
select <include refid="UserColumns"/> from sys_user where company_id = #{companyId} order by id
</select>
<select id="listCompanyAdmins" resultMap="SysUserResultMap">
select <include refid="UserColumns"/>
from sys_user
@@ -91,4 +72,4 @@
<delete id="deleteAll">
delete from sys_user
</delete>
</mapper>
</mapper>