Merge remote-tracking branch 'origin/main'

This commit is contained in:
haozq 2025-08-22 16:34:33 +08:00
commit 79034404a7
9 changed files with 155 additions and 96 deletions

View File

@ -18,7 +18,7 @@ public interface CompanyDao {
@Select("SELECT \"id\",\"name\" AS companyName FROM \"ynrealname\".\"pm_company\" where \"name\" = #{companyName} and \"is_active\" = '1'")
CompanyBean getCompanyByName(String companyName);
@SelectKey(statement = "SELECT IDENTITY()", keyProperty = "id", before = false, resultType = Long.class)
@SelectKey(statement = "SELECT @@IDENTITY", keyProperty = "id", before = false, resultType = Long.class)
@Insert("INSERT INTO \"ynrealname\".\"pm_company\"(\"name\", \"type_id\", \"address\", \"register_date\", \"legal_person\", \"legal_phone\", \"legal_idnumber\", \"is_active\") VALUES (#{companyName}, #{unitType}, #{address}, #{registerDate}, #{represent}, #{representPhone}, #{representIdNumber}, '1')")
int saveCompany(CompanyBean o);

View File

@ -2,6 +2,8 @@ package com.bonus.bmw.basic.dao;
import com.bonus.system.api.model.Permission;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;
import java.util.List;
import java.util.Set;
@ -63,6 +65,18 @@ public interface PermissionDao {
@Select("select p.* from \"ynrealname\".\"sys_permission\" p inner join \"ynrealname\".\"sys_role_permission\" rp on p.\"id\" = rp.\"permissionId\" where rp.\"roleId\" = #{appRoleId} and p.\"is_active\" = '1' and rp.\"is_active\" = 1 AND p.\"permission_type\"='APP' order by p.\"sort\"")
List<Permission> listByBackApp(Long appRoleId);
@Select("select getPermissionChildList(#{id})")
@Select("WITH RECURSIVE permission_tree(id, path) AS (\n" +
" SELECT \"id\", TO_CHAR(\"id\") AS path\n" +
" FROM \"ynrealname\".\"sys_permission\"\n" +
" WHERE \"id\" = #{id}\n" +
" \n" +
" UNION ALL\n" +
" \n" +
" SELECT p.\"id\", t.path || ',' || TO_CHAR(p.\"id\")\n" +
" FROM \"ynrealname\".\"sys_permission\" p\n" +
" INNER JOIN permission_tree t ON p.\"parentId\" = t.id\n" +
")\n" +
"SELECT LISTAGG(id,',') AS result\n" +
"FROM permission_tree;")
String getChildString(Long id);
}

View File

@ -9,7 +9,7 @@ import java.util.Map;
@Mapper
public interface RoleDao {
@SelectKey(statement = "SELECT IDENTITY()", keyProperty = "id", before = false, resultType = Long.class)
@SelectKey(statement = "SELECT @@IDENTITY", keyProperty = "id", before = false, resultType = Long.class)
@Insert("insert into \"ynrealname\".\"sys_role\"(\"name\", \"company_id\", \"description\", \"type\", \"level\", \"status\") values(#{name}, #{companyId}, #{description}, #{type}, #{level}, #{status})")
int save(Role role);

View File

@ -16,7 +16,7 @@ public interface SubCompanyDao {
@Select("SELECT \"id\",\"name\" AS subCompanyName FROM \"ynrealname\".\"pm_dept\" where \"name\" = #{companyName} and \"is_active\" = '1'")
SubCompanyBean getCompanyByName(String companyName);
@SelectKey(statement = "SELECT IDENTITY()", keyProperty = "id", before = false, resultType = Long.class)
@SelectKey(statement = "SELECT @@IDENTITY", keyProperty = "id", before = false, resultType = Long.class)
@Insert("INSERT INTO \"ynrealname\".\"pm_dept\"(\"name\", \"abbreviation\", \"company_id\", \"status\", \"is_active\") VALUES (#{subCompanyName}, #{abbreviation}, #{companyId}, '1', '1')")
int saveCompany(SubCompanyBean o);

View File

@ -7,61 +7,61 @@
<select id="getAll" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
SELECT
po.ID AS id,
po.PARENT_ID AS pId ,
po.COMPANY_ID as companyId,
po.NAME as name,
po."id" AS id,
po."parent_id" AS pId ,
po."company_id" as companyId,
po."name" as name,
po."foreign_id" as foreignId
FROM
"ynrealname"."pm_organization" po
LEFT JOIN "ynrealname"."pm_company" pc on po.COMPANY_ID = pc.ID
LEFT JOIN "ynrealname"."pm_company" pc on po."company_id" = pc."id"
WHERE
po."is_active" = '1'
<if test="companyId!=null and companyId!='' ">
and pc.ID =#{companyId}
and pc."id" =#{companyId}
</if>
<if test="childList!=null and childList!='' ">
and po.ID in (${childList})
and po."id" in (${childList})
</if>
</select>
<select id="getAllRl" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
SELECT
po.ID AS id,
po.PARENT_ID AS pId ,
po.ID as companyId,
po.NAME as name,
po."id" AS id,
po."parent_id" AS pId ,
po."id" as companyId,
po."name" as name,
po."foreign_id" as foreignId
FROM
"ynrealname"."pm_organization" po
LEFT JOIN "ynrealname"."pm_company" pc on po.COMPANY_ID = pc.ID
LEFT JOIN "ynrealname"."pm_company" pc on po."company_id" = pc."id"
WHERE
po."is_active" = '1'
<if test="companyId!=null and companyId!='' ">
and pc.ID =#{companyId}
and pc."id" =#{companyId}
</if>
</select>
<select id="getCompanyTree" parameterType="com.bonus.bmw.basic.entity.OrgBean" resultMap="ZNode">
SELECT
ID AS id,
PARENT_ID AS pId ,
NAME as name,
COMPANY_ID as companyId,
"id" AS id,
"parent_id" AS pId ,
"name" as name,
"company_id" as companyId,
po."foreign_id" as foreignId
FROM
"ynrealname"."pm_organization"
WHERE
"is_active" = '1'
<if test="companyId!=null and companyId!='' and companyId!='0' ">
and COMPANY_ID = #{companyId}
and "company_id" = #{companyId}
</if>
</select>
<insert id="addOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
insert into "ynrealname"."pm_organization"( NAME,PARENT_ID,IS_ACTIVE,TYPE,"update_time",COMPANY_ID)
insert into "ynrealname"."pm_organization"( "name","parent_id","is_active","type","update_time","company_id")
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
</insert>
@ -69,21 +69,21 @@
update "ynrealname"."pm_organization"
<set>
<if test="name != null">
NAME =#{name},
"name" =#{name},
</if>
</set>
where ID = #{id}
where "id" = #{id}
</update>
<update id="deleteOrg" parameterType="com.bonus.bmw.basic.entity.OrgBean">
update "ynrealname"."pm_organization" set IS_ACTIVE = 0 WHERE ID = #{id}
update "ynrealname"."pm_organization" set "is_active" = 0 WHERE "id" = #{id}
</update>
<select id="findCompanyInfo" resultType="com.bonus.bmw.basic.entity.OrgBean"
parameterType="com.bonus.bmw.basic.entity.OrgBean">
SELECT po.ID as companyId,po.NAME as companyName,po.PARENT_ID as parentId
SELECT po."id" as companyId,po."name" as companyName,po."parent_id" as parentId
FROM "ynrealname"."pm_organization" po
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
WHERE po."id" = #{id} AND po."is_active" = 1
</select>
<!-- <select id="getCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">-->
@ -101,23 +101,23 @@
<select id="getSubCompany" resultType="com.bonus.bmw.basic.entity.OrgBean">
WITH RECURSIVE org_tree(orgId, orgName, parentId, "level") AS (
SELECT
ID as orgId,
NAME as orgName,
PARENT_ID as parentId,
"id" as orgId,
"name" as orgName,
"parent_id" as parentId,
1 as "level"
FROM "ynrealname"."pm_organization"
WHERE ID = #{orgId} AND IS_ACTIVE = '1'
WHERE "id" = #{orgId} AND "is_active" = '1'
UNION ALL
SELECT
po.ID as orgId,
po.NAME as orgName,
po.PARENT_ID as parentId,
po."id" as orgId,
po."name" as orgName,
po."parent_id" as parentId,
ot."level" + 1 as "level"
FROM "ynrealname"."pm_organization" po
INNER JOIN org_tree ot ON po.ID = ot.parentId
WHERE po.IS_ACTIVE = '1' AND po.PARENT_ID > 0
INNER JOIN org_tree ot ON po."id" = ot.parentId
WHERE po."is_active" = '1' AND po."parent_id" > 0
)
SELECT
orgId,

View File

@ -9,17 +9,17 @@
</delete>
<!--查询用户记录列表-->
<select id="getAppUserHistoryList" resultType="com.bonus.bmw.basic.entity.UserHistoryBean">
select ala."id" as id,ala.USER_ID as userId,su.USERNAME as userName,su."phone",ala.DEVICE_ID as deviceId,ala.DEVICE_MODEL as deviceMode,
ala.ANDROID_VERSION as androidVersion,ala.LOGIN_DATE as loginDate,ala.LOGIN_TIME as loginTime
select ala."id" as id,ala."user_id" as userId,su."username" as userName,su."phone",ala."device_id" as deviceId,ala."device_model" as deviceMode,
ala."android_version" as androidVersion,ala."login_date" as loginDate,ala."login_time" as loginTime
from "ynrealname"."app_login_audit" ala
left join "ynrealname"."sys_user" su on su."id" = ala.USER_ID
left join "ynrealname"."sys_user" su on su."id" = ala."user_id"
where ala."is_active" = '1'
and ala.LOGIN_DATE BETWEEN #{params.startTime} and #{params.endTime}
and ala."login_date" BETWEEN #{params.startTime} and #{params.endTime}
<if test="params.keyWord != null and params.keyWord!='' ">
and (
su.USERNAME like concat ('%',#{params.keyWord},'%') or
ala.DEVICE_ID like concat ('%',#{params.keyWord},'%') or
ala.DEVICE_MODEL like concat ('%',#{params.keyWord},'%')
su."username" like '%' || #{params.keyWord} || '%' or
ala."device_id" like '%' || #{params.keyWord} || '%' or
ala."device_model" like '%' || #{params.keyWord} || '%'
)
</if>
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
@ -28,14 +28,14 @@
</select>
<select id="getAppUserHistoryCount" resultType="java.lang.Integer">
select COUNT(1) from "ynrealname"."app_login_audit" ala
left join "ynrealname"."sys_user" su on su."id" = ala.USER_ID
left join "ynrealname"."sys_user" su on su."id" = ala."user_id"
where ala."is_active" = '1'
and ala.LOGIN_DATE BETWEEN #{params.startTime} and #{params.endTime}
and ala."login_date" BETWEEN #{params.startTime} and #{params.endTime}
<if test="params.keyWord != null and params.keyWord!='' ">
and (
su.USERNAME like concat ('%',#{params.keyWord},'%') or
ala.DEVICE_ID like concat ('%',#{params.keyWord},'%') or
ala.DEVICE_MODEL like concat ('%',#{params.keyWord},'%')
su."username" like '%' || #{params.keyWord} || '%' or
ala."device_id" like '%' || #{params.keyWord} || '%' or
ala."device_model" like '%' || #{params.keyWord} || '%'
)
</if>
</select>

View File

@ -172,7 +172,10 @@
insert into "ynrealname"."sys_role_user"("roleId", "userId","is_active") values(#{roleId},#{userId},'1')
</insert>
<!-- 添加用户 -->
<insert id="saveUser" useGeneratedKeys="true" keyProperty = "userId" keyColumn="id">
<insert id="saveUser">
<selectKey resultType="java.lang.Long" keyProperty="userId" order="BEFORE">
SELECT @@IDENTITY
</selectKey>
insert into "ynrealname"."sys_user"
("username", "password", "loginname", "id_number","phone",
<if test="orgId != null and orgId !=''">

View File

@ -4,10 +4,52 @@
<mapper namespace="com.bonus.bmw.person.dao.GetChildListDao">
<select id="getChildList" resultType="java.lang.String">
SELECT getChildList( #{params} )
WITH RECURSIVE child_tree(id,PATH,level) AS (
SELECT
"id",
CAST("id" AS VARCHAR(4000)) AS path,
1 AS level
FROM "ynrealname"."pm_organization"
WHERE "id" = #{params} AND "is_active" = '1'
UNION ALL
SELECT
p."id",
CAST(t.path || ',' || p."id" AS VARCHAR(4000)),
t.level + 1
FROM "ynrealname"."pm_organization" p
INNER JOIN child_tree t ON p."parent_id" = t.id
WHERE p."is_active" = '1'
)
SELECT LISTAGG(id, ',') WITHIN GROUP (ORDER BY level, id) AS result
FROM child_tree;
</select>
<select id="getParentList" resultType="java.lang.String">
SELECT getParentList( #{params} )
WITH RECURSIVE parent_tree(id,parent_id,allpid,level) AS (
SELECT
"id",
"parent_id",
CAST("id" AS VARCHAR(1000)) AS allpid,
1 AS level
FROM "ynrealname"."pm_organization"
WHERE "id" = #{params}
UNION ALL
SELECT
p."id",
p."parent_id",
CAST(t.allpid || ',' || p."id" AS VARCHAR(1000)),
t.level + 1
FROM "ynrealname"."pm_organization" p
INNER JOIN parent_tree t ON p."id" = t.parent_id
WHERE p."id" IS NOT NULL
)
SELECT allpid AS result
FROM parent_tree
ORDER BY level DESC
FETCH FIRST 1 ROW ONLY;
</select>
</mapper>

View File

@ -5,29 +5,29 @@
<mapper namespace="com.bonus.system.logs.dao.SysOperLogMapper">
<sql id="selectOperLogVo">
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time
from sys_oper_log
select "oper_id", "title", "business_type", "method", "request_method", "operator_type", "oper_name", "dept_name", "oper_url", "oper_ip", "oper_param", "json_result", "status", "error_msg", "oper_time"
from "ynrealname"."sys_oper_log"
</sql>
<sql id="where">
<where>
a.opersTime BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
a."opersTime" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
<if test="params != null">
<if test="params.type != null and params.type != ''">
and a.operatoType = #{params.type}
and a."operatoType" = #{params.type}
</if>
<if test="params.module != null and params.module != ''">
and locate(#{params.module},a.title) > 0
and INSTR(a."title", #{params.module}) > 0
</if>
<if test="params.result != null and params.result != ''">
and locate(#{params.result},a.jsonResult) > 0
and INSTR(a."jsonResult", #{params.result}) > 0
</if>
<if test="params.keyWord != null and params.keyWord != ''">
and (
a.title like concat('%', #{params.keyWord}, '%') or
a.type like concat('%', #{params.keyWord}, '%') or
a.operName like concat('%', #{params.keyWord}, '%') or
a.phone like concat('%', #{params.keyWord}, '%')
a."title" like '%' || #{params.keyWord} || '%' or
a."type" like '%' || #{params.keyWord} || '%' or
a."operName" like '%' || #{params.keyWord} || '%' or
a."phone" like '%' || #{params.keyWord} || '%'
)
</if>
</if>
@ -43,35 +43,35 @@
<include refid="selectOperLogVo"/>
<where>
<if test="title != null and title != ''">
AND title like concat('%', #{title}, '%')
AND "title" like '%' || #{title} || '%'
</if>
<if test="businessType != null">
AND business_type = #{businessType}
AND "business_type" = #{businessType}
</if>
<if test="businessTypes != null and businessTypes.length > 0">
AND business_type in
AND "business_type" in
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
#{businessType}
</foreach>
</if>
<if test="status != null">
AND status = #{status}
AND "status" = #{status}
</if>
<if test="operName != null and operName != ''">
AND oper_name like concat('%', #{operName}, '%')
AND "oper_name" like '%' || #{operName} || '%'
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(oper_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
and to_char("oper_time", 'YYYYMMDD') &gt;= to_char(to_date(#{params.beginTime}, 'YYYY-MM-DD'), 'YYYYMMDD')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
and to_char("oper_time", 'YYYYMMDD') &lt;= to_char(to_date(#{params.endTime}, 'YYYY-MM-DD'), 'YYYYMMDD')
</if>
</where>
order by oper_id desc
order by "oper_id" desc
</select>
<delete id="deleteOperLogByIds" parameterType="Long">
delete from sys_oper_log where oper_id in
delete from "ynrealname"."sys_oper_log" where "oper_id" in
<foreach collection="array" item="operId" open="(" separator="," close=")">
#{operId}
</foreach>
@ -79,40 +79,40 @@
<select id="selectOperLogById" parameterType="Long" resultType="com.bonus.system.api.domain.SysOperLog">
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
where "oper_id" = #{operId}
</select>
<select id="count" resultType="java.lang.Integer">
SELECT
count(1)
FROM
sys_oper_log sol
"ynrealname"."sys_oper_log" sol
where
create_time BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
"create_time" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
<if test="params.type != null and params.type != ''">
and operator_type = #{params.type}
and "operator_type" = #{params.type}
</if>
<if test="params.module != null and params.module != ''">
and locate(#{params.module},title) > 0
and INSTR("title", #{params.module}) > 0
</if>
<if test="params.result != null and params.result != ''">
and locate(#{params.result},json_result) > 0
and INSTR("json_result", #{params.result}) > 0
</if>
</select>
<select id="list" resultType="com.bonus.system.api.domain.SysOperLog">
select
su.username AS operName,
su.phone,
su."username" AS operName,
su."phone",
a.*
from(
SELECT
user_id,
oper_id AS operId,
title,
json_result as jsonResult,
"user_id",
"oper_id" AS operId,
"title",
"json_result" as jsonResult,
CASE
business_type
"business_type"
WHEN 1 THEN '查询'
WHEN 2 THEN '新增'
WHEN 3 THEN '修改'
@ -126,35 +126,35 @@
ELSE '其他'
END AS type,
CASE
operator_type
"operator_type"
WHEN 1 THEN '后台'
WHEN 2 THEN 'APP'
ELSE '其他'
END AS operatoType ,
create_time AS opersTime
"create_time" AS opersTime
FROM
sys_oper_log
"ynrealname"."sys_oper_log"
where
create_time BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
"create_time" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
<if test="params.type != null and params.type != ''">
and operator_type = #{params.type}
and "operator_type" = #{params.type}
</if>
<if test="params.module != null and params.module != ''">
and locate(#{params.module},title) > 0
and INSTR("title", #{params.module}) > 0
</if>
<if test="params.result != null and params.result != ''">
and locate(#{params.result},json_result) > 0
and INSTR("json_result", #{params.result}) > 0
</if>
) a
LEFT JOIN sys_user su ON su.id = a.user_id
LEFT JOIN "ynrealname"."sys_user" su ON su."id" = a."user_id"
order by a.opersTime DESC
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
limit #{offset}, #{limit}
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
</if>
</select>
<update id="cleanOperLog">
truncate table sys_oper_log
truncate table "ynrealname"."sys_oper_log"
</update>
</mapper>