<?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.thhy.engineering.modules.biz.company.mapper.CompanyMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
t.company_id as companyId,
|
t.company_name as companyName,
|
t.company_admin as companyAdmin,
|
t.company_phone as companyPhone,
|
t.address as address,
|
t.remark as remark,
|
t.is_use as isUse,
|
t.create_time as createTime,
|
t.update_time as updateTime,
|
t.create_user as createUser,
|
t.update_user as updateUser,
|
t.is_finish as isFinish,
|
t.target_url as targetUrl,
|
t.icon
|
</sql>
|
|
<sql id="condition_query">
|
<where>
|
<trim suffixOverrides=" AND ">
|
t.is_use = 1 AND
|
<if test="companyId!=null and companyId!=''">
|
t.company_id = #{companyId} AND
|
</if>
|
<if test="companyName!=null and companyName!=''">
|
t.company_name LIKE concat('%',#{companyName},'%') AND
|
</if>
|
<if test="companyAdmin!=null and companyAdmin!=''">
|
t.company_admin = #{companyAdmin} AND
|
</if>
|
<if test="companyPhone!=null and companyPhone!=''">
|
t.company_phone = #{companyPhone} AND
|
</if>
|
<if test="address!=null and address!=''">
|
t.address = #{address} AND
|
</if>
|
<if test="remark!=null and remark!=''">
|
t.remark = #{remark} AND
|
</if>
|
<if test="createTime!=null">
|
t.create_time = #{createTime} AND
|
</if>
|
<if test="updateTime!=null">
|
t.update_time = #{updateTime} AND
|
</if>
|
<if test="createUser!=null and createUser!=''">
|
t.create_user = #{createUser} AND
|
</if>
|
<if test="updateUser!=null and updateUser!=''">
|
t.update_user = #{updateUser} AND
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
<select id="queryById" resultType="com.thhy.engineering.modules.biz.company.entity.Company">
|
select <include refid="Base_Column_List" />
|
from sys_company t
|
where t.company_id=#{companyId}
|
</select>
|
|
<select id="queryVersionById" resultType="integer">
|
select version from sys_company
|
where company_id=#{companyId}
|
</select>
|
|
<!--查询列表-->
|
<select id="findList" resultType="com.thhy.engineering.modules.biz.company.entity.Company">
|
SELECT
|
<include refid="Base_Column_List" />
|
from sys_company t
|
<include refid="condition_query" />
|
</select>
|
|
<!--查询列表-->
|
<select id="findAll" resultType="com.thhy.engineering.modules.biz.company.entity.CompanySamInfo">
|
SELECT
|
t.company_id as companyId,
|
t.company_name as companyName,
|
t.is_finish as isFinish,
|
t.target_url as targetUrl,
|
t.icon
|
from sys_company t
|
where t.is_use = 1
|
order by t.is_finish,t.create_time desc
|
</select>
|
|
<select id="pulldown" resultType="hashmap">
|
SELECT
|
t.company_id as companyId,
|
t.company_name as companyName
|
from sys_company t
|
where t.is_use = 1
|
</select>
|
|
<!--插入操作-->
|
<insert id="insert">
|
insert into sys_company
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="companyId != null">
|
company_id,
|
</if>
|
<if test="companyName != null">
|
company_name,
|
</if>
|
<if test="companyAdmin != null">
|
company_admin,
|
</if>
|
<if test="companyPhone != null">
|
company_phone,
|
</if>
|
<if test="address != null">
|
address,
|
</if>
|
<if test="remark != null">
|
remark,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="updateTime != null">
|
update_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="updateUser != null">
|
update_user,
|
</if>
|
<if test="isFinish != null">
|
is_finish,
|
</if>
|
<if test="targetUrl != null">
|
target_url,
|
</if>
|
<if test="icon != null">
|
icon,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="companyId != null">
|
#{companyId},
|
</if>
|
<if test="companyName != null">
|
#{companyName},
|
</if>
|
<if test="companyAdmin != null">
|
#{companyAdmin},
|
</if>
|
<if test="companyPhone != null">
|
#{companyPhone},
|
</if>
|
<if test="address != null">
|
#{address},
|
</if>
|
<if test="remark != null">
|
#{remark},
|
</if>
|
<if test="isUse != null">
|
#{isUse},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime},
|
</if>
|
<if test="createUser != null">
|
#{createUser},
|
</if>
|
<if test="updateUser != null">
|
#{updateUser},
|
</if>
|
<if test="isFinish != null">
|
#{isFinish},
|
</if>
|
<if test="targetUrl != null">
|
#{targetUrl},
|
</if>
|
<if test="icon != null">
|
#{icon},
|
</if>
|
</trim>
|
</insert>
|
|
<!--插入操作-->
|
<insert id="insertSysUser" parameterType="com.thhy.engineering.modules.biz.company.entity.SysUsers">
|
insert into sys_users
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="userId != null">
|
user_id,
|
</if>
|
<if test="username != null">
|
username,
|
</if>
|
<if test="password != null">
|
password,
|
</if>
|
<if test="realName != null">
|
real_name,
|
</if>
|
<if test="telphone != null">
|
telphone,
|
</if>
|
<if test="photoUrl != null">
|
photo_url,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="sex != null">
|
sex,
|
</if>
|
<if test="email != null">
|
email,
|
</if>
|
<if test="subAdmin != null">
|
sub_admin,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="userId != null">
|
#{userId},
|
</if>
|
<if test="username != null">
|
#{username},
|
</if>
|
<if test="password != null">
|
#{password},
|
</if>
|
<if test="realName != null">
|
#{realName},
|
</if>
|
<if test="telphone != null">
|
#{telphone},
|
</if>
|
<if test="photoUrl != null">
|
#{photoUrl},
|
</if>
|
<if test="createUser != null">
|
#{createUser},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="isUse != null">
|
#{isUse},
|
</if>
|
<if test="sex != null">
|
#{sex},
|
</if>
|
<if test="email != null">
|
#{email},
|
</if>
|
<if test="subAdmin != null">
|
#{subAdmin},
|
</if>
|
</trim>
|
</insert>
|
|
<!--插入操作-->
|
<insert id="insertCompanyUser" parameterType="com.thhy.engineering.modules.biz.company.entity.CompanySu">
|
insert into sys_com_su
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
id,
|
</if>
|
<if test="companyId != null">
|
company_id,
|
</if>
|
<if test="userId != null">
|
user_id,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
#{id},
|
</if>
|
<if test="companyId != null">
|
#{companyId},
|
</if>
|
<if test="userId != null">
|
#{userId},
|
</if>
|
</trim>
|
</insert>
|
|
<!--更新操作-->
|
<update id="update">
|
update sys_company
|
<set>
|
<trim suffixOverrides=",">
|
<if test="companyName != null">
|
company_name=#{companyName},
|
</if>
|
<if test="companyAdmin != null">
|
company_admin=#{companyAdmin},
|
</if>
|
<if test="companyPhone != null">
|
company_phone=#{companyPhone},
|
</if>
|
<if test="address != null">
|
address=#{address},
|
</if>
|
<if test="remark != null">
|
remark=#{remark},
|
</if>
|
<if test="isUse != null">
|
is_use=#{isUse},
|
</if>
|
<if test="createTime != null">
|
create_time=#{createTime},
|
</if>
|
<if test="updateTime != null">
|
update_time=#{updateTime},
|
</if>
|
<if test="createUser != null">
|
create_user=#{createUser},
|
</if>
|
<if test="updateUser != null">
|
update_user=#{updateUser},
|
</if>
|
<!--<if test="subAdmin != null">
|
sub_admin=#{subAdmin},
|
</if>-->
|
<if test="isFinish != null">
|
is_finish = #{isFinish},
|
</if>
|
<if test="targetUrl != null">
|
target_url = #{targetUrl},
|
</if>
|
<if test="icon != null">
|
icon = #{icon},
|
</if>
|
</trim>
|
|
</set>
|
where company_id=#{companyId}
|
</update>
|
|
<!--逻辑删除-->
|
<update id="deletelogic">
|
update sys_company
|
SET is_use = 0
|
where company_id=#{companyId}
|
</update>
|
|
<!--根据ID删除-->
|
<delete id="deleteById">
|
delete from sys_company
|
where company_id=#{companyId}
|
</delete>
|
|
<!--插入操作-->
|
<insert id="insertUserRole">
|
insert into sys_user_role
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="userRoleId != null">
|
user_role_id,
|
</if>
|
<if test="userId != null">
|
user_id,
|
</if>
|
<if test="roleId != null">
|
role_id,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="userRoleId != null">
|
#{userRoleId},
|
</if>
|
<if test="userId != null">
|
#{userId},
|
</if>
|
<if test="roleId != null">
|
#{roleId},
|
</if>
|
<if test="isUse != null">
|
#{isUse},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="queryIdByComName" resultType="string">
|
select company_id from sys_company where company_name = TRIM(#{companyName})
|
</select>
|
|
</mapper>
|