This commit is contained in:
xd 2024-05-16 16:12:15 +08:00
parent a40d03899f
commit 17720a24bc
9 changed files with 123 additions and 22 deletions

View File

@ -79,7 +79,7 @@ public class SysSapUserController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SysSapUser sysSapUser)
{
sysSapUser.setSapUserId(UUID.fastUUID().toString());
//sysSapUser.setSapUserId(UUID.fastUUID().toString());
return toAjax(sysSapUserService.insertSysSapUser(sysSapUser));
}

View File

@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.service.*;
import com.ruoyi.web.utils.SHA1;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -62,6 +63,20 @@ public class SysUserController extends BaseController
@Autowired
private ISysPostService postService;
/**
* 获取切换账号的OA登录 token
*/
@PreAuthorize("@ss.hasPermi('system:user:OAtoken')")
@GetMapping("/getSwitchAccountToken/{account}")
public AjaxResult getSwitchAccountToken(@PathVariable("account") String account)
{
AjaxResult ajax = AjaxResult.success();
//OA验证
String newToken = SHA1.shaEncode("uy4MbH"+account);
ajax.put("token", newToken);
return ajax;
}
/**
* 获取用户列表
*/

View File

@ -30,4 +30,8 @@ public class SHA1 {
return "";
}
}
public static void main(String[] args) {
System.out.println(shaEncode("uy4MbH"+"8879"));
}
}

View File

@ -7,7 +7,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
/**
* SAP账户对象 sys_sap_user
*
*
* @author ruoyi
* @date 2024-04-02
*/
@ -34,52 +34,60 @@ public class SysSapUser extends BaseEntity
@Excel(name = "系统账户名称")
private String sysUserNickName;
public void setSapUserId(String sapUserId)
/** 片区 */
@Excel(name = "片区")
private String sysUserPianqu;
public void setSapUserId(String sapUserId)
{
this.sapUserId = sapUserId;
}
public String getSapUserId()
public String getSapUserId()
{
return sapUserId;
}
public void setSapUserBm(String sapUserBm)
public void setSapUserBm(String sapUserBm)
{
this.sapUserBm = sapUserBm;
}
public String getSapUserBm()
public String getSapUserBm()
{
return sapUserBm;
}
public void setSapUserName(String sapUserName)
public void setSapUserName(String sapUserName)
{
this.sapUserName = sapUserName;
}
public String getSapUserName()
public String getSapUserName()
{
return sapUserName;
}
public void setSysUserName(String sysUserName)
public void setSysUserName(String sysUserName)
{
this.sysUserName = sysUserName;
}
public String getSysUserName()
public String getSysUserName()
{
return sysUserName;
}
public void setSysUserNickName(String sysUserNickName)
public void setSysUserNickName(String sysUserNickName)
{
this.sysUserNickName = sysUserNickName;
}
public String getSysUserNickName()
public String getSysUserNickName()
{
return sysUserNickName;
}
public String getSysUserPianqu() { return sysUserPianqu; }
public void setSysUserPianqu(String sysUserPianqu) { this.sysUserPianqu = sysUserPianqu; }
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -3,34 +3,35 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.sysSapUser.mapper.SysSapUserMapper">
<resultMap type="SysSapUser" id="SysSapUserResult">
<result property="sapUserId" column="sap_user_id" />
<result property="sapUserBm" column="sap_user_bm" />
<result property="sapUserName" column="sap_user_name" />
<result property="sysUserName" column="sys_user_name" />
<result property="sysUserNickName" column="sys_user_nick_name" />
<result property="sysUserPianqu" column="sys_user_pianqu" />
</resultMap>
<sql id="selectSysSapUserVo">
select sap_user_id, sap_user_bm, sap_user_name, sys_user_name, sys_user_nick_name from sys_sap_user
select sap_user_id, sap_user_bm, sap_user_name, sys_user_name, sys_user_nick_name, sys_user_pianqu from sys_sap_user
</sql>
<select id="selectSysSapUserList" parameterType="SysSapUser" resultMap="SysSapUserResult">
<include refid="selectSysSapUserVo"/>
<where>
<where>
<if test="sapUserBm != null and sapUserBm != ''"> and sap_user_bm like concat('%', #{sapUserBm}, '%')</if>
<if test="sapUserName != null and sapUserName != ''"> and sap_user_name like concat('%', #{sapUserName}, '%')</if>
<if test="sysUserName != null and sysUserName != ''"> and sys_user_name like concat('%', #{sysUserName}, '%')</if>
<if test="sysUserNickName != null and sysUserNickName != ''"> and sys_user_nick_name like concat('%', #{sysUserNickName}, '%')</if>
</where>
</select>
<select id="selectSysSapUserBySapUserId" parameterType="String" resultMap="SysSapUserResult">
<include refid="selectSysSapUserVo"/>
where sap_user_id = #{sapUserId}
</select>
<insert id="insertSysSapUser" parameterType="SysSapUser">
insert into sys_sap_user
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -39,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sapUserName != null and sapUserName != ''">sap_user_name,</if>
<if test="sysUserName != null and sysUserName != ''">sys_user_name,</if>
<if test="sysUserNickName != null and sysUserNickName != ''">sys_user_nick_name,</if>
<if test="sysUserPianqu != null and sysUserPianqu != ''">sys_user_pianqu,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sapUserId != null">#{sapUserId},</if>
@ -46,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sapUserName != null and sapUserName != ''">#{sapUserName},</if>
<if test="sysUserName != null and sysUserName != ''">#{sysUserName},</if>
<if test="sysUserNickName != null and sysUserNickName != ''">#{sysUserNickName},</if>
<if test="sysUserPianqu != null and sysUserPianqu != ''">#{sysUserPianqu},</if>
</trim>
</insert>
@ -56,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sapUserName != null and sapUserName != ''">sap_user_name = #{sapUserName},</if>
<if test="sysUserName != null and sysUserName != ''">sys_user_name = #{sysUserName},</if>
<if test="sysUserNickName != null and sysUserNickName != ''">sys_user_nick_name = #{sysUserNickName},</if>
<if test="sysUserPianqu != null and sysUserPianqu != ''">sys_user_pianqu = #{sysUserPianqu},</if>
</trim>
where sap_user_id = #{sapUserId}
</update>
@ -65,9 +69,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteSysSapUserBySapUserIds" parameterType="String">
delete from sys_sap_user where sap_user_id in
delete from sys_sap_user where sap_user_id in
<foreach item="sapUserId" collection="array" open="(" separator="," close=")">
#{sapUserId}
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -145,3 +145,12 @@ export function deptTreeSelect() {
method: 'get'
})
}
// 获取切换账号的OA登录 token
export function getSwitchAccountToken(account) {
return request({
url: '/system/user/getSwitchAccountToken/'+account,
method: 'get'
})
}

View File

@ -25,6 +25,17 @@
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip>
<el-dialog :title="switchAccountTitle" :visible.sync="switchAccountOpen" width="500px" append-to-body>
<el-form ref="form" :model="form" label-width="100px">
<el-form-item label="账号" prop="Name">
<el-input v-model="form.account" placeholder="请输入账号" clearable/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="switchAccountConfirm(form.account)"> </el-button>
</div>
</el-dialog>
</template>
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
@ -39,6 +50,9 @@
<el-dropdown-item @click.native="setting = true">
<span>布局设置</span>
</el-dropdown-item>
<el-dropdown-item @click.native="switchAccount" v-if="checkRole(['ITZX'])">
<span>切换账号</span>
</el-dropdown-item>
<el-dropdown-item divided @click.native="logout">
<span>退出登录</span>
</el-dropdown-item>
@ -61,7 +75,19 @@ import RuoYiDoc from '@/components/RuoYi/Doc'
import settings from '@/settings'
import NavbarNotice from "@/layout/components/NavbarNotice.vue";
import { getSwitchAccountToken } from "@/api/system/user";
import { checkRole } from "@/utils/permission"; //
export default {
data() {
return {
//
switchAccountTitle: "",
//
switchAccountOpen: false,
form: {}
}
},
components: {
Breadcrumb,
TopNav,
@ -97,6 +123,18 @@ export default {
}
},
methods: {
checkRole,
switchAccount() {
this.switchAccountTitle = "账号切换";
this.switchAccountOpen = true;
},
switchAccountConfirm(account){
// OA-token
getSwitchAccountToken(account).then(response => {
this.switchAccountOpen = false;
window.open('http://localhost:3335/ssoLogin?loginid='+account+'&token='+response.token, '_self');
})
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},

View File

@ -25,14 +25,14 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="系统账户名称" prop="sysUserNickName">
<!--<el-form-item label="系统账户名称" prop="sysUserNickName">
<el-input
v-model="queryParams.sysUserNickName"
placeholder="请输入系统账户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@ -92,6 +92,7 @@
<el-table-column label="SAP账户名称" align="center" prop="sapUserName" />
<el-table-column label="系统账户" align="center" prop="sysUserName" />
<el-table-column label="系统账户名称" align="center" prop="sysUserNickName" />
<el-table-column label="片区" align="center" prop="sysUserPianqu" />
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button
@ -147,6 +148,13 @@
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="8">
<el-col :span="12">
<el-form-item label="片区" prop="sysUserPianqu">
<el-input v-model="form.sysUserPianqu" placeholder="请输入片区" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -188,7 +196,8 @@ export default {
sapUserBm: null,
sapUserName: null,
sysUserName: null,
sysUserNickName: null
sysUserNickName: null,
sysUserPianqu: null
},
//
form: {},
@ -205,6 +214,9 @@ export default {
],
sysUserNickName: [
{ required: true, message: "系统账户名称不能为空", trigger: "blur" }
],
sysUserPianqu: [
{ required: true, message: "片区不能为空", trigger: "blur" }
]
}
};

View File

@ -39,6 +39,15 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="用户昵称" prop="nickName">
<el-input
v-model="queryParams.nickName"
placeholder="请输入用户昵称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input
v-model="queryParams.phonenumber"
@ -142,7 +151,9 @@
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
<!--
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
-->
<el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
<template slot-scope="scope">
<el-switch