143 lines
5.5 KiB
XML
143 lines
5.5 KiB
XML
<?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.bonus.hnrn.rnmw.person.dao.CompanyDao">
|
|
|
|
<!-- 查询单个公司数量 -->
|
|
<select id="findCompanyCount" resultType="java.lang.Integer">
|
|
SELECT COUNT(1) FROM bns_smz_pm_company
|
|
WHERE org_name=#{orgName}
|
|
</select>
|
|
<!-- 公司注册 -->
|
|
<insert id="addCompany" parameterType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity" useGeneratedKeys="true" keyProperty="id" >
|
|
INSERT INTO bns_smz_pm_company(
|
|
org_name,
|
|
org_credit_code,
|
|
legal_person_name,
|
|
legal_person_idcard,
|
|
legal_person_phone,
|
|
org_type,
|
|
register_capital,
|
|
register_address_code,
|
|
postal_code,
|
|
register_address,
|
|
laborer_person_name,
|
|
laborer_person_idcard,
|
|
laborer_person_phone,
|
|
contact_person,
|
|
contact_person_phone,
|
|
office_address,
|
|
regist_date,
|
|
examine_status,
|
|
is_active,
|
|
create_type
|
|
)
|
|
VALUES (
|
|
#{orgName},
|
|
#{orgCreditCode},
|
|
#{legalPersonName},
|
|
#{legalPersonIdcard},
|
|
#{legalPersonPhone},
|
|
#{orgType},
|
|
#{registerCapital},
|
|
#{registerAddressCode},
|
|
#{postalCode},
|
|
#{registerAddress},
|
|
#{laborerPersonName},
|
|
#{laborerPersonIdcard},
|
|
#{laborerPersonPhone},
|
|
#{contactPerson},
|
|
#{contactPersonPhone},
|
|
#{officeAddress},
|
|
#{registDate},
|
|
'0','1','1'
|
|
)
|
|
</insert>
|
|
<!-- 获取单位类型 -->
|
|
<select id="findOrgType" resultType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity">
|
|
SELECT sdd.id as orgType,sdd.name as orgTypeName
|
|
FROM bns_smz_sys_dic_type sdt
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdt.id=sdd.dic_type
|
|
WHERE sdt.is_active='1' AND sdt.id='1'
|
|
</select>
|
|
<!-- 获取注册地行政区划代码 -->
|
|
<select id="findRegisterAddressCode" resultType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity">
|
|
SELECT sdd.id as registerAddressCode,CONCAT(sdd.name,'-',sdd.code) as registerAddressCodeName
|
|
FROM bns_smz_sys_dic_type sdt
|
|
LEFT JOIN bns_smz_sys_dic_detail sdd ON sdt.id=sdd.dic_type
|
|
WHERE sdt.is_active='1' AND sdt.id='2'
|
|
</select>
|
|
|
|
<!-- 获取单个公司信息 -->
|
|
<select id="findCompanyOne" resultType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity">
|
|
SELECT pc.id,pc.org_name as orgName
|
|
FROM bns_smz_pm_company pc
|
|
where pc.org_name=#{orgName}
|
|
</select>
|
|
|
|
<!-- 公司注册-用户 -->
|
|
<insert id="addCompanyUser" parameterType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity" useGeneratedKeys="true" keyProperty="userId" >
|
|
INSERT INTO `sys_user`(`USERNAME`, `LOGINNAME`, `PHONE`, `TYPE`,ORG_ID,ROLE_ID, `PASSWORD`,`create_type`, `examine_status`, `createTime`)
|
|
VALUES (#{userName}, #{userName}, #{userPhone}, '1,2',#{id},#{roleId},#{password},'1', '0', CURRENT_TIMESTAMP)
|
|
</insert>
|
|
|
|
|
|
<!--公司新增role-->
|
|
<insert id="addCompanyRole" parameterType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity" useGeneratedKeys="true" keyProperty="roleId" >
|
|
INSERT INTO `sys_role`( `name`, `company_id`, `createTime`, `updateTime`, `status`, `is_active`)
|
|
VALUES ('公司管理员', #{id}, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP(), '1', '1');
|
|
</insert>
|
|
|
|
<!--公司新增roleUser-->
|
|
<insert id="addCompanyRoleUser" >
|
|
INSERT INTO `sys_role_user`( `userId`, `roleId`)
|
|
VALUES (#{userId}, #{roleId});
|
|
</insert>
|
|
|
|
|
|
<!-- 公司注册-组织架构 -->
|
|
<insert id="addCompanyOrg">
|
|
INSERT INTO `pm_organization`(`NAME`, `ABBREVIATION`, `PARENT_ID`, `TYPE`, `IS_ACTIVE`, `COMPANY_ID`)
|
|
VALUES ( #{orgName}, #{orgName}, 0, '1', '1', #{id})
|
|
</insert>
|
|
|
|
<!-- 获取单个用户信息 -->
|
|
<select id="findUserCount" resultType="java.lang.Integer">
|
|
SELECT COUNT(1)
|
|
FROM bns_smz_sys_user su
|
|
WHERE su.IS_ACTIVE='1'
|
|
AND (USERNAME = #{userName} or PHONE = #{phone})
|
|
</select>
|
|
|
|
<!-- 用户注册 -->
|
|
<insert id="addUser" useGeneratedKeys="true" keyProperty="userId" >
|
|
INSERT INTO `sys_user`(`USERNAME`, `LOGINNAME`, `PHONE`, `TYPE`, `ROLE_ID`, `ORG_ID`, <if test="proId !='' and proId !=null">PRO_ID,</if><if test="subId !='' and subId !=null">SUB_ID,</if> `POST_ID`, `PASSWORD`, `SEX`, `create_type`, `examine_status`, `createTime`)
|
|
VALUES (#{userName}, #{userName},#{phone}, #{type},#{roleId},#{orgId},<if test="proId !='' and proId !=null">#{proId},</if><if test="subId !='' and subId !=null">#{subId},</if> #{orgId},#{password}, #{sex},'1', '0', CURRENT_TIMESTAMP)
|
|
</insert>
|
|
|
|
<!--添加用户角色关系-->
|
|
<insert id="insertUserRole" parameterType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity" >
|
|
insert into bns_smz_sys_role_user(roleId,userId)
|
|
values(#{roleId},#{userId})
|
|
</insert>
|
|
<insert id="insertRegisterRolePermission">
|
|
INSERT INTO `sys_role_permission`( `roleId`, `permissionId`)
|
|
VALUES (#{roleId}, #{id});
|
|
</insert>
|
|
<!-- 重置密码 -->
|
|
<update bns_smz_id="resetUserPwd">
|
|
UPDATE bns_smz_sys_user SET `password`=#{password} WHERE phone=#{phone} and IS_ACTIVE='1'
|
|
</update>
|
|
|
|
<select id="getPhone" resultType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity">
|
|
select PHONE from bns_smz_sys_user where PHONE = #{phone} and IS_ACTIVE = '1'
|
|
</select>
|
|
|
|
<!-- 获取角色Type-->
|
|
<select id="findRoleType" resultType="com.bonus.hnrn.rnmw.person.entity.CompanyEntity">
|
|
select type from bns_smz_sys_role where id = #{roleId} and is_active = '1'
|
|
</select>
|
|
|
|
<select id="listBackAll" resultType="com.bonus.hnrn.rnmw.core.entity.Permission">
|
|
select * from bns_smz_sys_permission t where t.is_active = '1' AND t.permission_type='后台' order by t.sort
|
|
</select>
|
|
</mapper> |