whyclxw
2024-11-28 1293a2564822ea7c281a5a9eb74488995371bda7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.AuthiruzeInfMapper;
import com.whyc.pojo.db_area.AuthiruzeInf;
import com.whyc.pojo.db_area.LockInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class AuthiruzeInfService {
    @Autowired(required = false)
    private AuthiruzeInfMapper mapper;
 
    //查询所有授权信息
    public Response getAllAuthInf(Integer state, String uname, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(state!=null){
            wrapper.eq("state",state);
        }
        if(uname!=null){
            wrapper.like("uname",uname);
        }
        List<LockInf> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询所有钥匙信息");
    }
    //添加授权
    public Response addAuth(AuthiruzeInf auth) {
        mapper.insert(auth);
        return new Response().set(1,true);
    }
    //删除授权
    public Response delAuth(Integer id) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("id",id);
        mapper.delete(wrapper);
        return new Response().set(1,true);
    }
    //修改授权
    public Response updateAuth(AuthiruzeInf auth) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("id",auth.getId());
        if(auth.getStartTime()!=null){
            wrapper.set("start_time",auth.getStartTime());
        }
        if(auth.getStopTime()!=null){
            wrapper.set("stop_time",auth.getStopTime());
        }
        if(auth.getDescript()!=null){
            wrapper.set("descript",auth.getDescript());
        }
        mapper.update(null,wrapper);
        return new Response().set(1,true);
    }
}