puzhibing
5 天以前 1f9454af3356f628c25c3e2e492869163731da56
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
157
158
159
160
161
162
163
164
package com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.model.TGaodeAccount;
import com.stylefeng.guns.modular.system.service.ITGaodeAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.Date;
import java.util.Map;
 
/**
 * 高德地图账号控制器
 *
 * @author stylefeng
 * @Date 2026-09-21
 */
@Controller
@RequestMapping("/tGaodeAccount")
public class TGaodeAccountController extends BaseController {
 
    private String PREFIX = "/system/tGaodeAccount/";
 
    @Autowired
    private ITGaodeAccountService tGaodeAccountService;
 
    /**
     * 跳转到高德地图账号首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tGaodeAccount.html";
    }
 
    /**
     * 跳转到添加高德地图账号
     */
    @RequestMapping("/tGaodeAccount_add")
    public String tGaodeAccountAdd() {
        return PREFIX + "tGaodeAccount_add.html";
    }
 
    /**
     * 跳转到修改高德地图账号
     */
    @RequestMapping("/tGaodeAccount_update/{tGaodeAccountId}")
    public String tGaodeAccountUpdate(@PathVariable Integer tGaodeAccountId, Model model) {
        TGaodeAccount tGaodeAccount = tGaodeAccountService.selectById(tGaodeAccountId);
        model.addAttribute("item", tGaodeAccount);
        LogObjectHolder.me().set(tGaodeAccount);
        return PREFIX + "tGaodeAccount_edit.html";
    }
 
    /**
     * 获取高德地图账号列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String gdKey, Integer useStatus, Integer status) {
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tGaodeAccountService.getAccountList(page, gdKey, useStatus, status));
        return super.packForBT(page);
    }
 
    /**
     * 新增高德地图账号
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TGaodeAccount tGaodeAccount) {
        if (SinataUtil.isEmpty(tGaodeAccount.getGdKey())) {
            return new ErrorTip(500, "高德key不能为空");
        }
        //校验高德key是否重复
        TGaodeAccount exist = tGaodeAccountService.selectOne(new EntityWrapper<TGaodeAccount>()
                .eq("gdKey", tGaodeAccount.getGdKey())
                .eq("delFlag", 0));
        if (SinataUtil.isNotEmpty(exist)) {
            return new ErrorTip(500, "该高德key已存在,请勿重复添加");
        }
        if (SinataUtil.isEmpty(tGaodeAccount.getUseStatus())) {
            tGaodeAccount.setUseStatus(1);
        }
        if (SinataUtil.isEmpty(tGaodeAccount.getStatus())) {
            tGaodeAccount.setStatus(1);
        }
        tGaodeAccount.setDelFlag(0);
        tGaodeAccount.setInsertTime(new Date());
        tGaodeAccount.setInsertUser(ShiroKit.getUser().getId());
        tGaodeAccountService.insert(tGaodeAccount);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除高德地图账号(逻辑删除)
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tGaodeAccountId) {
        TGaodeAccount tGaodeAccount = tGaodeAccountService.selectById(tGaodeAccountId);
        if (SinataUtil.isNotEmpty(tGaodeAccount)) {
            tGaodeAccount.setDelFlag(1);
            tGaodeAccount.setUpdateTime(new Date());
            tGaodeAccount.setUpdateUser(ShiroKit.getUser().getId());
            tGaodeAccountService.updateById(tGaodeAccount);
        }
        return SUCCESS_TIP;
    }
 
    /**
     * 修改高德地图账号
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TGaodeAccount tGaodeAccount) {
        if (SinataUtil.isEmpty(tGaodeAccount.getGdKey())) {
            return new ErrorTip(500, "高德key不能为空");
        }
        //校验高德key是否重复(排除自身)
        TGaodeAccount exist = tGaodeAccountService.selectOne(new EntityWrapper<TGaodeAccount>()
                .eq("gdKey", tGaodeAccount.getGdKey())
                .eq("delFlag", 0)
                .ne("id", tGaodeAccount.getId()));
        if (SinataUtil.isNotEmpty(exist)) {
            return new ErrorTip(500, "该高德key已存在,请勿重复添加");
        }
        tGaodeAccount.setUpdateTime(new Date());
        tGaodeAccount.setUpdateUser(ShiroKit.getUser().getId());
        tGaodeAccountService.updateById(tGaodeAccount);
        return SUCCESS_TIP;
    }
 
    /**
     * 操作高德地图账号(启用/禁用)
     */
    @RequestMapping(value = "/opt")
    @ResponseBody
    public Object opt(@RequestParam Integer tGaodeAccountId, @RequestParam Integer optType) {
        TGaodeAccount tGaodeAccount = tGaodeAccountService.selectById(tGaodeAccountId);
        if (SinataUtil.isNotEmpty(tGaodeAccount)) {
            if (1 == optType.intValue()) {  //启用
                tGaodeAccount.setStatus(1);
            } else if (2 == optType.intValue()) {  //禁用
                tGaodeAccount.setStatus(2);
            }
            tGaodeAccount.setUpdateTime(new Date());
            tGaodeAccount.setUpdateUser(ShiroKit.getUser().getId());
            tGaodeAccountService.updateById(tGaodeAccount);
        }
        return SUCCESS_TIP;
    }
}