牛股项目流程(三)

2023-11-01 00:50
文章标签 流程 项目 牛股

本文主要是介绍牛股项目流程(三),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

牛股项目流程(三)

    • 用户名修改页面的建立
      • 页面布局设计
      • script逻辑方面
      • 效果图
      • 用户名修改页面的后端部分
        • 后端Controller层中的修改用户名的方法
        • Service层中的修改用户名的方法
        • Dao层中修改用户名的方法
      • 用户名修改页面的前后端测试
    • 密码修改页面的建立
      • 页面布局设计
      • script逻辑部分
      • 效果图
      • 更新问题

在完成分时图的设计后,下一步的负责部分是用户的用户名修改页面和密码修改页面的设计。

用户名修改页面的建立

在vue项目的src文件夹里,在components文件夹里创建一个vue文件,命名为changeuser.vue。

页面布局设计

用户名修改的页面布局比较简洁,因为前端向后端发送请求时要发送两个参数:用户的id(在这里面为邮箱),用户需要输入修改的昵称内容。由于在用户登录的时候,在vue的store文件夹里(vue仓库)自动存入了登录的用户id,所以用户的id可以通过调用store来提取,在前端页面中只需要拿到用户想要修改的昵称内容即可。所以只需要一个输入框以及一个修改按钮。

