luo
2023-12-09 cb5ddf074d60b72e35ee4bafaec95530f53d1839
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.stylefeng.guns.modular.code.controller;
 
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stylefeng.guns.modular.system.dto.Host;
import com.stylefeng.guns.modular.system.dto.Medium;
import com.stylefeng.guns.modular.system.dto.THouseResource;
import com.stylefeng.guns.modular.system.model.AppUser;
import com.stylefeng.guns.modular.system.service.IAppUserService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.List;
 
@Controller
@RequestMapping("/base/medium")
public class MediumController {
 
 
    @Autowired
    private IAppUserService appUserService;
 
    @ResponseBody
    @GetMapping("/list")
    @ApiOperation(value = "查询中介列表", tags = {"后台-中介管理"},response = Medium.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nickname", value = "微信昵称", required = false),
//            @ApiImplicitParam(name = "userType", value = "3(中介)",dataType = "int",required = true),
            @ApiImplicitParam(name = "status", value = "状态(1=正常,2=冻结,3=删除)",dataType = "int",required = false),
            @ApiImplicitParam(name = "phone", value = "电话",required = false),
            @ApiImplicitParam(name = "pageNum", required = false),
            @ApiImplicitParam(name = "pageSize",required = false),
 
    })
    public Object list(String nickname, Integer status, String phone, @RequestParam() int pageNum, @RequestParam()int pageSize){
        Integer userType = 3;
        PageHelper.startPage(pageNum,pageSize);
 
        List<Medium>  medius =  appUserService.listMedium(nickname,userType,status,phone);
        PageInfo<Medium> info=new PageInfo<>(medius);
        System.err.println(info);
        return  info;
    }
 
 
    @ResponseBody
    @PostMapping("/add")
    @ApiOperation(value = "添加中介", tags = {"后台-中介管理"})
    public ResultUtil addHost( Medium host){
        System.out.println("===================添加房东==");
        AppUser appUser = new AppUser();
        BeanUtils.copyProperties(host,appUser);
        appUser.setInsertTime(new Date());
        appUser.setStatus(1);
        appUser.setAuditStatus(2);
        appUserService.insert(appUser);
        return ResultUtil.success("增加成功");
    }
 
 
    @ResponseBody
    @GetMapping("/pre/update")
    @ApiOperation(value = "编辑前获取中介信息", tags = {"后台-中介管理"})
    public Medium preupdate(Integer id){
        AppUser appUser = appUserService.selectById(id);
        Medium host = new Medium();
        BeanUtils.copyProperties(appUser,host);
        return host;
    }
 
    @ResponseBody
    @PutMapping("/forzen")
    @ApiOperation(value = "更改状态1=正常,2=冻结,3=删除", tags = {"后台-中介管理"})
    public ResultUtil frozen(Integer id,Integer status){
        AppUser appUser = appUserService.selectById(id);
        appUser.setStatus(status);
        appUserService.updateById(appUser);
        String res = "";
        switch (status) {
            case 1:
                res = "解冻";
                break;
            case 2:
                res = "冻结";
                break;
            case 3:
                res = "删除";
                break;
        }
        return ResultUtil.success(res+"成功");
    }
 
 
    @ResponseBody
    @PutMapping("/update")
    @ApiOperation(value = "编辑中介", tags = {"后台-中介管理"})
    public ResultUtil update(Medium host){
//        AppUser appUser = appUserService.selectById(id);
//        Host host = new Host();
        AppUser appUser =new AppUser();
        BeanUtils.copyProperties(host,appUser);
        appUserService.updateById(appUser);
        return ResultUtil.success("编辑成功");
    }
 
    @ResponseBody
    @GetMapping("/auth/list")
    @ApiOperation(value = "查询中介审核列表", tags = {"后台-中介审核管理"},response = Medium.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nickname", value = "微信昵称", required = false),
            @ApiImplicitParam(name = "userType", value = "3(中介)",dataType = "int",required = true),
            @ApiImplicitParam(name = "status", value = "状态(1=正常,2=冻结,3=删除)",dataType = "int",required = false),
            @ApiImplicitParam(name = "phone", value = "电话",required = false),
            @ApiImplicitParam(name = "pageNum", required = true),
            @ApiImplicitParam(name = "pageSize",required = true),
 
    })
    public Object aulist(String nickname, Integer userType, Integer status, String phone, int pageNum, int pageSize){
 
        PageHelper.startPage(pageNum,pageSize);
        List<Medium>  medius =  appUserService.listAuMedium(nickname,userType,status,phone);
        PageInfo<Medium> info=new PageInfo<>(medius);
        System.err.println(info);
        return  info;
    }
 
    @ResponseBody
    @PutMapping("/auth/change")
    @ApiOperation(value = "更改状态1=审核通过,2=审核拒绝,3=删除", tags = {"后台-中介审核管理"})
    public ResultUtil frozen(Integer id,Integer status,String reason){
        AppUser appUser = appUserService.selectById(id);
        if (status==1){
            appUser.setAuditStatus(2);
        }else if (status==2){
            appUser.setAuditStatus(1);
            appUser.setAuditNote(reason);
        }else if (status==3){
            appUser.setStatus(3);
        }
 
        appUserService.updateById(appUser);
 
        return ResultUtil.success("操作成功");
 
 
    }
 
 
}