提交 de7697ef authored 作者: 林业通's avatar 林业通

锁修改

上级 bc7d4f24
......@@ -56,7 +56,7 @@ public class ShDevicePasswordController {
@ApiLog("待下发密码数量")
public R count(@RequestParam Map<String, Object> params) {
Integer deviceId = Integer.parseInt((String) params.get("deviceId"));
if (StringUtils.isBlank(params.get("deviceId"))) {
if (StringUtils.isBlank(deviceId)) {
return R.error("缺少参数");
}
Integer count = shDevicePasswordService.count(new QueryWrapper<ShDevicePasswordEntity>().eq("device_id", deviceId).eq("status", 1));
......@@ -91,7 +91,7 @@ public class ShDevicePasswordController {
}
passwordEntity.setExpiredTime(sdf.parse(expiredTime));
}
return shDevicePasswordService.save(passwordEntity) ? R.ok() : R.error("记录失败!");
return shDevicePasswordService.save(passwordEntity) ? R.ok() : R.error("保存失败!");
}
}
package tech.glinfo.enbao.modules.sh.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tech.glinfo.enbao.common.annotation.ApiLog;
import tech.glinfo.enbao.common.annotation.Login;
import tech.glinfo.enbao.common.utils.PageUtils;
import tech.glinfo.enbao.common.utils.Query;
import tech.glinfo.enbao.common.utils.R;
import tech.glinfo.enbao.common.utils.StringUtils;
import tech.glinfo.enbao.modules.sh.entity.ShLockUserEntity;
import tech.glinfo.enbao.modules.sh.service.ShLockUserService;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/shLockUser")
@Api(value = "锁用户", description = "锁用户")
public class ShLockUserController {
@Autowired
private ShLockUserService shLockUserService;
@Login
@PostMapping("save")
@ApiOperation("保存用户")
@ApiLog("保存用户")
public R save(@RequestBody Map<String, Object> params) {
Integer lockId = (Integer) params.get("lockId");
Integer userId = (Integer) params.get("userId");
String userName = (String) params.get("userName");
if (StringUtils.isBlank(lockId, userId, userName)) {
return R.error("参数为空!");
}
ShLockUserEntity lockUserEntity = shLockUserService.getOne(new QueryWrapper<ShLockUserEntity>().eq("lock_id", lockId).eq("user_id", userId));
if (lockUserEntity != null) {
return R.error("用户ID不能重复!");
}
ShLockUserEntity entity = new ShLockUserEntity();
entity.setLockId(lockId);
entity.setUserId(userId);
entity.setUserName(userName);
boolean flag = shLockUserService.save(entity);
return flag ? R.ok() : R.error("新增失败!");
}
@Login
@PostMapping("update")
@ApiOperation("修改用户")
@ApiLog("修改用户")
public R update(@RequestBody Map<String, Object> params) {
Integer id = (Integer) params.get("id");
Integer userId = (Integer) params.get("userId");
String userName = (String) params.get("userName");
if (StringUtils.isBlank(id, userId, userName)) {
return R.error("参数为空!");
}
ShLockUserEntity entity = new ShLockUserEntity();
entity.setId(id);
entity.setUserId(userId);
entity.setUserName(userName);
boolean flag = shLockUserService.updateById(entity);
return flag ? R.ok() : R.error("修改失败!");
}
@Login
@PostMapping("delete")
@ApiOperation("删除用户")
@ApiLog("删除用户")
public R delete(@RequestBody Map<String, Object> params) {
Integer id = (Integer) params.get("id");
if (StringUtils.isBlank(id)) {
return R.error("参数为空!");
}
boolean flag = shLockUserService.removeById(id);
return flag ? R.ok() : R.error("删除失败!");
}
@Login
@GetMapping("/list")
@ApiOperation("锁用户列表")
@ApiLog("锁用户列表")
public R list(@RequestParam Map<String, Object> params){
Integer lockId = Integer.parseInt((String) params.get("lockId"));
IPage<ShLockUserEntity> page = shLockUserService.page(
new Query<ShLockUserEntity>().getPage(params),
new QueryWrapper<ShLockUserEntity>().eq("lock_id", lockId)
);
Map<String, Object> map = new HashMap<>();
map.put("page", new PageUtils(page));
return R.ok(map);
}
}
package tech.glinfo.enbao.modules.sh.dao;
import tech.glinfo.enbao.modules.sh.entity.ShLockUserEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 锁用户
*
* @author linyetong
* @email linyetong@glinfo.com
* @date 2022-02-25 13:51:20
*/
@Mapper
public interface ShLockUserDao extends BaseMapper<ShLockUserEntity> {
}
package tech.glinfo.enbao.modules.sh.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 锁用户
*
* @author linyetong
* @email linyetong@glinfo.com
* @date 2022-02-25 13:51:20
*/
@Data
@TableName("sh_lock_user")
public class ShLockUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId
private Integer id;
/**
* 用户
*/
private Integer userId;
/**
* 锁ID
*/
private Integer lockId;
/**
* 用户名称
*/
private String userName;
/**
* 创建时间
*/
private Date createDate;
}
package tech.glinfo.enbao.modules.sh.service;
import com.baomidou.mybatisplus.extension.service.IService;
import tech.glinfo.enbao.common.utils.PageUtils;
import tech.glinfo.enbao.modules.sh.entity.ShLockUserEntity;
import java.util.Map;
/**
* 锁用户
*
* @author linyetong
* @email linyetong@glinfo.com
* @date 2022-02-25 13:51:20
*/
public interface ShLockUserService extends IService<ShLockUserEntity> {
PageUtils queryPage(Map<String, Object> params);
}
package tech.glinfo.enbao.modules.sh.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import tech.glinfo.enbao.common.utils.PageUtils;
import tech.glinfo.enbao.common.utils.Query;
import tech.glinfo.enbao.modules.sh.dao.ShLockUserDao;
import tech.glinfo.enbao.modules.sh.entity.ShLockUserEntity;
import tech.glinfo.enbao.modules.sh.service.ShLockUserService;
@Service("shLockUserService")
public class ShLockUserServiceImpl extends ServiceImpl<ShLockUserDao, ShLockUserEntity> implements ShLockUserService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<ShLockUserEntity> page = this.page(
new Query<ShLockUserEntity>().getPage(params),
new QueryWrapper<ShLockUserEntity>()
);
return new PageUtils(page);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="tech.glinfo.enbao.modules.sh.dao.ShLockUserDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="tech.glinfo.enbao.modules.sh.entity.ShLockUserEntity" id="shLockUserMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="lockId" column="lock_id"/>
<result property="userName" column="user_name"/>
<result property="createDate" column="create_date"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -311,4 +311,14 @@ CREATE TABLE `infrared_control` (
`remark` varchar(50) DEFAULT NULL COMMENT '备注',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户遥控器';
\ No newline at end of file
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户遥控器';
CREATE TABLE `sh_lock_user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`user_id` int(11) DEFAULT NULL COMMENT '用户',
`lock_id` int(11) DEFAULT NULL COMMENT '锁ID',
`user_name` varchar(50) DEFAULT NULL COMMENT '用户名称',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `sh_lock_user_lock_id` (`lock_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='锁用户';
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论