2021-07-13 10:18:08 +08:00
|
|
|
package com.xkrs.controller;
|
|
|
|
|
|
|
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
2021-07-14 16:06:34 +08:00
|
|
|
import com.xkrs.common.tool.TokenUtil;
|
|
|
|
import com.xkrs.dao.SysUserDao;
|
2021-07-13 10:18:08 +08:00
|
|
|
import com.xkrs.model.entity.FirePointEntity;
|
2021-07-14 16:06:34 +08:00
|
|
|
import com.xkrs.model.entity.SysUserEntity;
|
2021-07-13 10:18:08 +08:00
|
|
|
import com.xkrs.model.qo.FirePointQo;
|
|
|
|
import com.xkrs.service.FirePointService;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2021-07-14 16:06:34 +08:00
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author XinYi Song
|
|
|
|
*/
|
|
|
|
@RestController
|
2021-07-14 16:06:34 +08:00
|
|
|
public class FirePointController {
|
2021-07-13 10:18:08 +08:00
|
|
|
|
|
|
|
@Resource
|
|
|
|
private FirePointService firePointService;
|
|
|
|
|
2021-07-14 16:06:34 +08:00
|
|
|
@Resource
|
|
|
|
private SysUserDao sysUserDao;
|
|
|
|
|
2021-07-13 10:18:08 +08:00
|
|
|
/**
|
|
|
|
* 添加火点数据
|
|
|
|
* @param firePointQo
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("/insertFirePoint")
|
|
|
|
public String insertFirePoint(@RequestBody FirePointQo firePointQo){
|
|
|
|
// 获取区域信息
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo);
|
|
|
|
if(firePointEntity == null){
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"添加数据失败",locale);
|
|
|
|
}else {
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功",locale);
|
|
|
|
}
|
|
|
|
}
|
2021-07-14 16:06:34 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试
|
|
|
|
* @param token
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectUserName")
|
|
|
|
@PreAuthorize("hasAnyAuthority('auth_general_user')")
|
|
|
|
public String selectUserName(@RequestHeader(value="Authorization") String token){
|
|
|
|
// 获取区域信息
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
// 验证token
|
|
|
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
|
|
|
if(sysUserEntity == null){
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale);
|
|
|
|
}
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserEntity.getUserName(),locale);
|
|
|
|
}
|
2021-07-13 10:18:08 +08:00
|
|
|
}
|