//template部分
<template>
<div style="left: 500px;position: absolute;top: 200px;width: 600px;height:300px;background: #ffffff;border-radius: 10px"><el-form label-width="0px" style="margin: 0;padding: 0"><div class="login-title" >scow修改用户名</div><!--div style="margin-top:5px"></div--><div class="input" ><el-form-item  prop="newuser"><el-input class="textarea" v-model="newuser"  placeholder="请输入新用户名"></el-input></el-form-item></div><div class="button-my"><el-form-item><el-button  class="el-button–primary" type="success" @click="confirm"  style="width:500px;position: absolute;left: 45px;top: 50px" >确定</el-button></el-form-item></div>
</el-form>
</div>
</template>
//style部分
<style scoped>.input{}.button-my{margin: 0 0px 40px 5px;}.el-button–primary{color: #ffffff;font-size: 20px;font-weight: bold;font-family: “Microsoft YaHei”;}.textarea>>>.el-input__inner{border-left-color: #ffffff;border-right-color: #ffffff;border-top-color: #ffffff;border-bottom-color: #DDDDDD;border-bottom-width: 2px;border-radius: 0;width: 500px;height: 60px;left: 50px;position: absolute;top: 0;font-family: Microsoft YaHei;}.login-title {margin: 0 0px 40px 90px;color: #000000;font-size: 32px;text-align: center;font-weight: normal;margin: 0 0 18px 0;margin-top: 0px;margin-right: 0px;margin-bottom: 18px;margin-left: 0px;color:#666666;font-family: Microsoft YaHei;}
</style>

script逻辑方面

如果用户没有输入内容就点击了修改按钮,则会返回一个警告提醒用户输入的内容不能为空;如果用户输入了新昵称并修改成功会返回一个提示来提醒用户修改成功;最后用户点击修改按钮后前端会将数据传递给后端并对数据库进行修改。

<script>
import axios from 'axios'
export default {data() {return{username: '',newuser: ''}},methods:{usernull() {this.$message.error('用户名不能为空');},sucessuser() {this.$message({message: '用户名修改成功',type: 'success'});},confirm(){//数据传输const newusername = this.newuser.toString()if(newusername==''){this.usernull()}else{axios.get('api/user/ChangeNickname', {params: {userid: this.$store.state.accout,name: this.newuser}}).then(res=>{console.log(res.data)if(res.data.code === '200'){this.$store.commit("logname",newusername);this.sucessuser()}this.newuser=''
//        console.log(res.data)}).catch(err=>{console.log(err)})}}}
}
</script>

效果图

在这里插入图片描述

用户名修改页面的后端部分

后端Controller层中的修改用户名的方法
	@RequestMapping(value = "/ChangeNickname",method = RequestMethod.GET )@ResponseBodypublic CommonResult ChangeNickname(@NotNull(message = "userid 不允许为空") String userid,String name){return  umsAdminService.ChangeNickname(userid,name);}
Service层中的修改用户名的方法
	@Overridepublic CommonResult ChangeNickname(String userid, String nemNickname) {userDao.upDataForNicknameById(userid,nemNickname);return CommonResult.success(userid);}
Dao层中修改用户名的方法
<update id="upDataForNicknameById" parameterType="java.util.Map">UPDATE users SET nickname = #{nickname,jdbcType=VARCHAR} where userid=#{userid}
</update>

用户名修改页面的前后端测试

在修改用户的昵称之前,先在数据库里查看用户id为2的用户的昵称:
在这里插入图片描述
可以看到此时用户id为2的用户昵称为777。

在浏览器中输入后端对应的接口地址:http://localhost:9000/user/ChangeNickname?userid=2&name=555,然后得到的返回信息如下:
在这里插入图片描述
可以得到的修改成功的返回数据有三个,我们以code的内容为标准,如果返回的code的值为200,则修改用户名成功。此时数据库中用户id为2的昵称为:
在这里插入图片描述
可以看到修改成功了。

随后我们再从前端开始测试,我们选择将用户id为2的用户昵称从777改为888:
在这里插入图片描述

可以看到修改成功的返回提示:
在这里插入图片描述
再从数据库中查看id为2的用户的昵称是否改变:
在这里插入图片描述

可以看到id为2的用户的昵称从555变为了888,测试成功!

密码修改页面的建立

与用户名修改页面的建立相同,在vue项目的src文件夹里,在components文件夹里创建一个vue文件,命名为changepass.vue。

页面布局设计

密码修改页面初步设定的内容是两个输入框,分别是输入原密码和输入要修改的密码。另外在vue的store文件夹中拿到当前登录的用户的id,所以一共向后端传三个参数。

//template部分
<template>
<div style="left: 500px;position: absolute;top: 200px;width: 600px;height: 320px;background: #ffffff;border-radius: 10px"><el-form  label-width="0px" style="margin: 0;padding: 0"><div class="login-title" >scow修改密码</div><!--div style="margin-top:5px"></div--><div class="input" >
<el-form-item  prop="password" style="border: none"><el-input class="textarea"  v-model="pass" placeholder="请输入原密码" ></el-input></el-form-item><el-form-item  prop="Password"><el-input class="textarea" v-model="newpass"  placeholder="请输入新密码"  ></el-input></el-form-item></div><div class="button-my"><el-form-item><el-button  class="el-button–primary" type="success" @click="confirm"  style="width:500px;position: absolute;left: 40px;top: 70px" >确定</el-button></el-form-item></div>
</el-form>
</div>
</template>
//style部分
<style scoped>.input{}.button-my{margin: 0 0px 40px 5px;}.el-button–primary{color: #ffffff;font-size: 20px;font-weight: bold;font-family: “Microsoft YaHei”;}.textarea>>>.el-input__inner{border-left-color: #ffffff;border-right-color: #ffffff;border-top-color: #ffffff;border-bottom-color: #DDDDDD;border-bottom-width: 2px;border-radius: 0;width: 500px;height: 60px;font-family: Microsoft YaHei;position: absolute;left: 40px;}.login-title {margin: 0 0px 40px 90px;color: #000000;font-size: 32px;text-align: center;font-weight: normal;margin: 0 0 18px 0;margin-top: 0px;margin-right: 0px;margin-bottom: 18px;margin-left: 0px;color:#666666;font-family: Microsoft YaHei;}
</style>

script逻辑部分

与用户名修改页面一样,密码修改页面对输入框也有判空的警告提示以及修改成功的消息提示,但是密码修改还多了一个要求就是输入的原密码内容要与此时用户的密码相同,如果不同的话还是会判定成密码修改失败。这个功能的实现放在后端,在后端提取用户数据库当前的密码与输入的原密码进行相等的判断,如果不相等则返回false,相等则进行修改,然后返回true。

<script>
import axios from 'axios'
export default {data() {return{pass: '',newpass: ''}},methods:{passnull() {this.$message.error('原始密码不能为空');},newpassnull() {this.$message.error('新密码不能为空');},sucesspass() {this.$message({message: '密码修改成功',type: 'success'});},confirm(){//数据传输const password = this.pass.toString()const newpassword = this.newpass.toString()if (password == ''){this.passnull()}else if(newpassword == ''){this.newpassnull()}else{axios.get('api/changepass', {params: {account: this.$store.state.accout,password: this.pass,newpassword: this.newpass}}).then(res=>{if(res.data === true){this.$alert('修改成功', '提示', {confirmButtonText: '确定'});}else if(res.data === false){this.sucesspass()}}).catch(err=>{console.log(err)})}}}
}
</script>

效果图

在这里插入图片描述

更新问题

在项目后期对后端进行了大整改,最后决定在密码修改部分加入邮箱验证码,密码修改页面的前端修改及测试就交给了组长来处理。

这篇关于牛股项目流程(三)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/319308

相关文章

精选20个好玩又实用的的Python实战项目(有图文代码)

《精选20个好玩又实用的的Python实战项目(有图文代码)》文章介绍了20个实用Python项目,涵盖游戏开发、工具应用、图像处理、机器学习等,使用Tkinter、PIL、OpenCV、Kivy等库... 目录① 猜字游戏② 闹钟③ 骰子模拟器④ 二维码⑤ 语言检测⑥ 加密和解密⑦ URL缩短⑧ 音乐播放

Springboot项目启动失败提示找不到dao类的解决

《Springboot项目启动失败提示找不到dao类的解决》SpringBoot启动失败,因ProductServiceImpl未正确注入ProductDao,原因:Dao未注册为Bean,解决:在启... 目录错误描述原因解决方法总结***************************APPLICA编

Spring Boot 中的默认异常处理机制及执行流程

《SpringBoot中的默认异常处理机制及执行流程》SpringBoot内置BasicErrorController,自动处理异常并生成HTML/JSON响应,支持自定义错误路径、配置及扩展,如... 目录Spring Boot 异常处理机制详解默认错误页面功能自动异常转换机制错误属性配置选项默认错误处理

在IntelliJ IDEA中高效运行与调试Spring Boot项目的实战步骤

《在IntelliJIDEA中高效运行与调试SpringBoot项目的实战步骤》本章详解SpringBoot项目导入IntelliJIDEA的流程,教授运行与调试技巧,包括断点设置与变量查看,奠定... 目录引言:为良驹配上好鞍一、为何选择IntelliJ IDEA?二、实战:导入并运行你的第一个项目步骤1

Spring Boot从main方法到内嵌Tomcat的全过程(自动化流程)

《SpringBoot从main方法到内嵌Tomcat的全过程(自动化流程)》SpringBoot启动始于main方法,创建SpringApplication实例,初始化上下文,准备环境,刷新容器并... 目录1. 入口:main方法2. SpringApplication初始化2.1 构造阶段3. 运行阶

使用Go实现文件复制的完整流程

《使用Go实现文件复制的完整流程》本案例将实现一个实用的文件操作工具:将一个文件的内容完整复制到另一个文件中,这是文件处理中的常见任务,比如配置文件备份、日志迁移、用户上传文件转存等,文中通过代码示例... 目录案例说明涉及China编程知识点示例代码代码解析示例运行练习扩展小结案例说明我们将通过标准库 os

Ubuntu 24.04启用root图形登录的操作流程

《Ubuntu24.04启用root图形登录的操作流程》Ubuntu默认禁用root账户的图形与SSH登录,这是为了安全,但在某些场景你可能需要直接用root登录GNOME桌面,本文以Ubuntu2... 目录一、前言二、准备工作三、设置 root 密码四、启用图形界面 root 登录1. 修改 GDM 配

IntelliJ IDEA2025创建SpringBoot项目的实现步骤

《IntelliJIDEA2025创建SpringBoot项目的实现步骤》本文主要介绍了IntelliJIDEA2025创建SpringBoot项目的实现步骤,文中通过示例代码介绍的非常详细,对大家... 目录一、创建 Spring Boot 项目1. 新建项目2. 基础配置3. 选择依赖4. 生成项目5.

深度解析Java项目中包和包之间的联系

《深度解析Java项目中包和包之间的联系》文章浏览阅读850次,点赞13次,收藏8次。本文详细介绍了Java分层架构中的几个关键包:DTO、Controller、Service和Mapper。_jav... 目录前言一、各大包1.DTO1.1、DTO的核心用途1.2. DTO与实体类(Entity)的区别1

Spring Security中用户名和密码的验证完整流程

《SpringSecurity中用户名和密码的验证完整流程》本文给大家介绍SpringSecurity中用户名和密码的验证完整流程,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定... 首先创建了一个UsernamePasswordAuthenticationTChina编程oken对象,这是S