merge
This commit is contained in:
+4
-4
@@ -11,7 +11,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
public class JSONObjResult {
|
||||
public class JsonResult {
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ public class JSONObjResult {
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject toJSONObj(Object o, String message) {
|
||||
JSONObjResult jsonObjResult = new JSONObjResult();
|
||||
JsonResult jsonObjResult = new JsonResult();
|
||||
jsonObjResult.setSuccess(true);
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
jsonObjResult.setMessage(message);
|
||||
@@ -51,7 +51,7 @@ public class JSONObjResult {
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject toJSONObj(RestMessage rest) {
|
||||
JSONObjResult jsonObjResult = new JSONObjResult();
|
||||
JsonResult jsonObjResult = new JsonResult();
|
||||
jsonObjResult.setSuccess(rest.isSuccess());
|
||||
jsonObjResult.setMessage(rest.getMessage());
|
||||
jsonObjResult.setData(JSONUtil.beanToMap(rest.getData()));
|
||||
@@ -65,7 +65,7 @@ public class JSONObjResult {
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject toJSONObj(String error) {
|
||||
JSONObjResult jsonObjResult = new JSONObjResult();
|
||||
JsonResult jsonObjResult = new JsonResult();
|
||||
jsonObjResult.setSuccess(false);
|
||||
jsonObjResult.setMessage(error);
|
||||
return JSON.parseObject(JSONObject.toJSONString(jsonObjResult, SerializerFeature.WriteMapNullValue));
|
||||
@@ -3,7 +3,7 @@ package com.xwbing.controller.other;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.service.other.MailService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -31,7 +31,7 @@ public class MailTestControl {
|
||||
@ApiOperation(value = "发送纯文本邮件")
|
||||
public JSONObject sendSimpleMail() {
|
||||
RestMessage restMessage = mailService.sendSimpleMail("786461501@qq.com", "测试邮件", "收到一个纯文本邮件");
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("发送html格式邮件")
|
||||
@@ -44,7 +44,7 @@ public class MailTestControl {
|
||||
"</body>" +
|
||||
"</html>";
|
||||
RestMessage restMessage = mailService.sendHtmlMail("786461501@qq.com", "html测试邮件", content);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("发送带附件邮件")
|
||||
@@ -53,7 +53,7 @@ public class MailTestControl {
|
||||
public JSONObject sendAttachmentsMail() {
|
||||
String path = "C:\\Users\\admin\\Desktop\\qq.txt";
|
||||
RestMessage restMessage = mailService.sendAttachmentsMail("786461501@qq.com", "附件测试邮件", "收到一个带附件邮件", path);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("发送文本内嵌图片邮件")
|
||||
@@ -64,6 +64,6 @@ public class MailTestControl {
|
||||
String content = "<html><body>这是有图片的邮件:<img src=\'cid:" + rscId + "\'></body></html>";
|
||||
String imgPath = "C:\\Users\\admin\\Desktop\\0000001.png";
|
||||
RestMessage restMessage = mailService.sendInlineResourceMail("786461501@qq.com", "内嵌图片测试邮件", content, imgPath, rscId);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.xwbing.service.other.CookieSessionService;
|
||||
import com.xwbing.service.other.ExpressDeliveryService;
|
||||
import com.xwbing.service.other.QRCodeZipService;
|
||||
import com.xwbing.util.HttpClientUtil;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RSAUtil;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -64,45 +64,45 @@ public class TestControl {
|
||||
@GetMapping("listShipperCode")
|
||||
public JSONObject listShipperCode() {
|
||||
List<JSONObject> list = expressDeliveryService.listShipperCode();
|
||||
return JSONObjResult.toJSONObj(list, "");
|
||||
return JsonResult.toJSONObj(list, "");
|
||||
}
|
||||
|
||||
@LogInfo("快递查询")
|
||||
@PostMapping("expressInfo")
|
||||
public JSONObject getExpressInfo(@RequestBody ExpressInfo info) {
|
||||
if (StringUtils.isEmpty(info.getLogisticCode()) || StringUtils.isEmpty(info.getShipperCode())) {
|
||||
return JSONObjResult.toJSONObj("快递公司或物流单号不能为空");
|
||||
return JsonResult.toJSONObj("快递公司或物流单号不能为空");
|
||||
}
|
||||
ExpressInfoVo infoVo = expressDeliveryService.queryOrderTraces(info);
|
||||
return JSONObjResult.toJSONObj(infoVo, "查询快递信息成功");
|
||||
return JsonResult.toJSONObj(infoVo, "查询快递信息成功");
|
||||
}
|
||||
|
||||
@LogInfo("生成二维码")
|
||||
@PostMapping("createQRCode")
|
||||
public JSONObject createQRCode(@RequestParam String name, @RequestParam String text) {
|
||||
RestMessage qrCode = qrCodeZipService.createQRCode(name, text);
|
||||
return JSONObjResult.toJSONObj(qrCode);
|
||||
return JsonResult.toJSONObj(qrCode);
|
||||
}
|
||||
|
||||
@LogInfo("解析二维码")
|
||||
@GetMapping("decode")
|
||||
public JSONObject decode(@RequestParam String path) {
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
return JSONObjResult.toJSONObj("二维码图片路径不能为空");
|
||||
return JsonResult.toJSONObj("二维码图片路径不能为空");
|
||||
}
|
||||
File file = new File(path);
|
||||
RestMessage decode = qrCodeZipService.decode(file);
|
||||
return JSONObjResult.toJSONObj(decode);
|
||||
return JsonResult.toJSONObj(decode);
|
||||
}
|
||||
|
||||
@LogInfo("导出zip")
|
||||
@GetMapping("batchGetImage")
|
||||
public JSONObject batchGetImage(HttpServletResponse response, @RequestParam String[] names, @RequestParam String fileName) {
|
||||
if (StringUtils.isEmpty(fileName)) {
|
||||
return JSONObjResult.toJSONObj("zip名称不能为空");
|
||||
return JsonResult.toJSONObj("zip名称不能为空");
|
||||
}
|
||||
RestMessage restMessage = qrCodeZipService.batchGetImage(response, names, fileName);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("rsa")
|
||||
@@ -125,19 +125,19 @@ public class TestControl {
|
||||
@LogInfo("session")
|
||||
@GetMapping("session")
|
||||
public JSONObject session(HttpServletRequest request) {
|
||||
return JSONObjResult.toJSONObj(cookieSessionService.session(request));
|
||||
return JsonResult.toJSONObj(cookieSessionService.session(request));
|
||||
}
|
||||
|
||||
@LogInfo("cookie")
|
||||
@GetMapping("cookie")
|
||||
public JSONObject cookie(HttpServletRequest request, HttpServletResponse response) {
|
||||
return JSONObjResult.toJSONObj(cookieSessionService.cookie(response, request));
|
||||
return JsonResult.toJSONObj(cookieSessionService.cookie(response, request));
|
||||
}
|
||||
|
||||
@LogInfo("completableFuture")
|
||||
@GetMapping("completableFuture")
|
||||
public JSONObject completableFuture() {
|
||||
return JSONObjResult.toJSONObj(thenCombine(), "");
|
||||
return JsonResult.toJSONObj(thenCombine(), "");
|
||||
}
|
||||
|
||||
private JSONObject thenCombine() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.xwbing.domain.entity.vo.DataDictionaryVo;
|
||||
import com.xwbing.domain.entity.vo.ListDataDictionaryVo;
|
||||
import com.xwbing.domain.entity.vo.RestMessageVo;
|
||||
import com.xwbing.service.sys.DataDictionaryService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -38,7 +38,7 @@ public class DataDictionaryControl {
|
||||
@ApiOperation(value = "添加字典", response = RestMessageVo.class)
|
||||
public JSONObject save(@RequestBody DataDictionary dictionary) {
|
||||
RestMessage result = dataDictionaryService.save(dictionary);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("修改字典")
|
||||
@@ -46,10 +46,10 @@ public class DataDictionaryControl {
|
||||
@ApiOperation(value = "修改字典", response = RestMessageVo.class)
|
||||
public JSONObject update(@RequestBody DataDictionary dictionary) {
|
||||
if (StringUtils.isEmpty(dictionary.getId())) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = dataDictionaryService.update(dictionary);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("获取字典详情")
|
||||
@@ -57,13 +57,13 @@ public class DataDictionaryControl {
|
||||
@GetMapping("getById")
|
||||
public JSONObject getById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
DataDictionary dataDictionary = dataDictionaryService.getById(id);
|
||||
if (dataDictionary == null) {
|
||||
return JSONObjResult.toJSONObj("该字典不存在");
|
||||
return JsonResult.toJSONObj("该字典不存在");
|
||||
}
|
||||
return JSONObjResult.toJSONObj(dataDictionary, "");
|
||||
return JsonResult.toJSONObj(dataDictionary, "");
|
||||
}
|
||||
|
||||
@LogInfo("校验编码")
|
||||
@@ -76,7 +76,7 @@ public class DataDictionaryControl {
|
||||
if (b) {
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("根据父id列表查询")
|
||||
@@ -91,7 +91,7 @@ public class DataDictionaryControl {
|
||||
parentId = CommonConstant.ROOT;
|
||||
}
|
||||
List<DataDictionary> listByParent = dataDictionaryService.findListByParent(parentId, enable);
|
||||
return JSONObjResult.toJSONObj(listByParent, "");
|
||||
return JsonResult.toJSONObj(listByParent, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据编码查询字典列表")
|
||||
@@ -100,9 +100,9 @@ public class DataDictionaryControl {
|
||||
@PostMapping("findListByCode")
|
||||
public JSONObject findListByCode(@RequestParam String code, String enable) {
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return JSONObjResult.toJSONObj("编码不能为空");
|
||||
return JsonResult.toJSONObj("编码不能为空");
|
||||
}
|
||||
List<DataDictionary> listByParent = dataDictionaryService.findListByCode(code, enable);
|
||||
return JSONObjResult.toJSONObj(listByParent, "");
|
||||
return JsonResult.toJSONObj(listByParent, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.xwbing.domain.entity.vo.RestMessageVo;
|
||||
import com.xwbing.domain.entity.vo.SysAuthVo;
|
||||
import com.xwbing.redis.RedisService;
|
||||
import com.xwbing.service.sys.SysAuthorityService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -46,7 +46,7 @@ public class SysAuthorityControl {
|
||||
if (save.isSuccess()) {
|
||||
redisService.del(CommonConstant.AUTHORITY_THREE);
|
||||
}
|
||||
return JSONObjResult.toJSONObj(save);
|
||||
return JsonResult.toJSONObj(save);
|
||||
}
|
||||
|
||||
@LogInfo("删除权限")
|
||||
@@ -54,14 +54,14 @@ public class SysAuthorityControl {
|
||||
@GetMapping("removeById")
|
||||
public JSONObject removeById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = sysAuthorityService.removeById(id);
|
||||
//删除缓存
|
||||
if (result.isSuccess()) {
|
||||
redisService.del(CommonConstant.AUTHORITY_THREE);
|
||||
}
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("修改权限")
|
||||
@@ -69,21 +69,21 @@ public class SysAuthorityControl {
|
||||
@PostMapping("update")
|
||||
public JSONObject update(@RequestBody SysAuthority sysAuthority) {
|
||||
if (StringUtils.isEmpty(sysAuthority.getId())) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
String enable = sysAuthority.getEnable();
|
||||
// 如果禁用,查询是否有子节点,如果有,子节点也要被禁用
|
||||
if (CommonConstant.IS_NOT_ENABLE.equals(enable)) {
|
||||
// 子节点的权限都禁用
|
||||
if (!sysAuthorityService.disableChildrenByParentId(sysAuthority.getId())) {
|
||||
return JSONObjResult.toJSONObj("禁用子节点权限失败");
|
||||
return JsonResult.toJSONObj("禁用子节点权限失败");
|
||||
}
|
||||
} else {
|
||||
// 如果是启用,看父节点是否被禁用,一级的不需要判断
|
||||
if (!CommonConstant.ROOT.equals(sysAuthority.getParentId())) {
|
||||
SysAuthority parent = sysAuthorityService.getById(sysAuthority.getParentId());
|
||||
if (parent != null && CommonEnum.YesOrNoEnum.NO.getCode().equals(parent.getEnable())) {
|
||||
return JSONObjResult.toJSONObj("父节点已被禁用,请先启用父节点");
|
||||
return JsonResult.toJSONObj("父节点已被禁用,请先启用父节点");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class SysAuthorityControl {
|
||||
if (result.isSuccess()) {
|
||||
redisService.del(CommonConstant.AUTHORITY_THREE);
|
||||
}
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("根据是否启用查询所有权限")
|
||||
@@ -101,7 +101,7 @@ public class SysAuthorityControl {
|
||||
@GetMapping("listByEnable")
|
||||
public JSONObject listByEnable(String enable) {
|
||||
List<SysAuthority> authoritys = sysAuthorityService.listByEnable(enable);
|
||||
return JSONObjResult.toJSONObj(authoritys, "");
|
||||
return JsonResult.toJSONObj(authoritys, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据父节点查询子节点")
|
||||
@@ -113,10 +113,10 @@ public class SysAuthorityControl {
|
||||
parentId = CommonConstant.ROOT;
|
||||
}
|
||||
if (!CommonConstant.ROOT.equals(parentId) && sysAuthorityService.getById(parentId) == null) {
|
||||
return JSONObjResult.toJSONObj("父节点不存在");
|
||||
return JsonResult.toJSONObj("父节点不存在");
|
||||
}
|
||||
List<SysAuthority> queryByParentId = sysAuthorityService.listByParentEnable(parentId, null);
|
||||
return JSONObjResult.toJSONObj(queryByParentId, "");
|
||||
return JsonResult.toJSONObj(queryByParentId, "");
|
||||
}
|
||||
|
||||
@LogInfo("递归查询所有权限")
|
||||
@@ -135,6 +135,6 @@ public class SysAuthorityControl {
|
||||
// 设置缓存
|
||||
redisService.set(CommonConstant.AUTHORITY_THREE, JSONArray.toJSONString(authoritys));
|
||||
}
|
||||
return JSONObjResult.toJSONObj(authoritys, "");
|
||||
return JsonResult.toJSONObj(authoritys, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.xwbing.domain.entity.vo.ListSysConfigVo;
|
||||
import com.xwbing.domain.entity.vo.RestMessageVo;
|
||||
import com.xwbing.domain.entity.vo.SysConfigVo;
|
||||
import com.xwbing.service.sys.SysConfigService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -49,7 +49,7 @@ public class SysConfigControl {
|
||||
String logMsg = "新增系统配置信息";
|
||||
logger.info(logMsg);
|
||||
RestMessage result = sysConfigService.save(sysConfig);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("根据code删除系统配置信息")
|
||||
@@ -60,10 +60,10 @@ public class SysConfigControl {
|
||||
String logMsg = "删除系统配置信息";
|
||||
logger.info(logMsg + " code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return JSONObjResult.toJSONObj("code不能为空");
|
||||
return JsonResult.toJSONObj("code不能为空");
|
||||
}
|
||||
RestMessage result = sysConfigService.removeByCode(code);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("修改系统配置信息")
|
||||
@@ -78,10 +78,10 @@ public class SysConfigControl {
|
||||
String logMsg = "修改系统配置信息";
|
||||
logger.info(logMsg);
|
||||
if (StringUtils.isEmpty(sysConfig.getCode())) {
|
||||
return JSONObjResult.toJSONObj("配置项的code不能为空");
|
||||
return JsonResult.toJSONObj("配置项的code不能为空");
|
||||
}
|
||||
RestMessage result = sysConfigService.update(sysConfig);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("根据key查找系统配置信息")
|
||||
@@ -92,13 +92,13 @@ public class SysConfigControl {
|
||||
String logMsg = "根据code查找系统配置信息";
|
||||
logger.info(logMsg + " code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return JSONObjResult.toJSONObj("code不能为空");
|
||||
return JsonResult.toJSONObj("code不能为空");
|
||||
}
|
||||
SysConfig one = sysConfigService.getByCode(code);
|
||||
if (one == null) {
|
||||
return JSONObjResult.toJSONObj("该配置不存在");
|
||||
return JsonResult.toJSONObj("该配置不存在");
|
||||
}
|
||||
return JSONObjResult.toJSONObj(one, "");
|
||||
return JsonResult.toJSONObj(one, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据是否启用查找配置列表")
|
||||
@@ -109,9 +109,9 @@ public class SysConfigControl {
|
||||
String logMsg = "根据是否启用查找配置列表";
|
||||
logger.info(logMsg + " enable:{}", enable);
|
||||
if (StringUtils.isEmpty(enable)) {
|
||||
return JSONObjResult.toJSONObj("是否启用不能为空");
|
||||
return JsonResult.toJSONObj("是否启用不能为空");
|
||||
}
|
||||
List<SysConfig> byEnable = sysConfigService.listByEnable(enable);
|
||||
return JSONObjResult.toJSONObj(byEnable, "");
|
||||
return JsonResult.toJSONObj(byEnable, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.xwbing.domain.entity.vo.SysRoleVo;
|
||||
import com.xwbing.service.sys.SysAuthorityService;
|
||||
import com.xwbing.service.sys.SysRoleAuthorityService;
|
||||
import com.xwbing.service.sys.SysRoleService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -45,7 +45,7 @@ public class SysRoleControl {
|
||||
@PostMapping("save")
|
||||
public JSONObject save(@RequestBody SysRole sysRole) {
|
||||
RestMessage result = sysRoleService.save(sysRole);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("删除角色")
|
||||
@@ -53,10 +53,10 @@ public class SysRoleControl {
|
||||
@GetMapping("removeById")
|
||||
public JSONObject removeById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = sysRoleService.removeById(id);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("修改角色")
|
||||
@@ -64,10 +64,10 @@ public class SysRoleControl {
|
||||
@PostMapping("update")
|
||||
public JSONObject update(@RequestBody SysRole sysRole) {
|
||||
if (StringUtils.isEmpty(sysRole.getId())) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = sysRoleService.update(sysRole);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("获取角色详情")
|
||||
@@ -75,13 +75,13 @@ public class SysRoleControl {
|
||||
@GetMapping("getById")
|
||||
public JSONObject getById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
SysRole sysRole = sysRoleService.getById(id);
|
||||
if (sysRole == null) {
|
||||
return JSONObjResult.toJSONObj("该角色不存在");
|
||||
return JsonResult.toJSONObj("该角色不存在");
|
||||
}
|
||||
return JSONObjResult.toJSONObj(sysRole, "");
|
||||
return JsonResult.toJSONObj(sysRole, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据是否启用查询所有角色")
|
||||
@@ -90,7 +90,7 @@ public class SysRoleControl {
|
||||
@GetMapping("listByEnable")
|
||||
public JSONObject listByEnable(String enable) {
|
||||
List<SysRole> sysRoles = sysRoleService.listAllByEnable(enable);
|
||||
return JSONObjResult.toJSONObj(sysRoles, "");
|
||||
return JsonResult.toJSONObj(sysRoles, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据角色主键查找权限")
|
||||
@@ -99,14 +99,14 @@ public class SysRoleControl {
|
||||
@PostMapping("listAuthorityByRoleId")
|
||||
public JSONObject listAuthorityByRoleId(@RequestParam String roleId, String enable) {
|
||||
if (StringUtils.isEmpty(roleId)) {
|
||||
return JSONObjResult.toJSONObj("角色主键不能为空");
|
||||
return JsonResult.toJSONObj("角色主键不能为空");
|
||||
}
|
||||
SysRole sysRole = sysRoleService.getById(roleId);
|
||||
if (sysRole == null) {
|
||||
return JSONObjResult.toJSONObj("该角色不存在");
|
||||
return JsonResult.toJSONObj("该角色不存在");
|
||||
}
|
||||
List<SysAuthority> authoritys = sysAuthorityService.listByRoleIdEnable(roleId, enable);
|
||||
return JSONObjResult.toJSONObj(authoritys, "");
|
||||
return JsonResult.toJSONObj(authoritys, "");
|
||||
}
|
||||
|
||||
@LogInfo("保存角色权限")
|
||||
@@ -114,14 +114,14 @@ public class SysRoleControl {
|
||||
@PostMapping("saveAuthority")
|
||||
public JSONObject saveAuthority(@RequestParam String authorityIds, @RequestParam String roleId) {
|
||||
if (StringUtils.isEmpty(authorityIds)) {
|
||||
return JSONObjResult.toJSONObj("权限主键集合不能为空");
|
||||
return JsonResult.toJSONObj("权限主键集合不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(roleId)) {
|
||||
return JSONObjResult.toJSONObj("角色主键不能为空");
|
||||
return JsonResult.toJSONObj("角色主键不能为空");
|
||||
}
|
||||
SysRole sysRole = sysRoleService.getById(roleId);
|
||||
if (sysRole == null) {
|
||||
return JSONObjResult.toJSONObj("该角色不存在");
|
||||
return JsonResult.toJSONObj("该角色不存在");
|
||||
}
|
||||
String ids[] = authorityIds.split(",");
|
||||
List<SysRoleAuthority> list = new ArrayList<>();
|
||||
@@ -133,6 +133,6 @@ public class SysRoleControl {
|
||||
list.add(roleAuthority);
|
||||
}
|
||||
RestMessage restMessage = sysRoleAuthorityService.saveBatch(list, roleId);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.xwbing.service.sys.SysRoleService;
|
||||
import com.xwbing.service.sys.SysUserRoleService;
|
||||
import com.xwbing.service.sys.SysUserService;
|
||||
import com.xwbing.util.CommonDataUtil;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -54,7 +54,7 @@ public class SysUserControl {
|
||||
@PostMapping("save")
|
||||
public JSONObject save(@RequestBody @Valid SysUser sysUser) {
|
||||
RestMessage result = sysUserService.save(sysUser);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("删除用户")
|
||||
@@ -62,10 +62,10 @@ public class SysUserControl {
|
||||
@GetMapping("removeById")
|
||||
public JSONObject removeById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = sysUserService.removeById(id);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("修改用户信息")
|
||||
@@ -73,10 +73,10 @@ public class SysUserControl {
|
||||
@PostMapping("update")
|
||||
public JSONObject update(@RequestBody @Valid SysUser sysUser) {
|
||||
if (StringUtils.isEmpty(sysUser.getId())) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage result = sysUserService.update(sysUser);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
return JsonResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@LogInfo("获取用户详情")
|
||||
@@ -84,13 +84,13 @@ public class SysUserControl {
|
||||
@GetMapping("getById")
|
||||
public JSONObject getById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
SysUser sysUser = sysUserService.getById(id);
|
||||
if (sysUser == null) {
|
||||
return JSONObjResult.toJSONObj("未查到该对象");
|
||||
return JsonResult.toJSONObj("未查到该对象");
|
||||
}
|
||||
return JSONObjResult.toJSONObj(sysUser, "");
|
||||
return JsonResult.toJSONObj(sysUser, "");
|
||||
}
|
||||
|
||||
@LogInfo("列表查询所有用户")
|
||||
@@ -98,7 +98,7 @@ public class SysUserControl {
|
||||
@GetMapping("listAll")
|
||||
public JSONObject listAll() {
|
||||
List<SysUser> list = sysUserService.listAll();
|
||||
return JSONObjResult.toJSONObj(list, "");
|
||||
return JsonResult.toJSONObj(list, "");
|
||||
}
|
||||
|
||||
@LogInfo("登录")
|
||||
@@ -106,13 +106,13 @@ public class SysUserControl {
|
||||
@PostMapping("login")
|
||||
public JSONObject login(HttpServletRequest request, @RequestParam String userName, @RequestParam String passWord, @RequestParam String checkCode) {
|
||||
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(passWord)) {
|
||||
return JSONObjResult.toJSONObj("用户名或密码不能为空");
|
||||
return JsonResult.toJSONObj("用户名或密码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(checkCode)) {
|
||||
return JSONObjResult.toJSONObj("请输入验证码");
|
||||
return JsonResult.toJSONObj("请输入验证码");
|
||||
}
|
||||
RestMessage login = sysUserService.login(request, userName, passWord, checkCode);
|
||||
return JSONObjResult.toJSONObj(login);
|
||||
return JsonResult.toJSONObj(login);
|
||||
}
|
||||
|
||||
@LogInfo("登出")
|
||||
@@ -120,7 +120,7 @@ public class SysUserControl {
|
||||
@GetMapping("logout")
|
||||
public JSONObject logout(HttpServletRequest request) {
|
||||
RestMessage logout = sysUserService.logout(request);
|
||||
return JSONObjResult.toJSONObj(logout);
|
||||
return JsonResult.toJSONObj(logout);
|
||||
}
|
||||
|
||||
@LogInfo("修改密码")
|
||||
@@ -128,13 +128,13 @@ public class SysUserControl {
|
||||
@PostMapping("updatePassWord")
|
||||
public JSONObject updatePassWord(@RequestParam String newPassWord, @RequestParam String oldPassWord, @RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(newPassWord) || StringUtils.isEmpty(oldPassWord)) {
|
||||
return JSONObjResult.toJSONObj("原密码或新密码不能为空");
|
||||
return JsonResult.toJSONObj("原密码或新密码不能为空");
|
||||
}
|
||||
RestMessage restMessage = sysUserService.updatePassWord(newPassWord, oldPassWord, id);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("重置密码")
|
||||
@@ -142,10 +142,10 @@ public class SysUserControl {
|
||||
@GetMapping("resetPassWord")
|
||||
public JSONObject resetPassWord(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
return JsonResult.toJSONObj("主键不能为空");
|
||||
}
|
||||
RestMessage restMessage = sysUserService.resetPassWord(id);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("获取当前登录用户信息")
|
||||
@@ -154,7 +154,7 @@ public class SysUserControl {
|
||||
public JSONObject getLoginUserInfo() {
|
||||
SysUser sysUser = sysUserService.getById((String) CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID));
|
||||
if (sysUser == null) {
|
||||
return JSONObjResult.toJSONObj("未获取到当前登录用户信息");
|
||||
return JsonResult.toJSONObj("未获取到当前登录用户信息");
|
||||
}
|
||||
List<SysAuthority> button = new ArrayList<>();
|
||||
List<SysAuthority> menu = new ArrayList<>();
|
||||
@@ -175,7 +175,7 @@ public class SysUserControl {
|
||||
}
|
||||
sysUser.setMenus(menu);
|
||||
sysUser.setButtons(button);
|
||||
return JSONObjResult.toJSONObj(sysUser, "");
|
||||
return JsonResult.toJSONObj(sysUser, "");
|
||||
}
|
||||
|
||||
@LogInfo("保存用户角色")
|
||||
@@ -183,17 +183,17 @@ public class SysUserControl {
|
||||
@PostMapping("saveRole")
|
||||
public JSONObject saveRole(@RequestParam String roleIds, @RequestParam String userId) {
|
||||
if (StringUtils.isEmpty(roleIds)) {
|
||||
return JSONObjResult.toJSONObj("角色主键不能为空");
|
||||
return JsonResult.toJSONObj("角色主键不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
return JSONObjResult.toJSONObj("用户主键不能为空");
|
||||
return JsonResult.toJSONObj("用户主键不能为空");
|
||||
}
|
||||
SysUser old = sysUserService.getById(userId);
|
||||
if (old == null) {
|
||||
return JSONObjResult.toJSONObj("该用户不存在");
|
||||
return JsonResult.toJSONObj("该用户不存在");
|
||||
}
|
||||
if (CommonEnum.YesOrNoEnum.YES.getCode().equalsIgnoreCase(old.getAdmin())) {
|
||||
return JSONObjResult.toJSONObj("不能对管理员进行操作");
|
||||
return JsonResult.toJSONObj("不能对管理员进行操作");
|
||||
}
|
||||
String ids[] = roleIds.split(",");
|
||||
List<SysUserRole> list = new ArrayList<>();
|
||||
@@ -205,7 +205,7 @@ public class SysUserControl {
|
||||
list.add(userRole);
|
||||
}
|
||||
RestMessage restMessage = sysUserRoleService.saveBatch(list, userId);
|
||||
return JSONObjResult.toJSONObj(restMessage);
|
||||
return JsonResult.toJSONObj(restMessage);
|
||||
}
|
||||
|
||||
@LogInfo("根据用户主键查找所拥有的角色")
|
||||
@@ -214,10 +214,10 @@ public class SysUserControl {
|
||||
@PostMapping("listRoleByUserId")
|
||||
public JSONObject listRoleByUserId(@RequestParam String userId, String enable) {
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
return JSONObjResult.toJSONObj("用户主键不能为空");
|
||||
return JsonResult.toJSONObj("用户主键不能为空");
|
||||
}
|
||||
List<SysRole> list = sysRoleService.listByUserIdEnable(userId, enable);
|
||||
return JSONObjResult.toJSONObj(list, "");
|
||||
return JsonResult.toJSONObj(list, "");
|
||||
}
|
||||
|
||||
@LogInfo("根据用户主键查找所拥有的权限")
|
||||
@@ -226,10 +226,10 @@ public class SysUserControl {
|
||||
@PostMapping("listAuthorityByUserId")
|
||||
public JSONObject listAuthorityByUserId(@RequestParam String userId, String enable) {
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
return JSONObjResult.toJSONObj("用户主键不能为空");
|
||||
return JsonResult.toJSONObj("用户主键不能为空");
|
||||
}
|
||||
List<SysAuthority> list = sysUserService.listAuthorityByIdAndEnable(userId, enable);
|
||||
return JSONObjResult.toJSONObj(list, "");
|
||||
return JsonResult.toJSONObj(list, "");
|
||||
}
|
||||
|
||||
@LogInfo("导出用户excel表")
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
|
||||
import com.xwbing.domain.entity.vo.ListSysUserLoginInOutVo;
|
||||
import com.xwbing.service.sys.SysUserLoginInOutService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -34,6 +34,6 @@ public class SysUserLoginInOutControl {
|
||||
@GetMapping("listByType")
|
||||
public JSONObject listByType(@RequestParam int inout) {
|
||||
List<SysUserLoginInOut> sysUserLoginInOuts = inOutService.listByType(inout);
|
||||
return JSONObjResult.toJSONObj(sysUserLoginInOuts, "获取列表成功");
|
||||
return JsonResult.toJSONObj(sysUserLoginInOuts, "获取列表成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xwbing.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.JsonResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
@@ -46,7 +46,7 @@ public class GlobalExceptionHandler {
|
||||
@ResponseBody
|
||||
public JSONObject handlerBusinessException(BusinessException ex) {
|
||||
logger.error(ex.getMessage());
|
||||
return JSONObjResult.toJSONObj(ex.getMessage());
|
||||
return JsonResult.toJSONObj(ex.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class GlobalExceptionHandler {
|
||||
if (!detail.contains("BusinessException")) {
|
||||
errorMessages = "异步获取数据出错";
|
||||
}
|
||||
return JSONObjResult.toJSONObj(errorMessages);
|
||||
return JsonResult.toJSONObj(errorMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public class GlobalExceptionHandler {
|
||||
String errorMessages = list.stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining("&&"));
|
||||
logger.error(errorMessages);
|
||||
response.setStatus(HttpStatus.OK.value());
|
||||
return JSONObjResult.toJSONObj(errorMessages);
|
||||
return JsonResult.toJSONObj(errorMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public class GlobalExceptionHandler {
|
||||
List<ObjectError> allErrors = bindingResult.getAllErrors();
|
||||
String errorMessages = allErrors.stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining("&&"));
|
||||
logger.error(errorMessages);
|
||||
return JSONObjResult.toJSONObj(errorMessages);
|
||||
return JsonResult.toJSONObj(errorMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,6 +115,6 @@ public class GlobalExceptionHandler {
|
||||
@ResponseBody
|
||||
public JSONObject handlerException(Exception ex) {
|
||||
logger.error(ex.getMessage());
|
||||
return JSONObjResult.toJSONObj("系统异常,请联系管理员");
|
||||
return JsonResult.toJSONObj("系统异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user