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;
|
}
|
}
|