60 lines
2.2 KiB
XML
60 lines
2.2 KiB
XML
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
|
<mapper namespace="com.labelsys.backend.mapper.SysCompanyMapper">
|
||
|
|
<resultMap id="SysCompanyResultMap" type="com.labelsys.backend.entity.SysCompany">
|
||
|
|
<id column="id" property="id"/>
|
||
|
|
<result column="company_code" property="companyCode"/>
|
||
|
|
<result column="company_name" property="companyName"/>
|
||
|
|
<result column="status" property="status"/>
|
||
|
|
<result column="created_at" property="createdAt"/>
|
||
|
|
<result column="updated_at" property="updatedAt"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<sql id="CompanyColumns">
|
||
|
|
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
|
||
|
|
where company_code = #{companyCode}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findEnabledCompaniesByPhone" resultMap="SysCompanyResultMap">
|
||
|
|
select distinct c.id, c.company_code, c.company_name, c.status, c.created_at, c.updated_at
|
||
|
|
from sys_company c
|
||
|
|
inner join sys_user u on u.company_id = c.id
|
||
|
|
where u.phone = #{phone}
|
||
|
|
and u.status = 'ENABLED'
|
||
|
|
and c.status = 'ENABLED'
|
||
|
|
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>
|