New file |
| | |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| | | |
| | | public interface IUserService { |
| | | |
| | | User getUser(String username, String password); |
| | | |
| | | boolean changePassword(int id, String password); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.genersoft.iot.vmp.service.IUserService; |
| | | import com.genersoft.iot.vmp.storager.dao.UserMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class UserServiceImpl implements IUserService { |
| | | |
| | | @Autowired |
| | | private UserMapper userMapper; |
| | | |
| | | |
| | | @Override |
| | | public User getUser(String username, String password) { |
| | | return userMapper.select(username, password); |
| | | } |
| | | |
| | | @Override |
| | | public boolean changePassword(int id, String password) { |
| | | User user = userMapper.selectById(id); |
| | | user.setPassword(password); |
| | | return userMapper.update(user) > 0; |
| | | } |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.storager.dao; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| | | import org.apache.ibatis.annotations.*; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface UserMapper { |
| | | |
| | | @Insert("INSERT INTO user (username, password, roleId, create_time) VALUES" + |
| | | "('${username}', '${password}', '${roleId}', datetime('now','localtime'))") |
| | | int add(User user); |
| | | |
| | | @Update("UPDATE user " + |
| | | "SET username=#{username}," + |
| | | "password=#{password}," + |
| | | "roleId=#{roleId}" + |
| | | "WHERE id=#{id}") |
| | | int update(User user); |
| | | |
| | | @Delete("DELETE FROM user WHERE app=#{app} AND id=#{id}") |
| | | int delete(User user); |
| | | |
| | | @Select("select * FROM user WHERE username= #{username} AND password=#{password}") |
| | | User select(String username, String password); |
| | | |
| | | @Select("select * FROM user WHERE id= #{id}") |
| | | User selectById(int id); |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.storager.dao.dto; |
| | | |
| | | public class User { |
| | | |
| | | private int id; |
| | | private String username; |
| | | private String password; |
| | | private String createTime; |
| | | private int roleId; |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getUsername() { |
| | | return username; |
| | | } |
| | | |
| | | public void setUsername(String username) { |
| | | this.username = username; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) { |
| | | this.password = password; |
| | | } |
| | | |
| | | public String getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(String createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public int getRoleId() { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(int roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.vmanager.user; |
| | | |
| | | import com.genersoft.iot.vmp.service.IUserService; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | |
| | | @RequestMapping("/api/user") |
| | | public class UserController { |
| | | |
| | | @Value("${auth.username}") |
| | | private String usernameConfig; |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Value("${auth.password}") |
| | | private String passwordConfig; |
| | | |
| | | @ApiOperation("登录") |
| | | @ApiImplicitParams({ |
| | |
| | | }) |
| | | @GetMapping("/login") |
| | | public String login(String username, String password){ |
| | | if (!StringUtils.isEmpty(username) && username.equals(usernameConfig) |
| | | && !StringUtils.isEmpty(password) && password.equals(passwordConfig)) { |
| | | User user = userService.getUser(username, password); |
| | | if (user != null) { |
| | | return "success"; |
| | | }else { |
| | | return "fail"; |
| | |
| | | package com.genersoft.iot.vmp.web; |
| | | |
| | | import com.genersoft.iot.vmp.service.IUserService; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.User; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @RequestMapping(value = "/auth") |
| | | public class AuthController { |
| | | |
| | | @Value("${auth.username}") |
| | | private String username; |
| | | |
| | | @Value("${auth.password}") |
| | | private String password; |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @RequestMapping("/login") |
| | | public String devices(String name, String passwd){ |
| | | if (!StringUtils.isEmpty(name) && name.equals(username) |
| | | && !StringUtils.isEmpty(passwd) && passwd.equals(password)) { |
| | | User user = userService.getUser(name, passwd); |
| | | if (user != null) { |
| | | return "success"; |
| | | }else { |
| | | return "fail"; |
| | |
| | | # [可选] 默认设备认证密码,后续扩展使用设备单独密码 |
| | | password: admin123 |
| | | |
| | | # 登陆的用户名密码 |
| | | auth: |
| | | # [可选] 用户名 |
| | | username: admin |
| | | # [可选] 密码, 默认为admin |
| | | password: 21232f297a57a5a743894a0e4a801fc3 |
| | | |
| | | #zlm服务器配置 |
| | | media: |
| | | # [必须修改] zlm服务器的内网IP |
| | |
| | | console.log(message) |
| | | } |
| | | }, |
| | | destroyed() { |
| | | this.easyPlayer.destroy(); |
| | | }, |
| | | } |
| | | </script> |
| | | |