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;
}
}
......@@ -40,63 +40,61 @@ public class ExhibitionBoard implements Serializable {
@ApiModelProperty("展板分类名称")
@TableField("name")
@NotBlank(message = "展板分类名称不能为空", groups = {Add.class, Update.class})
private String name;
@NotBlank(message = "展板分类名称不能为空", groups = {Add.class, Update.class})
private String name;
@ApiModelProperty("展板版权方ID")
@TableField("copyright_owner_id")
@NotBlank(message = "展板版权方ID不能为空", groups = {Add.class, Update.class})
private String copyrightOwnerId;
@NotBlank(message = "展板版权方ID不能为空", groups = {Add.class, Update.class})
private String copyrightOwnerId;
@ApiModelProperty("展板分类ID")
@TableField("exhibition_board_cat_id")
@NotBlank(message = "展板分类ID不能为空", groups = {Add.class, Update.class})
private String exhibitionBoardCatId;
@NotBlank(message = "展板分类ID不能为空", groups = {Add.class, Update.class})
private String exhibitionBoardCatId;
@ApiModelProperty("展板图片URL")
@TableField("board_img_url")
@NotBlank(message = "展板图片URL不能为空", groups = {Add.class, Update.class})
private String boardImgUrl;
@NotBlank(message = "展板图片URL不能为空", groups = {Add.class, Update.class})
private String boardImgUrl;
@ApiModelProperty("展板二维码URL")
@TableField("board_qrcode_url")
@NotBlank(message = "展板二维码URL不能为空", groups = {Add.class, Update.class})
private String boardQrcodeUrl;
@NotBlank(message = "展板二维码URL不能为空", groups = {Add.class, Update.class})
private String boardQrcodeUrl;
@ApiModelProperty("简介")
@TableField("introduction")
@NotBlank(message = "简介不能为空", groups = {Add.class, Update.class})
private String introduction;
@NotBlank(message = "简介不能为空", groups = {Add.class, Update.class})
private String introduction;
@ApiModelProperty("视频类别ID")
@TableField("asset_type")
private String assetType;
@ApiModelProperty("视频ID")
@TableField("asset_id")
private String assetId;
@ApiModelProperty("导览音频URL")
@TableField("guide_audio_url")
private String guideAudioUrl;
@ApiModelProperty("参考资料")
@TableField("reference_material")
private String referenceMaterial;
@ApiModelProperty("创建日期")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@ApiModelProperty("修改日期")
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
@ApiModelProperty("审核状态")
@TableField("audit_status")
private String auditStatus;
}
......@@ -2,6 +2,7 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService;
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.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.Employee;
......@@ -12,14 +13,14 @@ import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
......@@ -30,9 +31,10 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
@Api(tags = {"中国移动API"})
@RestController("/cmRestApi")
public class ChinaMobileRestApiController extends BaseController {
......@@ -77,20 +79,12 @@ public class ChinaMobileRestApiController extends BaseController {
resultMap.put("message", "由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
employee = employeeService.selectByUsername(username);
if (employee == null) {
resultMap.put("status", 500);
resultMap.put("message", "用户名或密码不正确!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
if (!employee.getStatus()) {
throw new DisabledAccountException("此帐号已禁用,请联系管理员!");
}
if (!employee.getAllowLogin()) {
throw new DisabledAccountException("您无权访问,请联系管理员!");
}
try {
byte[] salt = employee.getPasswordSalt();
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(password, salt)).equals(new String(employee.getPasswordHash()))) {
......@@ -105,14 +99,6 @@ public class ChinaMobileRestApiController extends BaseController {
}
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());
// 将token信息存入Redis
stringRedisTemplate.opsForValue().set(SHIRO_JWT_TOKEN + token, employee.getId(), 240, TimeUnit.MINUTES);
......@@ -122,6 +108,8 @@ public class ChinaMobileRestApiController extends BaseController {
jsonObject.put("userId", employee.getId());
jsonObject.put("userName", employee.getUsername());
jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(240), TimeUtils.FORMAT_ONE));
jsonObject.put("orgCode", "");
jsonObject.put("orgName", "");
resultMap.put("resultCode", 200);
resultMap.put("message", "成功");
......@@ -135,34 +123,12 @@ public class ChinaMobileRestApiController extends BaseController {
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 = "获取单个成员信息")
@GetMapping(value = "/user/getUserInfo")
@RequiresPermissions("/user/getUserInfo")
public ResponseEntity<JSONObject> getById(String userId, @RequestHeader("token") String token) {
try {
Employee employee = employeeService.selectByEmpId(userId);
// BankBranchInfo bankBranch = this.employeeService.getById(Id);
// if (bankBranch != null) {
// employee.setBankBranchName(bankBranch.getName());
// }
if (null == employee) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
......@@ -173,8 +139,14 @@ public class ChinaMobileRestApiController extends BaseController {
jsonObject.put("userName", employee.getUsername());
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 resultMap = new JSONObject();
// BankBranchInfo bankBranch = this.employeeService.getById(Id);
// if (bankBranch != null) {
// employee.setBankBranchName(bankBranch.getName());
// }
jsonObject.put("orgCode", "");
jsonObject.put("orgName", "");
JSONObject resultMap = new JSONObject(true);
resultMap.put("resultCode", 200);
resultMap.put("message", "成功");
resultMap.put("data", jsonObject);
......@@ -185,6 +157,24 @@ public class ChinaMobileRestApiController extends BaseController {
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 = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
......@@ -193,7 +183,6 @@ public class ChinaMobileRestApiController extends BaseController {
@ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
})
@PostMapping("/exhibitionBoard/getPage")
@RequiresPermissions("exhibition:board:page")
@ApiOperation(value = "获取展板分页列表", notes = "获取展板分页列表")
public ResponseEntity<JSONObject> getExhibitionBoardPageList(GenericPageParam genericPageParam) {
LambdaQueryWrapper<ExhibitionBoard> queryWrapper = new LambdaQueryWrapper<>();
......@@ -232,13 +221,17 @@ public class ChinaMobileRestApiController extends BaseController {
@ApiOperation(value = "获取展板详情", notes = "获取展板详情")
@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}")
@RequiresPermissions("exhibition:board:get:id")
public Map<String, Object> getById(@PathVariable("id") String id) {
@GetMapping("/exhibitionBoard/getBoardInfo")
public JSONObject getById(@RequestParam(value = "boardId") String id, @RequestParam("language") LanguageEnum language) {
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