早晨四点起来,开发个基于SpringBoot+微信小程序汽车服务系统。
困死我了。
有时候甚至在同一所大学,同一个专业,有的学生大四毕业可以拿到四五十w的年薪,有的学生毕业找不到工作。
甚至挂科、重修,延期一年毕业![流泪]
现实就是这样,差距大的让人惊叹!究竟是什么原因造成了这样??
我读本科的时候,大三时候我已经作为队长获得软件大赛一等奖,而有的同学才开始学习编程,研一下的时候,很多同学刚开始准备开题,而我已经接了很多的外包项目。
包括后来,有公司给我高薪、高职位,我依然认清现状。程序员这个行业很特殊。
一 视频演示界面图
二 核心代码
/**
源码或者开发,都可以找小孟V:codingxm
*/
@RestController
public class AccountController {
@Resource
private UserInfoService userInfoService;
@GetMapping("/logout")
public Result logout(HttpServletRequest request) {
request.getSession().setAttribute("user", null);
return Result.success();
}
@GetMapping("/auth")
public Result getAuth(HttpServletRequest request) {
Object user = request.getSession().getAttribute("user");
if(user == null) {
return Result.error("401", "未登录");
}
return Result.success((UserInfo)user);
}
/**
* 注册
*/
@PostMapping("/register")
public Result<UserInfo> register(@RequestBody UserInfo userInfo, HttpServletRequest request) {
if (StrUtil.isBlank(userInfo.getName()) || StrUtil.isBlank(userInfo.getPassword())) {
throw new CustomException(ResultCode.PARAM_ERROR);
}
UserInfo register = userInfoService.add(userInfo);
HttpSession session = request.getSession();
session.setAttribute("user", register);
session.setMaxInactiveInterval(120 * 60);
return Result.success(register);
}
/**
* 登录
*/
@PostMapping("/login")
public Result<UserInfo> login(@RequestBody UserInfo userInfo, HttpServletRequest request) {
if (StrUtil.isBlank(userInfo.getName()) || StrUtil.isBlank(userInfo.getPassword())) {
throw new CustomException(ResultCode.USER_ACCOUNT_ERROR);
}
UserInfo login = userInfoService.login(userInfo.getName(), userInfo.getPassword());
HttpSession session = request.getSession();
session.setAttribute("user", login);
session.setMaxInactiveInterval(120 * 60);
return Result.success(login);
}
/**
* 重置密码为123456
*/
@PutMapping("/resetPassword")
public Result<UserInfo> resetPassword(@RequestParam String username) {
return Result.success(userInfoService.resetPassword(username));
}
@PutMapping("/updatePassword")
public Result updatePassword(@RequestBody UserInfo info, HttpServletRequest request) {
UserInfo account = (UserInfo) request.getSession().getAttribute("user");
if (account == null) {
return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
}
String oldPassword = SecureUtil.md5(info.getPassword());
if (!oldPassword.equals(account.getPassword())) {
return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
}
account.setPassword(SecureUtil.md5(info.getNewPassword()));
userInfoService.update(account);
// 清空session,让用户重新登录
request.getSession().setAttribute("user", null);
return Result.success();
}
@RestController
@RequestMapping(value = "/addressInfo")
public class AddressInfoController {
@Resource
private AddressInfoService addressInfoService;
@PostMapping
public Result<AddressInfo> add(@RequestBody AddressInfo addressInfo, HttpServletRequest request) {
addressInfoService.add(addressInfo);
return Result.success(addressInfo);
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
addressInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody AddressInfo addressInfo) {
addressInfoService.update(addressInfo);
return Result.success();
}
@GetMapping("/{id}")
public Result<AddressInfo> detail(@PathVariable Long id) {
AddressInfo addressInfo = addressInfoService.findById(id);
return Result.success(addressInfo);
}
@GetMapping
public Result<List<AddressInfo>> all() {
return Result.success(addressInfoService.findAll());
}
@GetMapping("/all/{userId}")
public Result<List<AddressInfo>> all(@PathVariable Long userId) {
return Result.success(addressInfoService.findAll(userId));
}
@GetMapping("/page/{name}")
public Result<PageInfo<AddressInfo>> page(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@PathVariable String name) {
return Result.success(addressInfoService.findPage( name, pageSize, pageNum));
}
@RestController
@RequestMapping(value = "/advertiserInfo")
public class AdvertiserInfoController {
@Resource
private AdvertiserInfoService advertiserInfoService;
@PostMapping
public Result<AdvertiserInfo> add(@RequestBody AdvertiserInfo advertiserInfo) {
advertiserInfoService.add(advertiserInfo);
return Result.success(advertiserInfo);
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
advertiserInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody AdvertiserInfo advertiserInfo) {
advertiserInfoService.update(advertiserInfo);
return Result.success();
}
@GetMapping("/{id}")
public Result<AdvertiserInfo> detail(@PathVariable Long id) {
AdvertiserInfo advertiserInfo = advertiserInfoService.findById(id);
return Result.success(advertiserInfo);
}
@GetMapping
public Result<List<AdvertiserInfo>> all() {
return Result.success(advertiserInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<AdvertiserInfo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(advertiserInfoService.findPage(name, pageNum, pageSize, request));
}
}
原文地址:https://blog.csdn.net/mengchuan6666/article/details/134686538
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_34402.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。