Commit 99bb83aa authored by liqin's avatar liqin 💬

bug fixed

parent 61380317
package cn.wisenergy.chnmuseum.party.common.enums;
public enum LanguageEnum {
CHINESE("Chinese", "汉语"),
MONGOLIAN("Mongolian", "蒙语"),
TIBETAN("Tibetan", "藏语"),
UYGHUR("Uyghur", "维吾尔语"),
ENGLISH("English", "英语");
// 错误编码
private String code;
// 信息
private String name;
// 相应编码有参构造函数
LanguageEnum(String code, String name) {
this.code = code;
this.name = name;
}
}
...@@ -97,6 +97,4 @@ public class ExhibitionBoard implements Serializable { ...@@ -97,6 +97,4 @@ public class ExhibitionBoard implements Serializable {
private String auditStatus; private String auditStatus;
} }
...@@ -2,6 +2,7 @@ package cn.wisenergy.chnmuseum.party.web.controller; ...@@ -2,6 +2,7 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService; import cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil; import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.common.enums.LanguageEnum;
import cn.wisenergy.chnmuseum.party.common.util.TimeUtils; import cn.wisenergy.chnmuseum.party.common.util.TimeUtils;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam; import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.Employee; import cn.wisenergy.chnmuseum.party.model.Employee;
...@@ -12,14 +13,14 @@ import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; ...@@ -12,14 +13,14 @@ import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
...@@ -30,9 +31,10 @@ import org.springframework.web.bind.annotation.*; ...@@ -30,9 +31,10 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Slf4j
@Api(tags = {"中国移动API"})
@RestController("/cmRestApi") @RestController("/cmRestApi")
public class ChinaMobileRestApiController extends BaseController { public class ChinaMobileRestApiController extends BaseController {
...@@ -77,20 +79,12 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -77,20 +79,12 @@ public class ChinaMobileRestApiController extends BaseController {
resultMap.put("message", "由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。"); resultMap.put("message", "由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} }
employee = employeeService.selectByUsername(username); employee = employeeService.selectByUsername(username);
if (employee == null) { if (employee == null) {
resultMap.put("status", 500); resultMap.put("status", 500);
resultMap.put("message", "用户名或密码不正确!"); resultMap.put("message", "用户名或密码不正确!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} }
if (!employee.getStatus()) {
throw new DisabledAccountException("此帐号已禁用,请联系管理员!");
}
if (!employee.getAllowLogin()) {
throw new DisabledAccountException("您无权访问,请联系管理员!");
}
try { try {
byte[] salt = employee.getPasswordSalt(); byte[] salt = employee.getPasswordSalt();
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(password, salt)).equals(new String(employee.getPasswordHash()))) { if (!new String(SHA256PasswordEncryptionService.createPasswordHash(password, salt)).equals(new String(employee.getPasswordHash()))) {
...@@ -105,14 +99,6 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -105,14 +99,6 @@ public class ChinaMobileRestApiController extends BaseController {
} }
throw new IncorrectCredentialsException("用户名或密码不正确!"); throw new IncorrectCredentialsException("用户名或密码不正确!");
} }
//登录时插入系统日志
String operationContent = username + "登录本系统";
if (employee.getBankBranchName() != null) {
operationContent += ",归属网点" + employee.getBankBranchName();
}
this.sysLogController.insertSysLog(operationContent, username);
String token = JwtTokenUtil.sign(username, employee.getId()); String token = JwtTokenUtil.sign(username, employee.getId());
// 将token信息存入Redis // 将token信息存入Redis
stringRedisTemplate.opsForValue().set(SHIRO_JWT_TOKEN + token, employee.getId(), 240, TimeUnit.MINUTES); stringRedisTemplate.opsForValue().set(SHIRO_JWT_TOKEN + token, employee.getId(), 240, TimeUnit.MINUTES);
...@@ -122,6 +108,8 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -122,6 +108,8 @@ public class ChinaMobileRestApiController extends BaseController {
jsonObject.put("userId", employee.getId()); jsonObject.put("userId", employee.getId());
jsonObject.put("userName", employee.getUsername()); jsonObject.put("userName", employee.getUsername());
jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(240), TimeUtils.FORMAT_ONE)); jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(240), TimeUtils.FORMAT_ONE));
jsonObject.put("orgCode", "");
jsonObject.put("orgName", "");
resultMap.put("resultCode", 200); resultMap.put("resultCode", 200);
resultMap.put("message", "成功"); resultMap.put("message", "成功");
...@@ -135,34 +123,12 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -135,34 +123,12 @@ public class ChinaMobileRestApiController extends BaseController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} }
@RequestMapping(value = "/user/logout", method = RequestMethod.GET)
public ResponseEntity<JSONObject> logout(@RequestHeader(value = "token") String token) {
try {
if (StringUtils.isNotBlank(token)) {
SecurityUtils.getSubject().logout();
this.stringRedisTemplate.delete(SHIRO_JWT_TOKEN + token);
}
JSONObject resultMap = new JSONObject();
resultMap.put("resultCode", 200);
resultMap.put("message", "成功");
resultMap.put("data", "");
return ResponseEntity.status(HttpStatus.OK).body(resultMap);
} catch (Exception e) {
LOGGER.error("注销错误!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
@ApiOperation(value = "获取单个成员信息") @ApiOperation(value = "获取单个成员信息")
@GetMapping(value = "/user/getUserInfo") @GetMapping(value = "/user/getUserInfo")
@RequiresPermissions("/user/getUserInfo")
public ResponseEntity<JSONObject> getById(String userId, @RequestHeader("token") String token) { public ResponseEntity<JSONObject> getById(String userId, @RequestHeader("token") String token) {
try { try {
Employee employee = employeeService.selectByEmpId(userId); Employee employee = employeeService.selectByEmpId(userId);
// BankBranchInfo bankBranch = this.employeeService.getById(Id);
// if (bankBranch != null) {
// employee.setBankBranchName(bankBranch.getName());
// }
if (null == employee) { if (null == employee) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} }
...@@ -173,8 +139,14 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -173,8 +139,14 @@ public class ChinaMobileRestApiController extends BaseController {
jsonObject.put("userName", employee.getUsername()); jsonObject.put("userName", employee.getUsername());
long expire = stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token) == null ? 0L : stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token); long expire = stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token) == null ? 0L : stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token);
jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(expire), TimeUtils.FORMAT_ONE)); jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(expire), TimeUtils.FORMAT_ONE));
// BankBranchInfo bankBranch = this.employeeService.getById(Id);
// if (bankBranch != null) {
// employee.setBankBranchName(bankBranch.getName());
// }
jsonObject.put("orgCode", "");
jsonObject.put("orgName", "");
JSONObject resultMap = new JSONObject(); JSONObject resultMap = new JSONObject(true);
resultMap.put("resultCode", 200); resultMap.put("resultCode", 200);
resultMap.put("message", "成功"); resultMap.put("message", "成功");
resultMap.put("data", jsonObject); resultMap.put("data", jsonObject);
...@@ -185,6 +157,24 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -185,6 +157,24 @@ public class ChinaMobileRestApiController extends BaseController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
} }
@RequestMapping(value = "/user/logout", method = RequestMethod.GET)
public ResponseEntity<JSONObject> logout(@RequestHeader(value = "token") String token) {
try {
if (StringUtils.isNotBlank(token)) {
SecurityUtils.getSubject().logout();
this.stringRedisTemplate.delete(SHIRO_JWT_TOKEN + token);
}
JSONObject resultMap = new JSONObject(true);
resultMap.put("resultCode", 200);
resultMap.put("message", "成功");
resultMap.put("data", "");
return ResponseEntity.status(HttpStatus.OK).body(resultMap);
} catch (Exception e) {
LOGGER.error("注销错误!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
...@@ -193,7 +183,6 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -193,7 +183,6 @@ public class ChinaMobileRestApiController extends BaseController {
@ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String") @ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
}) })
@PostMapping("/exhibitionBoard/getPage") @PostMapping("/exhibitionBoard/getPage")
@RequiresPermissions("exhibition:board:page")
@ApiOperation(value = "获取展板分页列表", notes = "获取展板分页列表") @ApiOperation(value = "获取展板分页列表", notes = "获取展板分页列表")
public ResponseEntity<JSONObject> getExhibitionBoardPageList(GenericPageParam genericPageParam) { public ResponseEntity<JSONObject> getExhibitionBoardPageList(GenericPageParam genericPageParam) {
LambdaQueryWrapper<ExhibitionBoard> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ExhibitionBoard> queryWrapper = new LambdaQueryWrapper<>();
...@@ -232,13 +221,17 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -232,13 +221,17 @@ public class ChinaMobileRestApiController extends BaseController {
@ApiOperation(value = "获取展板详情", notes = "获取展板详情") @ApiOperation(value = "获取展板详情", notes = "获取展板详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path") @ApiImplicitParam(name = "boardId", value = "展板ID", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "language", value = "语言", dataType = "String", paramType = "query"),
}) })
@GetMapping("/exhibitionBoard/getby/{id}") @GetMapping("/exhibitionBoard/getBoardInfo")
@RequiresPermissions("exhibition:board:get:id") public JSONObject getById(@RequestParam(value = "boardId") String id, @RequestParam("language") LanguageEnum language) {
public Map<String, Object> getById(@PathVariable("id") String id) {
ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id); ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id);
return getResult(exhibitionBoard); JSONObject resultMap = new JSONObject();
resultMap.put("resultCode", 200);
resultMap.put("message", "成功");
resultMap.put("data", exhibitionBoard);
return resultMap;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment