原文地址:http://www.work100.net/training/monolithic-project-iot-cloud-admin-manager-edit.html
更多教程:光束云 - 免费课程
编辑账户
序号 | 文内章节 | 视频 |
---|---|---|
1 | 概述 | - |
2 | 后端代码实现 | - |
3 | 前端页面实现 | - |
4 | 测试验证 | - |
5 | 实例源码 | - |
请参照如上章节导航
进行阅读
1.概述
本节实现 编辑账户
功能,实现逻辑和 新增账户
功能类似,画面效果如下:

2.后端代码实现
AuthManagerMapper.xml 修改
修改 update
语句,将查询条件改为 userKey
,代码如下:
<update id="update">
UPDATE
auth_manager
SET
status = #{status},
superuser = #{superuser},
roles = #{roles},
updated = #{updated}
WHERE
user_key = #{userKey}
</update>
同时增加一个 getByUserKey
语句,代码如下:
<select id="getByUserKey" resultType="AuthManager">
SELECT
<include refid="authManagerColumns" />
FROM
auth_manager AS a
WHERE
a.user_key = #{userKey}
</select>
AuthManagerDao 接口修改
增加 getByUserKey
方法,代码如下:
/**
* 获取账户对象
*
* @param userKey 用户Key
* @return
*/
AuthManager getByUserKey(String userKey);
AuthManagerService 接口修改
/**
* 更新
*
* @param authManager
* @return
*/
BaseResult update(AuthManager authManager);
AuthManagerServiceImpl 实现修改
@Override
public BaseResult update(AuthManager authManager) {
if (authManagerDao.getByUserKey(authManager.getUserKey()) == null) {
return BaseResult.fail("用户不存在");