puzhibing
2023-10-08 22199bbdda579861736420fe26c2873ab0f5d21c
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
package com.sinata.shop.modular.mall.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.sinata.core.base.controller.BaseController;
import com.sinata.shop.core.common.annotion.BussinessLog;
import com.sinata.shop.core.common.annotion.Permission;
import com.sinata.shop.core.common.constant.factory.PageFactory;
import com.sinata.shop.core.log.LogObjectHolder;
import com.sinata.shop.modular.mall.model.MerchantSysUser;
import com.sinata.shop.modular.mall.service.IMerchantSysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.List;
import java.util.Map;
 
/**
 * 管理员表控制器
 * @author goku
 */
@Controller
@RequestMapping("/merchantSysUser")
public class MerchantSysUserController extends BaseController {
 
    private String PREFIX = "/mall/merchantSysUser/";
 
    @Autowired
    private IMerchantSysUserService merchantSysUserService;
 
    /**
     * 跳转到管理员表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "merchantSysUser.html";
    }
 
    /**
     * 跳转到添加管理员表
     */
    @RequestMapping("/merchantSysUser_add")
    public String merchantSysUserAdd() {
        return PREFIX + "merchantSysUser_add.html";
    }
 
    /**
     * 跳转到修改管理员表
     */
    @RequestMapping("/merchantSysUser_update/{merchantSysUserId}")
    public String merchantSysUserUpdate(@PathVariable Integer merchantSysUserId, Model model) {
        MerchantSysUser merchantSysUser = merchantSysUserService.selectById(merchantSysUserId);
        model.addAttribute("item",merchantSysUser);
        LogObjectHolder.me().set(merchantSysUser);
        return PREFIX + "merchantSysUser_edit.html";
    }
 
    /**
     * 获取管理员表列表
     */
    @ResponseBody
    @RequestMapping(value = "/list")
    public Object list(String beginTime, String endTime, String condition) {
        Page<Map<String, Object>> page = new PageFactory().defaultPage();
        Wrapper wrapper = new EntityWrapper<MerchantSysUser>().orderBy("id", false);
 
        // 时间搜索
        if(!StringUtils.isEmpty(beginTime)) {
            wrapper.ge("create_time", beginTime + " 00:00:00");
        }
        if(!StringUtils.isEmpty(endTime)) {
            wrapper.le("create_time", endTime + " 23:59:59");
        }
 
        // 查询数据列表
        List<Map<String, Object>> list = merchantSysUserService.selectMapsPage(page, wrapper).getRecords();
 
        page.setRecords(list);
        return super.packForBT(page);
    }
 
    /**
     * 新增管理员表
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "新增管理员表")
    @RequestMapping(value = "/add")
    public Object add(MerchantSysUser merchantSysUser) {
        merchantSysUserService.insert(merchantSysUser);
        return SUCCESS_TIP;
    }
    /**
     * 删除/批量删除
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "删除/批量删除管理员表")
    @RequestMapping(value = "/delete")
    public Object delete(@RequestParam String ids) {
        // 逻辑删除
        merchantSysUserService.updateForSet("is_delete = 1", new EntityWrapper<MerchantSysUser>().in("id", ids.split(",")));
        return SUCCESS_TIP;
    }
 
    /**
     * 修改管理员表
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "修改管理员表")
    @RequestMapping(value = "/update")
    public Object update(MerchantSysUser merchantSysUser) {
        merchantSysUserService.updateById(merchantSysUser);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改管理员表状态
     */
    @ResponseBody
    @BussinessLog(value = "修改管理员表状态")
    @RequestMapping(value = "/updateState")
    public Object updateState(Integer merchantSysUserId, Integer state) {
        merchantSysUserService.updateForSet("state = " + state, new EntityWrapper<MerchantSysUser>().eq("id", merchantSysUserId));
        return SUCCESS_TIP;
    }
 
    /**
     * 跳转管理员表详情
     */
    @RequestMapping(value = "/detail/{merchantSysUserId}")
    public Object detail(@PathVariable("merchantSysUserId") Integer merchantSysUserId, Model model) {
        MerchantSysUser merchantSysUser = merchantSysUserService.selectById(merchantSysUserId);
        model.addAttribute("item",merchantSysUser);
        return PREFIX + "merchantSysUser_detail.html";
    }
}