!10 适配postgresql

Merge pull request !10 from oof/master
This commit is contained in:
MaxKeyTop 2022-03-07 09:56:53 +00:00 committed by Gitee
commit 7a5cdae8ca
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
33 changed files with 2107 additions and 1831 deletions

View File

@ -259,7 +259,7 @@ public class Institutions extends JpaBaseEntity implements Serializable {
}
public boolean isCaptchaSupport() {
return (captchaSupport !=null && captchaSupport.equalsIgnoreCase("YES") ? true : false);
return "YES".equalsIgnoreCase(captchaSupport);
}

View File

@ -257,13 +257,13 @@ public class LoginRepository {
userInfo.getLoginCount() + 1,
userInfo.getId()
},
new int[] { Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR });
new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.VARCHAR });
}
public void updateLastLogoff(UserInfo userInfo) {
jdbcTemplate.update( LOGOUT_USERINFO_UPDATE_STATEMENT,
new Object[] { userInfo.getLastLogoffTime(), userInfo.getId() },
new int[] { Types.VARCHAR, Types.VARCHAR });
new int[] { Types.TIMESTAMP, Types.VARCHAR });
}
public class UserInfoRowMapper implements RowMapper<UserInfo> {

View File

@ -18,15 +18,52 @@
</sql>
<select id="queryPageResults" parameterType="Accounts" resultType="Accounts">
select
*
from
mxk_accounts
where
(1=1)
where instid = #{instId}
<include refid="where_statement"/>
</select>
<select id="queryUserNotInStrategy" parameterType="AccountsStrategy" resultType="UserInfo">
select
*
from mxk_userinfo u
where u.instid = #{instId}
and not exists(
select 1 from mxk_accounts ac
where ac.appid = #{appId}
and ac.instid = #{instId}
and ac.userid = u.id
and ac.createtype='automatic'
)
<if test="filters != null and filters != ''">
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in( ${orgIdsList})
</if>
</select>
<delete id="deleteByStrategy" parameterType="AccountsStrategy">
delete from mxk_accounts ac
where ac.instid = #{instId}
and ac.createtype = 'automatic'
and ac.appid = #{appId}
and ac.strategyid = #{id}
and not exists(
select 1
from mxk_userinfo u
where instid = #{instId}
and u.id=ac.userid
<if test="filters != null and filters != ''">
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in ( ${orgIdsList})
</if>
)
</delete>
</mapper>

View File

@ -0,0 +1,31 @@
<?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="org.maxkey.persistence.mapper.AccountsStrategyMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and mas.id = #{id}
</if>
<if test="appId != null and appId != ''">
and mas.appid = #{appId}
</if>
<if test="name != null and name != ''">
and mas.name = #{name}
</if>
</sql>
<select id="queryPageResults" parameterType="AccountsStrategy" resultType="AccountsStrategy">
select
mas.*,
ma.icon appicon
from
mxk_accounts_strategy mas,
mxk_apps ma
where ma.instid = #{instId}
and mas.instid = #{instId}
and mas.appid = ma.id
<include refid="where_statement"/>
</select>
</mapper>

View File

@ -15,7 +15,6 @@
</sql>
<select id="queryPageResults" parameterType="AppsAdapters" resultType="AppsAdapters">
select
*

View File

@ -2,17 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.AppsCasDetailsMapper">
<select id="getAppDetails" parameterType="string" resultType="AppsCasDetails">
select
*
from
mxk_apps_cas_details cd,
select *
from mxk_apps_cas_details cd,
mxk_apps app
where
status = 1
where app.instid = cd.instid
and app.status = 1
and cd.id = app.id
and (
app.id = #{value}
or lower(cd.service) = lower(substring(#{value},1,length(cd.service)))
or lower(cd.service) = lower(substring(#{value}, 1, length(cd.service)))
)
</select>
</mapper>

View File

@ -3,13 +3,11 @@
<mapper namespace="org.maxkey.persistence.mapper.AppsFormBasedDetailsMapper">
<select id="getAppDetails" parameterType="string" resultType="AppsFormBasedDetails">
select
*
from
mxk_apps_form_based_details fbd,
select *
from mxk_apps_form_based_details fbd,
mxk_apps app
where
app.id = #{value}
where app.instId = fbd.instId
and app.id = #{value}
and fbd.id = #{value}
and fbd.id = app.id
and status = 1

View File

@ -2,17 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.AppsJwtDetailsMapper">
<select id="getAppDetails" parameterType="string" resultType="AppsJwtDetails">
select
*
from
mxk_apps_jwt_details jd,
<select id="getAppDetails" parameterType="string" resultType="AppsJwtDetails">
select *
from mxk_apps_jwt_details jd,
mxk_apps app
where
app.id = #{value}
where app.instid = jd.instid
and app.id = #{value}
and jd.id = #{value}
and jd.id = app.id
and status = 1
and jd.id = app.id
</select>
</mapper>

View File

@ -21,6 +21,7 @@
<if test="vendor != null and vendor != ''">
and vendor = #{vendor}
</if>
</sql>
@ -29,16 +30,14 @@
*
from
mxk_apps
where
(1=1)
where instid = #{instId}
<include refid="where_statement"/>
order by sortindex
</select>
<insert id="insertApp" parameterType="Apps">
insert into mxk_apps(
id,
insert into mxk_apps(id,
name,
icon,
loginurl,
@ -48,37 +47,29 @@
description,
vendor,
vendorurl,
credential,
sharedusername,
sharedpassword,
systemuserattr,
isextendattr,
extendattr,
userpropertys,
issignature,
isadapter,
adapterid,
adaptername,
adapter,
principal,
credentials,
visible,
sortindex,
createdby,
createddate,
status,
logouturl,
logouttype
)values(
#{id},
logouttype,
instid)
values (#{id},
#{name},
#{icon},
#{loginUrl},
@ -86,40 +77,33 @@
#{category},
#{secret},
#{description},
#{vendor} ,
#{vendor},
#{vendorUrl},
#{credential},
#{sharedUsername},
#{sharedPassword},
#{systemUserAttr},
#{isExtendAttr},
#{extendAttr},
#{userPropertys},
#{isSignature},
#{isAdapter},
#{adapterId},
#{adapterName},
#{adapter},
#{principal},
#{credentials},
#{visible},
#{sortIndex},
#{createdBy},
#{createdDate} ,
#{createdDate},
#{status},
#{logoutUrl},
#{logoutType}
)
#{logoutType},
#{instId})
</insert>
<update id="updateApp" parameterType="Apps" >
<update id="updateApp" parameterType="Apps">
update mxk_apps set
name = #{name},
<if test="icon != null">
@ -146,6 +130,8 @@
<if test="adapter != null">
isadapter = #{isAdapter},
adapterid = #{adapterId},
adaptername = #{adapterName},
adapter = #{adapter},
</if>
principal = #{principal},
@ -161,7 +147,7 @@
logouturl = #{logoutUrl},
logouttype = #{logoutType}
where
id = #{id}
ID = #{id}
</update>
<select id="queryMyApps" parameterType="UserApps" resultType="UserApps">
@ -172,6 +158,9 @@
where
app.id=gp.appid
and gp.groupid=g.id
and app.instid = #{instId}
and gp.instid = #{instId}
and g.instid = #{instId}
and app.visible != 0
and (
g.id='ROLE_ALL_USER'

View File

@ -3,16 +3,15 @@
<mapper namespace="org.maxkey.persistence.mapper.AppsSaml20DetailsMapper">
<select id="getAppDetails" parameterType="string" resultType="AppsSaml20Details">
select
svd.certissuer,
select svd.certissuer,
svd.certsubject,
svd.certexpiration,
svd.keystore,
svd.spacsurl ,
svd.spacsurl,
svd.issuer,
svd.entityid,
svd.audience,
svd.validityinterval ,
svd.validityinterval,
svd.nameidformat,
svd.encrypted,
svd.binding,
@ -21,11 +20,10 @@
svd.digestmethod,
svd.metaurl,
app.*
from
mxk_apps_saml_v20_details svd,
from mxk_apps_saml_v20_details svd,
mxk_apps app
where
app.id = #{value}
where app.instid = svd.instid
and app.id = #{value}
and svd.id = #{value}
and svd.id = app.id
and app.status = 1

View File

@ -2,14 +2,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.AppsTokenBasedDetailsMapper">
<select id="getAppDetails" parameterType="string" resultType="AppsTokenBasedDetails">
select
*
from
mxk_apps_token_based_details tbd,
<select id="getAppDetails" parameterType="string" resultType="AppsTokenBasedDetails">
select *
from mxk_apps_token_based_details tbd,
mxk_apps app
where
app.id = #{value}
where app.instid = tbd.instid
and app.id = #{value}
and tbd.id = #{value}
and tbd.id = app.id
and status = 1

View File

@ -14,19 +14,18 @@
<!-- GROUP_MEMBER User Member-->
<select id="allMemberInGroup" parameterType="GroupMember" resultType="GroupMember">
select distinct
u.id,
select distinct u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.displayname,
u.nickname,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.givenname,
u.middlename,
u.familyname,
u.gender,
@ -45,16 +44,11 @@
u.jobtitle,
u.joblevel,
u.createdby,
u.createddate,
u.modifiedby,
u.modifieddate,
u.status
from
mxk_userinfo u
where 1 = 1
from mxk_userinfo u
where instid = #{instId}
</select>
<select id="memberInGroup" parameterType="GroupMember" resultType="GroupMember">
@ -89,18 +83,16 @@
u.jobtitle,
u.joblevel,
u.createdby,
u.createddate,
u.modifiedby,
u.modifieddate,
gm.createddate,
u.status
from
mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where 1 = 1
where u.instid = #{instId}
and g.instid = #{instId}
and gm.instid = #{instId}
<if test="groupId != null and groupId != ''">
and gm.groupid = #{groupId}
and g.id = #{groupId}
@ -207,7 +199,7 @@
</if>
</select>
<update id="addDynamicGroupMember" parameterType="Groups" >
<update id="addDynamicGroupMember" parameterType="Groups">
insert into mxk_group_member(
id,
groupid,
@ -215,10 +207,10 @@
type
)
select
concat_ws('-','UD','${id}',u.id) id,
concat('${id}',u.id) id,
'${id}' groupid,
u.id memberid,
'USER-DYNAMIC' as type
'USER-DYNAMIC' TYPE
from mxk_userinfo u
where not exists(
select 1 from mxk_group_member gm
@ -234,7 +226,7 @@
</if>
</update>
<delete id="deleteDynamicGroupMember" parameterType="Groups" >
<delete id="deleteDynamicGroupMember" parameterType="Groups">
delete from mxk_group_member gm
where type = 'user-dynamic'
and gm.groupid=#{id}
@ -252,9 +244,54 @@
)
</delete>
<delete id="deleteByGroupId" parameterType="string" >
delete from mxk_group_member gm
where gm.groupid=#{value}
<select id="queryMemberByGroupId" parameterType="string" resultType="UserInfo">
select distinct u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname,
u.nickname,
u.namezhspell,
u.namezhshortspell,
u.givenname,
u.middlename,
u.familyname,
u.gender,
u.authntype,
u.mobile,
u.email,
u.workemail,
u.workphonenumber,
u.employeenumber,
u.division,
u.costcenter,
u.organization,
u.departmentid,
u.department,
u.jobtitle,
u.joblevel,
gm.createddate,
u.status
from mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where 1 = 1
and gm.groupid = #{value}
and g.id = #{value}
and gm.type in ('USER', 'USER-DYNAMIC')
and gm.groupid = g.id
and gm.memberid = u.id
</select>
<delete id="deleteByGroupId" parameterType="string">
delete
from mxk_group_member gm
where gm.groupid = #{value}
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.GroupPrivilegesMapper" >
<mapper namespace="org.maxkey.persistence.mapper.GroupPrivilegesMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
@ -35,7 +35,9 @@
mxk_apps apps,
mxk_group_privileges gp
where
gp.appid=apps.id
apps.instid = #{instId}
and gp.instid = #{instId}
and gp.appid = apps.id
and gp.groupid = #{groupId}
<include refid="where_statement"/>
</select>

View File

@ -12,14 +12,12 @@
</sql>
<select id="queryPageResults" parameterType="Groups" resultType="Groups">
select
*
from
mxk_groups
where
(1=1)
where instid = #{instId}
<include refid="where_statement"/>
</select>
@ -28,16 +26,16 @@
*
from
mxk_groups
where
dynamic = '1'
where instid = #{instId}
and dynamic = '1'
<include refid="where_statement"/>
</select>
<update id="logisticDelete" parameterType="Groups" >
<update id="logisticDelete" parameterType="Groups">
update mxk_groups set
status = '2'
where 1 = 1
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
@ -48,11 +46,30 @@
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_groups set status='2' where id in
update mxk_groups
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="queryGroupByUserId" parameterType="string" resultType="Groups">
select distinct g.*
from mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where u.instid = #{instId}
and g.instid = #{instId}
and gm.instid = #{instId}
and gm.memberid = #{value}
and u.id = #{value}
and gm.type in ('USER', 'USER-DYNAMIC')
and gm.groupid = g.id
and gm.memberid = u.id
</select>
</mapper>

View File

@ -0,0 +1,62 @@
<?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="org.maxkey.persistence.mapper.HistoryConnectorMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="conName != null and conName != ''">
and conName = #{conName}
</if>
<if test="conType != null and conType != ''">
and conType = #{conType}
</if>
<if test="sourceId != null and sourceId != ''">
and sourceId = #{sourceId}
</if>
<if test="sourceName != null and sourceName != ''">
and sourceName = #{sourceName}
</if>
<if test="objectId != null and objectId != ''">
and objectId = #{objectId}
</if>
<if test="objectName != null and objectName != ''">
and objectname = #{objectName}
</if>
<if test="result != null and result != ''">
and result = #{result}
</if>
<if test="startDate != null and startDate != ''">
and synctime >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and #{endDate} >= synctime
</if>
<if test="description != null and description != ''">
and description like '%${description}%'
</if>
</sql>
<select id="queryPageResults" parameterType="HistoryConnector" resultType="HistoryConnector">
select
*
from mxk_history_connector
where instid = #{instId}
<include refid="where_statement"/>
order by synctime desc
</select>
</mapper>

View File

@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.HistoryLoginAppsMapper" >
<mapper namespace="org.maxkey.persistence.mapper.HistoryLoginAppsMapper">
<sql id="dao_where_statement">
<if test="id != null and id != ''">
@ -19,7 +19,7 @@
and userId = #{userId}
</if>
<if test="username != null and username != ''">
and username like concat('%',#{username},'%')
and username = #{username}
</if>
<if test="displayName != null and displayName != ''">
and displayname like concat('%',#{displayName},'%')
@ -39,12 +39,13 @@
sessionid,
appid,
appname,
uid,
userId,
username,
displayname,
to_char(logintime,'YYYY-MM-DD HH24:MI:SS') as logintime
from mxk_history_login_apps
where 1 = 1
where instid = #{instId}
<include refid="dao_where_statement"/>
order by logintime desc

View File

@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.HistoryLoginMapper" >
<mapper namespace="org.maxkey.persistence.mapper.HistoryLoginMapper">
<sql id="dao_where_statement">
<if test="id != null and id != ''">
@ -37,7 +37,6 @@
</sql>
<select id="queryPageResults" parameterType="HistoryLogin" resultType="HistoryLogin">
select
id,
@ -55,18 +54,45 @@
application,
loginurl,
to_char(logintime,'YYYY-MM-DD HH24:MI:SS') as logintime,
to_char(logouttime,'YYYY-MM-DD HH24:MI:SS') as logouttime
logouttime
from mxk_history_login
where 1 = 1
where instid = #{instId}
<include refid="dao_where_statement"/>
order by logintime desc
</select>
<update id="logout" parameterType="java.lang.String" >
update mxk_history_login set
logouttime = current_timestamp
where
sessionid = #{value}
<select id="queryOnlineSession" parameterType="HistoryLogin" resultType="HistoryLogin">
select
sessionid id,
sessionid,
userId,
username,
displayname,
logintype,
message,
code,
provider,
sourceip,
browser,
platform,
application,
loginurl,
to_char(logintime,'YYYY-MM-DD HH24:MI:SS') as logintime,
logouttime
from mxk_history_login
where instid = #{instId}
and sessionstatus = 1
<include refid="dao_where_statement"/>
order by logintime desc
</select>
<update id="logout" parameterType="java.lang.String">
update mxk_history_login
set logouttime = current_timestamp
where sessionid = #{value}
</update>
</mapper>

View File

@ -0,0 +1,37 @@
<?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="org.maxkey.persistence.mapper.HistorySynchronizerMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="syncId != null and syncId != ''">
and syncid = #{syncId}
</if>
<if test="objectName != null and objectName != ''">
and objectname = #{objectName}
</if>
<if test="result != null and result != ''">
and result = #{result}
</if>
<if test="startDate != null and startDate != ''">
and synctime >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and #{endDate} >= synctime
</if>
</sql>
<select id="queryPageResults" parameterType="HistorySynchronizer" resultType="HistorySynchronizer">
select
*
from mxk_history_synchronizer
where instid = #{instId}
<include refid="where_statement"/>
order by synctime desc
</select>
</mapper>

View File

@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.HistorySystemLogsMapper" >
<mapper namespace="org.maxkey.persistence.mapper.HistorySystemLogsMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
@ -46,7 +46,7 @@
createddate,
createdby
from mxk_history_logs
where 1 = 1
where instid = #{instId}
<include refid="where_statement"/>
order by createddate desc

View File

@ -12,25 +12,22 @@
</sql>
<select id="queryPageResults" parameterType="Notices" resultType="Notices">
select
*
from
mxk_notices
where
(1=1)
instid = #{instId}
<include refid="where_statement"/>
order by modifieddate desc
</select>
<select id="queryLastedNotices" parameterType="Notices" resultType="Notices">
select
*
from
mxk_notices
order by modifieddate desc
limit 1
select *
from mxk_notices
where instid = #{instId}
order by modifieddate desc limit 1
</select>
</mapper>

View File

@ -1,37 +1,46 @@
<?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="org.maxkey.persistence.mapper.OrganizationsMapper" >
<mapper namespace="org.maxkey.persistence.mapper.OrganizationsMapper">
<sql id="dao_where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != '' ">
and name like '%#{name}%'
and name like '%${name}%'
</if>
<if test="parentId != null and parentId != '' ">
and parentid = #{parentId}
</if>
<if test="parentName != null and parentName != ''">
and parentname like '%#{parentName}%'
and parentName like '%${parentName}%'
</if>
</sql>
<select id="queryOrgs" parameterType="Organizations" resultType="Organizations">
select
*
from mxk_organizations
where instid = #{instId}
<include refid="dao_where_statement"/>
order by sortindex,id
</select>
<select id="queryPageResults" parameterType="Organizations" resultType="Organizations">
select
*
from mxk_organizations
where 1 = 1
where instid = #{instId}
<include refid="dao_where_statement"/>
order by sortindex,id
</select>
<update id="logisticDelete" parameterType="Organizations" >
<update id="logisticDelete" parameterType="Organizations">
update mxk_organizations set status = '2'
where 1 = 1
where instid = #{instId}
<if test="id != null and id != '' ">
and id = #{id}
</if>
@ -47,8 +56,10 @@
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
UPDATE MXK_ORGANIZATIONS SET STATUS = '2'
WHERE ID IN
UPDATE MXK_ORGANIZATIONS
SET STATUS = '2'
WHERE instid = #{instId}
and id in
<foreach collection="ids" item="selectId" open="(" separator="," close=")">
#{selectId}
</foreach>

View File

@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.PasswordPolicyMapper" >
<mapper namespace="org.maxkey.persistence.mapper.PasswordPolicyMapper">
</mapper>

View File

@ -0,0 +1,11 @@
<?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="org.maxkey.persistence.mapper.RegisterMapper">
<select id="findByEmail" parameterType="string" resultType="Register">
select *
from mxk_register
where workemail = #{value}
</select>
</mapper>

View File

@ -3,21 +3,15 @@
<mapper namespace="org.maxkey.persistence.mapper.RegistrationMapper">
<select id="queryUserInfoByEmail" parameterType="string" resultType="UserInfo">
select
id,
select id,
email
from
userinfo
where
email = #{value}
from userinfo
where email = #{value}
union
select
id,
select id,
workemail eamil
from
mxk_registration
where
workemail = #{value}
from mxk_registration
where workemail = #{value}
</select>
</mapper>

View File

@ -1,82 +1,77 @@
<?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="org.maxkey.persistence.mapper.ReportMapper" >
<mapper namespace="org.maxkey.persistence.mapper.ReportMapper">
<!-- DAY COUNT 一天访问量 -->
<select id="analysisDay" resultType="Integer">
select
count(id) reportcount
<select id="analysisDay" parameterType="java.util.HashMap" resultType="Integer">
select count(id) reportcount
from mxk_history_login
where
date(logintime) =current_date
where instid = #{instId}
and date (logintime) = current_date
</select>
<!-- 本月新用户统计 -->
<select id="analysisNewUsers" parameterType="String" resultType="Integer">
select
count(*) reportcount
<select id="analysisNewUsers" parameterType="java.util.HashMap" resultType="Integer">
select count(*) reportcount
from mxk_userinfo
where to_char(createddate,'YYYY-MM')=to_char(current_date,'YYYY-MM')
where instid = #{instId}
and to_char(createddate,'YYYY-MM')=to_char(current_date,'YYYY-MM')
</select>
<!-- 在线用户统计 -->
<select id="analysisOnlineUsers" parameterType="String" resultType="Integer">
select
count(*) reportcount
<select id="analysisOnlineUsers" parameterType="java.util.HashMap" resultType="Integer">
select count(*) reportcount
from mxk_userinfo
where
lastlogintime >lastlogofftime
where instid = #{instId}
and online = 1
and extract(epoch from now() - lastlogintime) &lt; 10000
</select>
<!-- 30天活跃用户统计 -->
<select id="analysisActiveUsers" parameterType="String" resultType="Integer">
select
count(*) reportcount
<select id="analysisActiveUsers" parameterType="java.util.HashMap" resultType="Integer">
select count(*) reportcount
from mxk_userinfo
where
date(lastlogintime) >(current_date - interval '30 day')
where instid = #{instId}
and date(lastlogintime) > (current_date - interval '30 day')
</select>
<!-- DAY HOUR COUNT 当天每小时 -->
<select id="analysisDayHour" parameterType="String" resultType="Map">
select
count(id) reportcount,
<select id="analysisDayHour" parameterType="java.util.HashMap" resultType="Map">
select count(id) reportcount,
to_char(logintime,'HH24') reportstring
from mxk_history_login
where
date(logintime) =current_date
where instid = #{instId}
and date (logintime) = current_date
group by reportstring
order by reportstring
</select>
<!-- 30 DAY COUNT 最近30天每天访问量-->
<select id="analysisMonth" parameterType="String" resultType="Map">
select
count(id) reportcount,
date(logintime) reportstring
<select id="analysisMonth" parameterType="java.util.HashMap" resultType="Map">
select count(id) reportcount,
date (logintime) reportstring
from mxk_history_login
where
date(logintime) >(current_date - interval '30 day')
where instid = #{instId}
and date(logintime) > (current_date - interval '30 day')
group by reportstring
order by reportstring
</select>
<!-- 30天浏览器的访问统计 -->
<select id="analysisBrowser" parameterType="Map" resultType="Map">
select
count(id) reportcount,
browser reportstring
<select id="analysisBrowser" parameterType="java.util.HashMap" resultType="Map">
select count(id) reportcount,
coalesce(browser, 'Other') reportstring
from mxk_history_login
where
date(logintime) >(current_date - interval '30 day')
where instid = #{instId}
and date(logintime) &gt; (current_date - interval '30 day')
group by reportstring
order by reportcount desc
</select>
<!-- 30天应用单点登录的访问统计 -->
<select id="analysisApp" parameterType="Map" resultType="Map">
select
count(id) reportcount,
select count(id) reportcount,
appname
from mxk_history_login_apps
where
date(logintime) >(current_date - interval '30 day')
group by appname order by reportcount desc
where instid = #{instId}
and date(logintime) &gt; (current_date - interval '30 day')
group by appname
order by reportcount desc
</select>
</mapper>

View File

@ -18,23 +18,24 @@
</sql>
<select id="queryPageResults" parameterType="Resources" resultType="Resources">
select
res.*,app.name appname
from
mxk_resources res, mxk_apps app
where
(1=1) and res.appid=app.id
res.instid = #{instId}
and app.instid = #{instId}
and res.appid=app.id
<include refid="where_statement"/>
order by res.sortindex
</select>
<update id="logisticDelete" parameterType="Resources" >
<update id="logisticDelete" parameterType="Resources">
update mxk_resources set
status = '2'
where 1 = 1
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
@ -45,7 +46,10 @@
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_resources set status='2' where id in
update mxk_resources
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>

View File

@ -14,19 +14,18 @@
<!-- ROLE_MEMBER User Member-->
<select id="allMemberInRole" parameterType="RoleMember" resultType="RoleMember">
select distinct
u.id,
select distinct u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.displayname,
u.nickname,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.givenname,
u.middlename,
u.familyname,
u.gender,
@ -45,16 +44,11 @@
u.jobtitle,
u.joblevel,
u.createdby,
u.createddate,
u.modifiedby,
u.modifieddate,
u.status
from
mxk_userinfo u
where 1 = 1
from mxk_userinfo u
where instid = #{instId}
</select>
<select id="memberInRole" parameterType="RoleMember" resultType="RoleMember">
@ -90,17 +84,16 @@
u.joblevel,
u.createdby,
u.createddate,
u.modifiedby,
u.modifieddate,
rm.createddate,
u.status
from
mxk_userinfo u,
mxk_roles r,
mxk_role_member rm
where 1 = 1
where u.instid = #{instId}
and r.instid = #{instId}
and rm.instid = #{instId}
<if test="roleId != null and roleId != ''">
and rm.roleid = #{roleId}
and r.id = #{roleId}
@ -208,7 +201,7 @@
</if>
</select>
<update id="addDynamicRoleMember" parameterType="Roles" >
<update id="addDynamicRoleMember" parameterType="Roles">
insert into mxk_role_member(
id,
roleid,
@ -216,7 +209,7 @@
type
)
select
concat_ws('-','UD','${id}',u.id) id,
concat('${id}',u.id) id,
'${id}' ROLEID,
u.id memberid,
'USER-DYNAMIC' type
@ -235,7 +228,7 @@
</if>
</update>
<delete id="deleteDynamicRoleMember" parameterType="Roles" >
<delete id="deleteDynamicRoleMember" parameterType="Roles">
delete from mxk_role_member rm
where type = 'USER-DYNAMIC'
and rm.roleid = #{id}
@ -253,9 +246,10 @@
)
</delete>
<delete id="deleteByRoleId" parameterType="string" >
delete from mxk_role_member rm
where rm.roleid=#{value}
<delete id="deleteByRoleId" parameterType="string">
delete
from mxk_role_member rm
where rm.roleid = #{value}
</delete>
</mapper>

View File

@ -15,9 +15,9 @@
select
*
from
mxk_groups
where
dynamic = '1'
mxk_roles
where instid = #{instId}
and dynamic = '1'
<include refid="where_statement"/>
</select>
@ -27,15 +27,15 @@
from
mxk_roles
where
(1=1)
instid = #{instId}
<include refid="where_statement"/>
</select>
<update id="logisticDelete" parameterType="Roles" >
<update id="logisticDelete" parameterType="Roles">
update mxk_roles set
status = '2'
where 1 = 1
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
@ -46,7 +46,10 @@
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_roles set status='2' where id in
update mxk_roles
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
@ -58,8 +61,8 @@
*
from
mxk_role_permissions
where
status = 1
where instid = #{instId}
and status = 1
<if test="id != null and id != ''">
and id = #{id}
</if>
@ -73,20 +76,21 @@
</select>
<update id="logisticDeleteRolePermissions" parameterType="java.util.List">
update mxk_role_permissions set status=9 where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
update mxk_role_permissions
set status = 9
where 1 = 1 and
<foreach item="item" collection="list" open="(" separator="or" close=")">
( id = #{item.id} and instid = #{item.instId} )
</foreach>
</update>
<insert id="insertRolePermissions" parameterType="java.util.List">
insert into mxk_role_permissions ( id,appid,roleid,resourceid,status)
insert into mxk_role_permissions ( id,appid,roleid,resourceid,status,instid)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.appId},#{item.roleId},#{item.resourceId},#{item.status})
(#{item.id},#{item.appId},#{item.roleId},#{item.resourceId},#{item.status},#{item.instId})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,27 @@
<?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="org.maxkey.persistence.mapper.SocialsProviderMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="providerName != null and providerName != ''">
and providerName like '%${providerName}%'
</if>
</sql>
<select id="queryPageResults" parameterType="SocialsProvider" resultType="SocialsProvider">
select
*
from
mxk_socials_provider
where
instid = #{instId}
<include refid="where_statement"/>
order by sortindex
</select>
</mapper>

View File

@ -17,7 +17,7 @@
from
mxk_synchronizers
where
(1=1)
instid = #{instId}
<include refid="where_statement"/>
</select>

View File

@ -12,38 +12,39 @@
</sql>
<select id="queryPageResults" parameterType="UserInfoAdjoint" resultType="UserInfoAdjoint">
select
*
from
mxk_userinfo_adjunct
where
(1=1)
instid = #{instId}
<include refid="where_statement"/>
</select>
<update id="logisticDelete" parameterType="UserInfoAdjoint" >
<update id="logisticDelete" parameterType="UserInfoAdjoint">
update mxk_userinfo_adjunct set
status = '2'
where 1 = 1
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
<if test="name != name">
and name = #{name}
and NAME = #{name}
</if>
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_userinfo_adjunct set status='2' where id in
update mxk_userinfo_adjunct
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>

View File

@ -2,14 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.UserInfoMapper">
<select id="loadByUsername" parameterType="string" resultType="UserInfo">
select
*
from
mxk_userinfo
where username = #{value}
</select>
<select id="queryPageResults" parameterType="UserInfo" resultType="UserInfo">
select
id,
@ -51,8 +43,7 @@
status
from
mxk_userinfo
where
(1=1)
where instid = #{instId}
<if test="username != null and username != ''">
and username = #{username}
</if>
@ -68,10 +59,10 @@
<if test="departmentId != null and departmentId != ''">
and departmentid = #{departmentId}
</if>
order by sortorder
order by sortorder,id
</select>
<update id="locked" parameterType="UserInfo" >
<update id="updateLocked" parameterType="UserInfo">
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@ -81,7 +72,7 @@
id = #{id}
</update>
<update id="lockout" parameterType="UserInfo" >
<update id="updateLockout" parameterType="UserInfo">
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@ -93,19 +84,19 @@
id = #{id}
</update>
<update id="changePassword" parameterType="UserInfo" >
<update id="updatePassword" parameterType="UserInfo">
update mxk_userinfo set
<if test="password != null">
password = #{password},
decipherable = #{decipherable},
passwordsettype =#{passwordSetType},
</if>
passwordsettype = 0,
passwordlastsettime = current_timestamp
where
id = #{id}
</update>
<update id="changeSharedSecret" parameterType="UserInfo" >
<update id="updateSharedSecret" parameterType="UserInfo">
update mxk_userinfo set
<if test="sharedSecret != null">
sharedsecret = #{sharedSecret},
@ -116,7 +107,7 @@
id = #{id}
</update>
<update id="changeAppLoginPassword" parameterType="UserInfo" >
<update id="updateAppLoginPassword" parameterType="UserInfo">
update mxk_userinfo set
<if test="appLoginPassword != null">
apploginpassword = #{appLoginPassword},
@ -126,7 +117,7 @@
id = #{id}
</update>
<update id="updateProtectedApps" parameterType="UserInfo" >
<update id="updateProtectedApps" parameterType="UserInfo">
update mxk_userinfo set
<if test="protectedApps != null">
protectedapps = #{protectedApps},
@ -136,7 +127,7 @@
id = #{id}
</update>
<update id="changePasswordQuestion" parameterType="UserInfo" >
<update id="updatePasswordQuestion" parameterType="UserInfo">
update mxk_userinfo set
<if test="passwordAnswer != null">
passwordquestion = #{passwordQuestion},
@ -147,7 +138,7 @@
id = #{id}
</update>
<update id="changeAuthnType" parameterType="UserInfo" >
<update id="updateAuthnType" parameterType="UserInfo">
update mxk_userinfo set
<if test="authnType != null">
authntype = #{authnType},
@ -157,7 +148,7 @@
id = #{id}
</update>
<update id="changeEmail" parameterType="UserInfo" >
<update id="updateEmail" parameterType="UserInfo">
update mxk_userinfo set
<if test="email != null">
email = #{email},
@ -173,7 +164,7 @@
id = #{id}
</update>
<update id="changeMobile" parameterType="UserInfo" >
<update id="updateMobile" parameterType="UserInfo">
update mxk_userinfo set
<if test="mobile != null">
mobile = #{mobile},
@ -186,14 +177,7 @@
id = #{id}
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_userinfo set status='2' where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateProfile" parameterType="UserInfo" >
<update id="updateProfile" parameterType="UserInfo">
update mxk_userinfo set
displayname = #{displayName},
nickname = #{nickName},
@ -249,4 +233,30 @@
id = #{id}
</update>
<select id="findDeptsByUserId" parameterType="string" resultType="Organizations">
select o.*, 1 isPrimary
from mxk_organizations o,
mxk_userinfo u
where o.instid = #{instId}
and u.instid = #{instId}
and o.id = u.departmentid
and u.id = #{value}
union all
select o.*, 0 isPrimary
from mxk_organizations o,
mxk_userinfo_adjunct ua
where o.instid = #{instId}
and ua.instid = #{instId}
and o.id = ua.departmentid
and ua.userid = #{value}
</select>
<select id="findAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
select *
from mxk_userinfo_adjunct
where userid = #{value}
</select>
</mapper>