panlinlin
4 years ago
9 changed files with 137 additions and 20 deletions
@ -0,0 +1,12 @@ |
|||||
|
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); |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
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; |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
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); |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
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; |
||||
|
} |
||||
|
} |
Binary file not shown.
Loading…
Reference in new issue