添加用户操作
修正报警清理接口
This commit is contained in:
@@ -38,6 +38,6 @@ public interface IDeviceAlarmService {
|
||||
* @param deviceIdList 制定需要清理的设备id
|
||||
* @param time 不写时间则清空所有时间的
|
||||
*/
|
||||
void clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time);
|
||||
int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IUserService {
|
||||
|
||||
User getUser(String username, String password);
|
||||
@@ -9,4 +11,12 @@ public interface IUserService {
|
||||
boolean changePassword(int id, String password);
|
||||
|
||||
User getUserByUsername(String username);
|
||||
|
||||
void addUser(User user);
|
||||
|
||||
void deleteUser(int id);
|
||||
|
||||
List<User> getAllUsers();
|
||||
|
||||
void updateUsers(User user);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time) {
|
||||
deviceAlarmMapper.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
public int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time) {
|
||||
return deviceAlarmMapper.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements IUserService {
|
||||
|
||||
@@ -29,4 +31,25 @@ public class UserServiceImpl implements IUserService {
|
||||
public User getUserByUsername(String username) {
|
||||
return userMapper.getUserByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUser(User user) {
|
||||
userMapper.add(user);
|
||||
}
|
||||
@Override
|
||||
public void deleteUser(int id) {
|
||||
userMapper.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getAllUsers() {
|
||||
return userMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUsers(User user) {
|
||||
userMapper.update(user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,23 +4,28 @@ import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface UserMapper {
|
||||
|
||||
@Insert("INSERT INTO user (username, password, roleId, create_time) VALUES" +
|
||||
"('${username}', '${password}', '${roleId}', datetime('now','localtime'))")
|
||||
@Insert("INSERT INTO user (username, password, roleId, create_time, update_time) VALUES" +
|
||||
"('${username}', '${password}', '${roleId}', '${createTime}', '${updateTime}')")
|
||||
int add(User user);
|
||||
|
||||
@Update("UPDATE user " +
|
||||
"SET username=#{username}, " +
|
||||
"password=#{password}, " +
|
||||
"roleId=#{roleId} " +
|
||||
"WHERE id=#{id}")
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE user " +
|
||||
"SET update_time='${updateTime}' " +
|
||||
"<if test=\"roleId != null\">, roleId='${roleId}'</if>" +
|
||||
"<if test=\"password != null\">, password='${password}'</if>" +
|
||||
"<if test=\"username != null\">, username='${username}'</if>" +
|
||||
"WHERE id=#{id}" +
|
||||
" </script>"})
|
||||
int update(User user);
|
||||
|
||||
@Delete("DELETE FROM user WHERE app=#{app} AND id=#{id}")
|
||||
int delete(User user);
|
||||
@Delete("DELETE FROM user WHERE id=#{id}")
|
||||
int delete(int id);
|
||||
|
||||
@Select("select * FROM user WHERE username=#{username} AND password=#{password}")
|
||||
User select(String username, String password);
|
||||
@@ -30,4 +35,7 @@ public interface UserMapper {
|
||||
|
||||
@Select("select * FROM user WHERE username=#{username}")
|
||||
User getUserByUsername(String username);
|
||||
|
||||
@Select("select * FROM user")
|
||||
List<User> selectAll();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ public class User {
|
||||
private String username;
|
||||
private String password;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
private int roleId;
|
||||
|
||||
public int getId() {
|
||||
@@ -47,4 +48,12 @@ public class User {
|
||||
public void setRoleId(int roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(String updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ public class AlarmController {
|
||||
@ApiImplicitParam(name="endTime", value = "查询内容" ,dataTypeClass = String.class),
|
||||
})
|
||||
public ResponseEntity<PageInfo<DeviceAlarm>> getAll(
|
||||
int page, int count,
|
||||
@RequestParam int page,
|
||||
@RequestParam int count,
|
||||
@RequestParam(required = false) String deviceId,
|
||||
@RequestParam(required = false) String alarmPriority,
|
||||
@RequestParam(required = false) String alarmMethod,
|
||||
@@ -76,8 +77,8 @@ public class AlarmController {
|
||||
|
||||
|
||||
try {
|
||||
format.parse(startTime);
|
||||
format.parse(endTime);
|
||||
if (startTime != null) format.parse(startTime);
|
||||
if (endTime != null) format.parse(endTime);
|
||||
} catch (ParseException e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class AlarmController {
|
||||
* @param time 结束时间(这个时间之前的报警会被删除)
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("分页查询报警")
|
||||
@ApiOperation("删除报警")
|
||||
@DeleteMapping("/delete")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="id", value = "ID", required = false ,dataTypeClass = Integer.class),
|
||||
@@ -118,12 +119,17 @@ public class AlarmController {
|
||||
} catch (ParseException e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
String[] deviceIdArray = deviceIds.split(",");
|
||||
List<String> deviceIdList = Arrays.asList(deviceIdArray);
|
||||
deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
List<String> deviceIdList = null;
|
||||
if (deviceIds != null) {
|
||||
String[] deviceIdArray = deviceIds.split(",");
|
||||
deviceIdList = Arrays.asList(deviceIdArray);
|
||||
}
|
||||
|
||||
int count = deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
WVPResult wvpResult = new WVPResult();
|
||||
wvpResult.setCode(0);
|
||||
wvpResult.setMsg("success");
|
||||
wvpResult.setData(count);
|
||||
return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user