mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
♻️ 重构代码 . R.ok R.failed
This commit is contained in:
1 parent
8affb5519e
commit
0ca10e1adc
43 files changed
+231
-249
No files matched your search
@@ -22,7 +22,7 @@ package com.pig4cloud.pigx.auth.endpoint;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
@@ -40,6 +40,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
|
||||
import org.springframework.security.oauth2.provider.AuthorizationRequest;
|
||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||
import org.springframework.security.oauth2.provider.ClientDetailsService;
|
||||
@@ -114,26 +115,27 @@ public class PigxTokenEndpoint {
|
||||
@DeleteMapping("/logout")
|
||||
public R logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
|
||||
if (StrUtil.isBlank(authHeader)) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.data(Boolean.FALSE)
|
||||
.msg("退出失败,token 为空").build();
|
||||
return R.failed(Boolean.FALSE, "退出失败,token 为空");
|
||||
}
|
||||
|
||||
String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim();
|
||||
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
|
||||
if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.data(Boolean.FALSE)
|
||||
.msg("退出失败,token 无效").build();
|
||||
return R.failed(Boolean.FALSE, "退出失败,token 无效");
|
||||
}
|
||||
|
||||
OAuth2Authentication auth2Authentication = tokenStore.readAuthentication(accessToken);
|
||||
cacheManager.getCache("user_details")
|
||||
// 清空用户信息
|
||||
cacheManager.getCache(CacheConstants.USER_DETAILS)
|
||||
.evict(auth2Authentication.getName());
|
||||
|
||||
// 清空access token
|
||||
tokenStore.removeAccessToken(accessToken);
|
||||
return new R<>(Boolean.TRUE);
|
||||
|
||||
// 清空 refresh token
|
||||
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(tokenValue);
|
||||
tokenStore.removeRefreshToken(refreshToken);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +172,7 @@ public class PigxTokenEndpoint {
|
||||
Page result = new Page(MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE));
|
||||
result.setRecords(pigxRedisTemplate.opsForValue().multiGet(pages));
|
||||
result.setTotal(Long.valueOf(pigxRedisTemplate.keys(key).size()));
|
||||
return new R<>(result);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+28
-17
@@ -33,23 +33,23 @@ import java.io.Serializable;
|
||||
* @param <T>
|
||||
* @author lengleng
|
||||
*/
|
||||
@Builder
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(description = "响应信息主体")
|
||||
@AllArgsConstructor
|
||||
public class R<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty(value = "返回标记:成功标记=0,失败标记=1")
|
||||
private int code = CommonConstants.SUCCESS;
|
||||
private int code;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModelProperty(value = "返回信息")
|
||||
private String msg = "success";
|
||||
private String msg;
|
||||
|
||||
|
||||
@Getter
|
||||
@@ -57,24 +57,35 @@ public class R<T> implements Serializable {
|
||||
@ApiModelProperty(value = "数据")
|
||||
private T data;
|
||||
|
||||
public R() {
|
||||
super();
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, CommonConstants.SUCCESS, null);
|
||||
}
|
||||
|
||||
public R(T data) {
|
||||
super();
|
||||
this.data = data;
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, CommonConstants.SUCCESS, null);
|
||||
}
|
||||
|
||||
public R(T data, String msg) {
|
||||
super();
|
||||
this.data = data;
|
||||
this.msg = msg;
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, CommonConstants.SUCCESS, msg);
|
||||
}
|
||||
|
||||
public R(Throwable e) {
|
||||
super();
|
||||
this.msg = e.getMessage();
|
||||
this.code = CommonConstants.FAIL;
|
||||
public static <T> R<T> failed() {
|
||||
return restResult(null, CommonConstants.FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(String msg) {
|
||||
return restResult(null, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data, String msg) {
|
||||
return restResult(data, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
+5
-15
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.pig4cloud.pigx.common.security.component;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -51,10 +50,7 @@ public class GlobalExceptionHandlerResolver {
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public R handleGlobalException(Exception e) {
|
||||
log.error("全局异常信息 ex={}", e.getMessage(), e);
|
||||
return R.builder()
|
||||
.msg(e.getLocalizedMessage())
|
||||
.code(CommonConstants.FAIL)
|
||||
.build();
|
||||
return R.failed(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,13 +63,10 @@ public class GlobalExceptionHandlerResolver {
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public R handleAccessDeniedException(AccessDeniedException e) {
|
||||
String msg = SpringSecurityMessageSource.getAccessor()
|
||||
.getMessage("AbstractAccessDecisionManager.accessDenied"
|
||||
, e.getMessage());
|
||||
.getMessage("AbstractAccessDecisionManager.accessDenied"
|
||||
, e.getMessage());
|
||||
log.error("拒绝授权异常信息 ex={}", msg, e);
|
||||
return R.builder()
|
||||
.msg(msg)
|
||||
.code(CommonConstants.FAIL)
|
||||
.build();
|
||||
return R.failed(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,9 +80,6 @@ public class GlobalExceptionHandlerResolver {
|
||||
public R handleBodyValidException(MethodArgumentNotValidException exception) {
|
||||
List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
|
||||
log.error("参数绑定异常,ex = {}", fieldErrors.get(0).getDefaultMessage());
|
||||
return R.builder()
|
||||
.msg(fieldErrors.get(0).getDefaultMessage())
|
||||
.code(CommonConstants.FAIL)
|
||||
.build();
|
||||
return R.failed(fieldErrors.get(0).getDefaultMessage());
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -96,8 +96,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||
try {
|
||||
return response.writeWith(Mono.just(response.bufferFactory()
|
||||
.wrap(objectMapper.writeValueAsBytes(
|
||||
R.builder().msg(e.getMessage())
|
||||
.code(CommonConstants.FAIL).build()))));
|
||||
R.failed(e.getMessage())))));
|
||||
} catch (JsonProcessingException e1) {
|
||||
log.error("对象输出异常", e1);
|
||||
}
|
||||
|
||||
+1
-5
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.pig4cloud.pigx.gateway.handler;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -49,9 +48,6 @@ public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
|
||||
|
||||
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
||||
.body(BodyInserters.fromObject(R.builder()
|
||||
.msg("服务异常")
|
||||
.code(CommonConstants.FAIL)
|
||||
.build()));
|
||||
.body(BodyInserters.fromObject(R.failed("服务异常")));
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -54,7 +54,7 @@ public class DeptController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R<>(sysDeptService.getById(id));
|
||||
return R.ok(sysDeptService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DeptController {
|
||||
*/
|
||||
@GetMapping(value = "/tree")
|
||||
public R getTree() {
|
||||
return new R<>(sysDeptService.selectTree());
|
||||
return R.ok(sysDeptService.selectTree());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public class DeptController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_dept_add')")
|
||||
public R save(@Valid @RequestBody SysDept sysDept) {
|
||||
return new R<>(sysDeptService.saveDept(sysDept));
|
||||
return R.ok(sysDeptService.saveDept(sysDept));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ public class DeptController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_dept_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(sysDeptService.removeDeptById(id));
|
||||
return R.ok(sysDeptService.removeDeptById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +105,6 @@ public class DeptController {
|
||||
@PreAuthorize("@pms.hasPermission('sys_dept_edit')")
|
||||
public R update(@Valid @RequestBody SysDept sysDept) {
|
||||
sysDept.setUpdateTime(LocalDateTime.now());
|
||||
return new R<>(sysDeptService.updateDeptById(sysDept));
|
||||
return R.ok(sysDeptService.updateDeptById(sysDept));
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -63,7 +63,7 @@ public class DictController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R<>(sysDictService.getById(id));
|
||||
return R.ok(sysDictService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class DictController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R<IPage> getDictPage(Page page, SysDict sysDict) {
|
||||
return new R<>(sysDictService.page(page, Wrappers.query(sysDict)));
|
||||
return R.ok(sysDictService.page(page, Wrappers.query(sysDict)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ public class DictController {
|
||||
@GetMapping("/type/{type}")
|
||||
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result == null")
|
||||
public R getDictByType(@PathVariable String type) {
|
||||
return new R<>(sysDictItemService.list(Wrappers
|
||||
return R.ok(sysDictItemService.list(Wrappers
|
||||
.<SysDictItem>query().lambda()
|
||||
.eq(SysDictItem::getType, type)));
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class DictController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_dict_add')")
|
||||
public R save(@Valid @RequestBody SysDict sysDict) {
|
||||
return new R<>(sysDictService.save(sysDict));
|
||||
return R.ok(sysDictService.save(sysDict));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public class DictController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(sysDictService.removeDict(id));
|
||||
return R.ok(sysDictService.removeDict(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class DictController {
|
||||
@SysLog("修改字典")
|
||||
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
|
||||
public R updateById(@Valid @RequestBody SysDict sysDict) {
|
||||
return new R<>(sysDictService.updateById(sysDict));
|
||||
return R.ok(sysDictService.updateById(sysDict));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class DictController {
|
||||
*/
|
||||
@GetMapping("/item/page")
|
||||
public R getSysDictItemPage(Page page, SysDictItem sysDictItem) {
|
||||
return new R<>(sysDictItemService.page(page, Wrappers.query(sysDictItem)));
|
||||
return R.ok(sysDictItemService.page(page, Wrappers.query(sysDictItem)));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ public class DictController {
|
||||
*/
|
||||
@GetMapping("/item/{id}")
|
||||
public R getDictItemById(@PathVariable("id") Integer id) {
|
||||
return new R<>(sysDictItemService.getById(id));
|
||||
return R.ok(sysDictItemService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ public class DictController {
|
||||
@PostMapping("/item")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R save(@RequestBody SysDictItem sysDictItem) {
|
||||
return new R<>(sysDictItemService.save(sysDictItem));
|
||||
return R.ok(sysDictItemService.save(sysDictItem));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +177,7 @@ public class DictController {
|
||||
@PutMapping("/item")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R updateById(@RequestBody SysDictItem sysDictItem) {
|
||||
return new R<>(sysDictItemService.updateById(sysDictItem));
|
||||
return R.ok(sysDictItemService.updateById(sysDictItem));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +190,6 @@ public class DictController {
|
||||
@DeleteMapping("/item/{id}")
|
||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||
public R removeDictItemById(@PathVariable Integer id) {
|
||||
return new R<>(sysDictItemService.removeById(id));
|
||||
return R.ok(sysDictItemService.removeById(id));
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -67,10 +67,9 @@ public class FileController {
|
||||
minioTemplate.putObject(CommonConstants.BUCKET_NAME, fileName, file.getInputStream());
|
||||
} catch (Exception e) {
|
||||
log.error("上传失败", e);
|
||||
return R.builder().code(CommonConstants.FAIL)
|
||||
.msg(e.getLocalizedMessage()).build();
|
||||
return R.failed(e.getLocalizedMessage());
|
||||
}
|
||||
return R.builder().data(resultMap).build();
|
||||
return R.ok(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +82,7 @@ public class FileController {
|
||||
@GetMapping("/{fileName}")
|
||||
public void file(@PathVariable String fileName, HttpServletResponse response) {
|
||||
Integer separator = fileName.lastIndexOf(StrUtil.DASHED);
|
||||
try (InputStream inputStream = minioTemplate.getObject(fileName.substring(0,separator),fileName.substring(separator+1,fileName.length()))) {
|
||||
try (InputStream inputStream = minioTemplate.getObject(fileName.substring(0, separator), fileName.substring(separator + 1, fileName.length()))) {
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
IoUtil.copy(inputStream, response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
|
||||
+4
-4
@@ -59,7 +59,7 @@ public class LogController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getLogPage(Page page, SysLog sysLog) {
|
||||
return new R<>(sysLogService.page(page, Wrappers.query(sysLog)));
|
||||
return R.ok(sysLogService.page(page, Wrappers.query(sysLog)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class LogController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_log_del')")
|
||||
public R removeById(@PathVariable Long id) {
|
||||
return new R<>(sysLogService.removeById(id));
|
||||
return R.ok(sysLogService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class LogController {
|
||||
@Inner
|
||||
@PostMapping("/save")
|
||||
public R save(@Valid @RequestBody SysLog sysLog) {
|
||||
return new R<>(sysLogService.save(sysLog));
|
||||
return R.ok(sysLogService.save(sysLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +94,6 @@ public class LogController {
|
||||
*/
|
||||
@PostMapping("/logs")
|
||||
public R saveBatchLogs(@RequestBody List<PreLogVo> preLogVoList) {
|
||||
return new R<>(sysLogService.saveBatchLogs(preLogVoList));
|
||||
return R.ok(sysLogService.saveBatchLogs(preLogVoList));
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -68,7 +68,7 @@ public class MenuController {
|
||||
.map(MenuTree::new)
|
||||
.sorted(Comparator.comparingInt(MenuTree::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return new R<>(TreeUtil.build(menuTreeList, CommonConstants.MENU_TREE_ROOT_ID));
|
||||
return R.ok(TreeUtil.build(menuTreeList, CommonConstants.MENU_TREE_ROOT_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public class MenuController {
|
||||
*/
|
||||
@GetMapping(value = "/tree")
|
||||
public R getTree() {
|
||||
return new R<>(TreeUtil.buildTree(sysMenuService
|
||||
return R.ok(TreeUtil.buildTree(sysMenuService
|
||||
.list(Wrappers.<SysMenu>lambdaQuery()
|
||||
.orderByAsc(SysMenu::getSort)), CommonConstants.MENU_TREE_ROOT_ID));
|
||||
}
|
||||
@@ -90,11 +90,11 @@ public class MenuController {
|
||||
* @return 属性集合
|
||||
*/
|
||||
@GetMapping("/tree/{roleId}")
|
||||
public List getRoleTree(@PathVariable Integer roleId) {
|
||||
return sysMenuService.findMenuByRoleId(roleId)
|
||||
public R getRoleTree(@PathVariable Integer roleId) {
|
||||
return R.ok(sysMenuService.findMenuByRoleId(roleId)
|
||||
.stream()
|
||||
.map(MenuVO::getMenuId)
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ public class MenuController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R<>(sysMenuService.getById(id));
|
||||
return R.ok(sysMenuService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public class MenuController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_menu_add')")
|
||||
public R save(@Valid @RequestBody SysMenu sysMenu) {
|
||||
return new R<>(sysMenuService.save(sysMenu));
|
||||
return R.ok(sysMenuService.save(sysMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public class MenuController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_menu_edit')")
|
||||
public R update(@Valid @RequestBody SysMenu sysMenu) {
|
||||
return new R<>(sysMenuService.updateMenuById(sysMenu));
|
||||
return R.ok(sysMenuService.updateMenuById(sysMenu));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -55,7 +55,7 @@ public class OauthClientDetailsController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R<>(sysOauthClientDetailsService.getById(id));
|
||||
return R.ok(sysOauthClientDetailsService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class OauthClientDetailsController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getOauthClientDetailsPage(Page page, SysOauthClientDetails sysOauthClientDetails) {
|
||||
return new R<>(sysOauthClientDetailsService.page(page, Wrappers.query(sysOauthClientDetails)));
|
||||
return R.ok(sysOauthClientDetailsService.page(page, Wrappers.query(sysOauthClientDetails)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class OauthClientDetailsController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_client_add')")
|
||||
public R add(@Valid @RequestBody SysOauthClientDetails sysOauthClientDetails) {
|
||||
return new R<>(sysOauthClientDetailsService.save(sysOauthClientDetails));
|
||||
return R.ok(sysOauthClientDetailsService.save(sysOauthClientDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class OauthClientDetailsController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_client_del')")
|
||||
public R removeById(@PathVariable String id) {
|
||||
return new R<>(sysOauthClientDetailsService.removeClientDetailsById(id));
|
||||
return R.ok(sysOauthClientDetailsService.removeClientDetailsById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,6 +107,6 @@ public class OauthClientDetailsController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_client_edit')")
|
||||
public R update(@Valid @RequestBody SysOauthClientDetails sysOauthClientDetails) {
|
||||
return new R<>(sysOauthClientDetailsService.updateClientDetailsById(sysOauthClientDetails));
|
||||
return R.ok(sysOauthClientDetailsService.updateClientDetailsById(sysOauthClientDetails));
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -53,7 +53,7 @@ public class RoleController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R<>(sysRoleService.getById(id));
|
||||
return R.ok(sysRoleService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class RoleController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_role_add')")
|
||||
public R save(@Valid @RequestBody SysRole sysRole) {
|
||||
return new R<>(sysRoleService.save(sysRole));
|
||||
return R.ok(sysRoleService.save(sysRole));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ public class RoleController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_role_edit')")
|
||||
public R update(@Valid @RequestBody SysRole sysRole) {
|
||||
return new R<>(sysRoleService.updateById(sysRole));
|
||||
return R.ok(sysRoleService.updateById(sysRole));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class RoleController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_role_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(sysRoleService.removeRoleById(id));
|
||||
return R.ok(sysRoleService.removeRoleById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ public class RoleController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R listRoles() {
|
||||
return new R<>(sysRoleService.list(Wrappers.emptyWrapper()));
|
||||
return R.ok(sysRoleService.list(Wrappers.emptyWrapper()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public class RoleController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getRolePage(Page page) {
|
||||
return new R<>(sysRoleService.page(page, Wrappers.emptyWrapper()));
|
||||
return R.ok(sysRoleService.page(page, Wrappers.emptyWrapper()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +128,6 @@ public class RoleController {
|
||||
@PreAuthorize("@pms.hasPermission('sys_role_perm')")
|
||||
public R saveRoleMenus(Integer roleId, @RequestParam(value = "menuIds", required = false) String menuIds) {
|
||||
SysRole sysRole = sysRoleService.getById(roleId);
|
||||
return new R<>(sysRoleMenuService.saveRoleMenus(sysRole.getRoleCode(), roleId, menuIds));
|
||||
return R.ok(sysRoleMenuService.saveRoleMenus(sysRole.getRoleCode(), roleId, menuIds));
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -60,7 +60,7 @@ public class SysPublicParamController {
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "publicKey", value = "键值,譬如:VERSION_INSTRUCTIONS", required = true)})
|
||||
@GetMapping("/publicValue/{publicKey}")
|
||||
public R publicKey(@PathVariable("publicKey") String publicKey) {
|
||||
return new R<>(sysPublicParamService.getSysPublicParamKeyToValue(publicKey));
|
||||
return R.ok(sysPublicParamService.getSysPublicParamKeyToValue(publicKey));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public class SysPublicParamController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSysPublicParamPage(Page page, SysPublicParam sysPublicParam) {
|
||||
return new R<>(sysPublicParamService.page(page, Wrappers.query(sysPublicParam)));
|
||||
return R.ok(sysPublicParamService.page(page, Wrappers.query(sysPublicParam)));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SysPublicParamController {
|
||||
*/
|
||||
@GetMapping("/{publicId}")
|
||||
public R getById(@PathVariable("publicId") Long publicId) {
|
||||
return new R<>(sysPublicParamService.getById(publicId));
|
||||
return R.ok(sysPublicParamService.getById(publicId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ public class SysPublicParamController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_add')")
|
||||
public R save(@RequestBody SysPublicParam sysPublicParam) {
|
||||
return new R<>(sysPublicParamService.save(sysPublicParam));
|
||||
return R.ok(sysPublicParamService.save(sysPublicParam));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public class SysPublicParamController {
|
||||
@CacheEvict(value = CacheConstants.PARAMS_DETAILS, key = "#sysPublicParam.publicKey")
|
||||
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_edit')")
|
||||
public R updateById(@RequestBody SysPublicParam sysPublicParam) {
|
||||
return new R<>(sysPublicParamService.updateById(sysPublicParam));
|
||||
return R.ok(sysPublicParamService.updateById(sysPublicParam));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ public class SysPublicParamController {
|
||||
@CacheEvict(value = CacheConstants.PARAMS_DETAILS, allEntries = true)
|
||||
@PreAuthorize("@pms.hasPermission('admin_syspublicparam_del')")
|
||||
public R removeById(@PathVariable Long publicId) {
|
||||
return new R<>(sysPublicParamService.removeById(publicId));
|
||||
return R.ok(sysPublicParamService.removeById(publicId));
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -47,7 +47,7 @@ public class SysRouteConfController {
|
||||
*/
|
||||
@GetMapping
|
||||
public R listRoutes() {
|
||||
return new R<>(sysRouteConfService.list());
|
||||
return R.ok(sysRouteConfService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class SysRouteConfController {
|
||||
@SysLog("修改路由")
|
||||
@PutMapping
|
||||
public R updateRoutes(@RequestBody JSONArray routes) {
|
||||
return new R(sysRouteConfService.updateRoutes(routes));
|
||||
return R.ok(sysRouteConfService.updateRoutes(routes));
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -55,7 +55,7 @@ public class SysSocialDetailsController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSocialDetailsPage(Page page, SysSocialDetails sysSocialDetails) {
|
||||
return new R<>(sysSocialDetailsService.page(page, Wrappers.query(sysSocialDetails)));
|
||||
return R.ok(sysSocialDetailsService.page(page, Wrappers.query(sysSocialDetails)));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SysSocialDetailsController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(sysSocialDetailsService.getById(id));
|
||||
return R.ok(sysSocialDetailsService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class SysSocialDetailsController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_social_details_add')")
|
||||
public R save(@Valid @RequestBody SysSocialDetails sysSocialDetails) {
|
||||
return new R<>(sysSocialDetailsService.save(sysSocialDetails));
|
||||
return R.ok(sysSocialDetailsService.save(sysSocialDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class SysSocialDetailsController {
|
||||
@PreAuthorize("@pms.hasPermission('sys_social_details_edit')")
|
||||
public R updateById(@Valid @RequestBody SysSocialDetails sysSocialDetails) {
|
||||
sysSocialDetailsService.updateById(sysSocialDetails);
|
||||
return new R<>(Boolean.TRUE);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ public class SysSocialDetailsController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('sys_social_details_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(sysSocialDetailsService.removeById(id));
|
||||
return R.ok(sysSocialDetailsService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ public class SysSocialDetailsController {
|
||||
@Inner
|
||||
@GetMapping("/info/{inStr}")
|
||||
public R getUserInfo(@PathVariable String inStr) {
|
||||
return new R<>(sysSocialDetailsService.getUserInfo(inStr));
|
||||
return R.ok(sysSocialDetailsService.getUserInfo(inStr));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,6 +131,6 @@ public class SysSocialDetailsController {
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public R bindSocial(String state, String code) {
|
||||
return new R<>(sysSocialDetailsService.bindSocial(state, code));
|
||||
return R.ok(sysSocialDetailsService.bindSocial(state, code));
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -60,9 +60,9 @@ public class UserController {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query()
|
||||
.lambda().eq(SysUser::getUsername, username));
|
||||
if (user == null) {
|
||||
return new R<>(Boolean.FALSE, "获取当前用户信息失败");
|
||||
return R.failed(Boolean.FALSE, "获取当前用户信息失败");
|
||||
}
|
||||
return new R<>(userService.findUserInfo(user));
|
||||
return R.ok(userService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,9 +76,9 @@ public class UserController {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query()
|
||||
.lambda().eq(SysUser::getUsername, username));
|
||||
if (user == null) {
|
||||
return new R<>(Boolean.FALSE, String.format("用户信息为空 %s", username));
|
||||
return R.failed(Boolean.FALSE, String.format("用户信息为空 %s", username));
|
||||
}
|
||||
return new R<>(userService.findUserInfo(user));
|
||||
return R.ok(userService.findUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public class UserController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R user(@PathVariable Integer id) {
|
||||
return new R<>(userService.selectUserVoById(id));
|
||||
return R.ok(userService.selectUserVoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ public class UserController {
|
||||
public R user(@PathVariable String username) {
|
||||
SysUser condition = new SysUser();
|
||||
condition.setUsername(username);
|
||||
return new R<>(userService.getOne(new QueryWrapper<>(condition)));
|
||||
return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public class UserController {
|
||||
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
||||
public R userDel(@PathVariable Integer id) {
|
||||
SysUser sysUser = userService.getById(id);
|
||||
return new R<>(userService.deleteUserById(sysUser));
|
||||
return R.ok(userService.deleteUserById(sysUser));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ public class UserController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_add')")
|
||||
public R user(@RequestBody UserDTO userDto) {
|
||||
return new R<>(userService.saveUser(userDto));
|
||||
return R.ok(userService.saveUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public class UserController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
||||
public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
||||
return new R<>(userService.updateUser(userDto));
|
||||
return R.ok(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ public class UserController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getUserPage(Page page, UserDTO userDTO) {
|
||||
return new R<>(userService.getUsersWithRolePage(page, userDTO));
|
||||
return R.ok(userService.getUsersWithRolePage(page, userDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,6 +177,6 @@ public class UserController {
|
||||
*/
|
||||
@GetMapping("/ancestor/{username}")
|
||||
public R listAncestorUsers(@PathVariable String username) {
|
||||
return new R<>(userService.listAncestorUsers(username));
|
||||
return R.ok(userService.listAncestorUsers(username));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -64,14 +64,14 @@ public class MobileServiceImpl implements MobileService {
|
||||
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
log.info("手机号未注册:{}", mobile);
|
||||
return new R<>(Boolean.FALSE, "手机号未注册");
|
||||
return R.ok(Boolean.FALSE, "手机号未注册");
|
||||
}
|
||||
|
||||
Object codeObj = pigxRedisTemplate.opsForValue().get(CommonConstants.DEFAULT_CODE_KEY + mobile);
|
||||
|
||||
if (codeObj != null) {
|
||||
log.info("手机号验证码未过期:{},{}", mobile, codeObj);
|
||||
return new R<>(Boolean.FALSE, "验证码发送过频繁");
|
||||
return R.ok(Boolean.FALSE, "验证码发送过频繁");
|
||||
}
|
||||
|
||||
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
||||
@@ -79,6 +79,6 @@ public class MobileServiceImpl implements MobileService {
|
||||
pigxRedisTemplate.opsForValue().set(
|
||||
CommonConstants.DEFAULT_CODE_KEY + LoginTypeEnum.SMS.getType() + "@" + mobile
|
||||
, code, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
||||
return new R<>(Boolean.TRUE, code);
|
||||
return R.ok(Boolean.TRUE, code);
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -29,7 +29,6 @@ import com.pig4cloud.pigx.admin.mapper.SysMenuMapper;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysRoleMenuMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -66,9 +65,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query()
|
||||
.lambda().eq(SysMenu::getParentId, id));
|
||||
if (CollUtil.isNotEmpty(menuList)) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg("菜单含有下级不能删除").build();
|
||||
return R.failed("菜单含有下级不能删除");
|
||||
}
|
||||
|
||||
sysRoleMenuMapper
|
||||
@@ -76,7 +73,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
.lambda().eq(SysRoleMenu::getMenuId, id));
|
||||
|
||||
//删除当前菜单及其子菜单
|
||||
return new R(this.removeById(id));
|
||||
return R.ok(this.removeById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -171,13 +171,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
|
||||
} else {
|
||||
log.warn("原密码错误,修改密码失败:{}", userDto.getUsername());
|
||||
return new R<>(Boolean.FALSE, "原密码错误,修改失败");
|
||||
return R.ok(Boolean.FALSE, "原密码错误,修改失败");
|
||||
}
|
||||
}
|
||||
sysUser.setPhone(userDto.getPhone());
|
||||
sysUser.setUserId(userVO.getUserId());
|
||||
sysUser.setAvatar(userDto.getAvatar());
|
||||
return new R<>(this.updateById(sysUser));
|
||||
return R.ok(this.updateById(sysUser));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
<logger name="com.alibaba.nacos" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
|
||||
+6
-6
@@ -51,7 +51,7 @@ public class LeaveBillController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getLeaveBillPage(Page page, LeaveBill leaveBill) {
|
||||
return new R<>(leaveBillService.page(page, Wrappers.query(leaveBill)));
|
||||
return R.ok(leaveBillService.page(page, Wrappers.query(leaveBill)));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class LeaveBillController {
|
||||
*/
|
||||
@GetMapping("/{leaveId}")
|
||||
public R getById(@PathVariable("leaveId") Integer leaveId) {
|
||||
return new R<>(leaveBillService.getById(leaveId));
|
||||
return R.ok(leaveBillService.getById(leaveId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public class LeaveBillController {
|
||||
public R save(@RequestBody LeaveBill leaveBill) {
|
||||
leaveBill.setUsername(SecurityUtils.getUser().getUsername());
|
||||
leaveBill.setState(TaskStatusEnum.UNSUBMIT.getStatus());
|
||||
return new R<>(leaveBillService.save(leaveBill));
|
||||
return R.ok(leaveBillService.save(leaveBill));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class LeaveBillController {
|
||||
*/
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody LeaveBill leaveBill) {
|
||||
return new R<>(leaveBillService.updateById(leaveBill));
|
||||
return R.ok(leaveBillService.updateById(leaveBill));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public class LeaveBillController {
|
||||
*/
|
||||
@DeleteMapping("/{leaveId}")
|
||||
public R removeById(@PathVariable Integer leaveId) {
|
||||
return new R<>(leaveBillService.removeById(leaveId));
|
||||
return R.ok(leaveBillService.removeById(leaveId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +109,6 @@ public class LeaveBillController {
|
||||
*/
|
||||
@GetMapping("/submit/{leaveId}")
|
||||
public R submit(@PathVariable("leaveId") Integer leaveId) {
|
||||
return new R<>(processService.saveStartProcess(leaveId));
|
||||
return R.ok(processService.saveStartProcess(leaveId));
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -39,28 +39,28 @@ public class ModelController {
|
||||
@PostMapping(value = "/insert")
|
||||
public R<Boolean> insertForm(@RequestBody @Valid ModelForm form) {
|
||||
modelService.create(form.getName(), form.getKey(), form.getDesc(), form.getCategory());
|
||||
return new R<>(Boolean.TRUE);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R createModel(@RequestParam String name, @RequestParam String key,
|
||||
@RequestParam String desc, @RequestParam String category) {
|
||||
return new R(modelService.create(name, key, desc, category));
|
||||
return R.ok(modelService.create(name, key, desc, category));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public R getModelPage(@RequestParam Map<String, Object> params) {
|
||||
return new R<>(modelService.getModelPage(params));
|
||||
return R.ok(modelService.getModelPage(params));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public R removeModelById(@PathVariable("id") String id) {
|
||||
return new R<>(modelService.removeModelById(id));
|
||||
return R.ok(modelService.removeModelById(id));
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/deploy/{id}")
|
||||
public R deploy(@PathVariable("id") String id) {
|
||||
return new R<>(modelService.deploy(id));
|
||||
return R.ok(modelService.deploy(id));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -44,7 +44,7 @@ public class ProcessController {
|
||||
|
||||
@GetMapping
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
return new R<>(processService.getProcessByPage(params));
|
||||
return R.ok(processService.getProcessByPage(params));
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@@ -65,11 +65,11 @@ public class ProcessController {
|
||||
|
||||
@PutMapping("/status/{procDefId}/{status}")
|
||||
public R updateState(@PathVariable String procDefId, @PathVariable String status) {
|
||||
return new R<>(processService.updateStatus(status, procDefId));
|
||||
return R.ok(processService.updateStatus(status, procDefId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{deploymentId}")
|
||||
public R deleteProcIns(@PathVariable String deploymentId) {
|
||||
return new R<>(processService.removeProcIns(deploymentId));
|
||||
return R.ok(processService.removeProcIns(deploymentId));
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -45,17 +45,17 @@ public class TaskController {
|
||||
|
||||
@GetMapping("/todo")
|
||||
public R todo(@RequestParam Map<String, Object> params) {
|
||||
return new R<>(actTaskService.getTaskByName(params, SecurityUtils.getUser().getUsername()));
|
||||
return R.ok(actTaskService.getTaskByName(params, SecurityUtils.getUser().getUsername()));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public R getTaskById(@PathVariable String id) {
|
||||
return new R(actTaskService.getTaskById(id));
|
||||
return R.ok(actTaskService.getTaskById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R submitTask(@RequestBody LeaveBillDto leaveBillDto) {
|
||||
return new R(actTaskService.submitTask(leaveBillDto));
|
||||
return R.ok(actTaskService.submitTask(leaveBillDto));
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@@ -69,7 +69,7 @@ public class TaskController {
|
||||
|
||||
@GetMapping("/comment/{id}")
|
||||
public R commitList(@PathVariable String id) {
|
||||
return new R(actTaskService.getCommentByTaskId(id));
|
||||
return R.ok(actTaskService.getCommentByTaskId(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -47,7 +47,7 @@ public class SysDsConfController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSysDatasourceConfPage(Page page, SysDatasourceConf sysDatasourceConf) {
|
||||
return new R<>(sysDatasourceConfService.page(page, Wrappers.query(sysDatasourceConf)));
|
||||
return R.ok(sysDatasourceConfService.page(page, Wrappers.query(sysDatasourceConf)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ public class SysDsConfController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
return new R<>(sysDatasourceConfService.list());
|
||||
return R.ok(sysDatasourceConfService.list());
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SysDsConfController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(sysDatasourceConfService.getById(id));
|
||||
return R.ok(sysDatasourceConfService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class SysDsConfController {
|
||||
@SysLog("新增数据源表")
|
||||
@PostMapping
|
||||
public R save(@RequestBody SysDatasourceConf sysDatasourceConf) {
|
||||
return new R<>(sysDatasourceConfService.saveDsByEnc(sysDatasourceConf));
|
||||
return R.ok(sysDatasourceConfService.saveDsByEnc(sysDatasourceConf));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class SysDsConfController {
|
||||
@SysLog("修改数据源表")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody SysDatasourceConf sysDatasourceConf) {
|
||||
return new R<>(sysDatasourceConfService.updateDsByEnc(sysDatasourceConf));
|
||||
return R.ok(sysDatasourceConfService.updateDsByEnc(sysDatasourceConf));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ public class SysDsConfController {
|
||||
@SysLog("删除数据源表")
|
||||
@DeleteMapping("/{id}")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(sysDatasourceConfService.removeById(id));
|
||||
return R.ok(sysDatasourceConfService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class SysGeneratorController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getPage(Page page, String tableName, Integer id) {
|
||||
return new R<>(sysGeneratorService.getPage(page, tableName, id));
|
||||
return R.ok(sysGeneratorService.getPage(page, tableName, id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ${className}Controller {
|
||||
*/
|
||||
@GetMapping("/page" )
|
||||
public R get${className}Page(Page page, ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
return R.ok(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ${className}Controller {
|
||||
*/
|
||||
@GetMapping("/{${pk.lowerAttrName}}" )
|
||||
public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return new R<>(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public class ${className}Controller {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" )
|
||||
public R save(@RequestBody ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.save(${classname}));
|
||||
return R.ok(${classname}Service.save(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ public class ${className}Controller {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" )
|
||||
public R updateById(@RequestBody ${className} ${classname}) {
|
||||
return new R<>(${classname}Service.updateById(${classname}));
|
||||
return R.ok(${classname}Service.updateById(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public class ${className}Controller {
|
||||
@DeleteMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" )
|
||||
public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return new R<>(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,6 +83,8 @@
|
||||
this.tableData = response.data.data.records
|
||||
this.page.total = response.data.data.total
|
||||
this.tableLoading = false
|
||||
}).catch(() => {
|
||||
this.listLoading=false
|
||||
})
|
||||
},
|
||||
rowDel: function (row, index) {
|
||||
@@ -101,7 +103,6 @@
|
||||
type: 'success'
|
||||
})
|
||||
this.getList(this.page)
|
||||
}).catch(function (err) {
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -111,7 +112,7 @@
|
||||
* @param done 为表单关闭函数
|
||||
*
|
||||
**/
|
||||
handleUpdate: function (row, index, done) {
|
||||
handleUpdate: function (row, index, done,loading) {
|
||||
putObj(row).then(data => {
|
||||
this.tableData.splice(index, 1, Object.assign({}, row))
|
||||
this.$message({
|
||||
@@ -121,7 +122,9 @@
|
||||
})
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
}).catch(() => {
|
||||
loading();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @title 数据添加
|
||||
@@ -129,7 +132,7 @@
|
||||
* @param done 为表单关闭函数
|
||||
*
|
||||
**/
|
||||
handleSave: function (row, done) {
|
||||
handleSave: function (row, done,loading) {
|
||||
addObj(row).then(data => {
|
||||
this.tableData.push(Object.assign({}, row))
|
||||
this.$message({
|
||||
@@ -139,7 +142,9 @@
|
||||
})
|
||||
done()
|
||||
this.getList(this.page)
|
||||
})
|
||||
}).catch(() => {
|
||||
loading();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 搜索回调
|
||||
|
||||
+5
-5
@@ -47,7 +47,7 @@ public class ExecutionLogController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getExecutionLogPage(Page page, ExecutionLog executionLog) {
|
||||
return new R<>(executionLogService.page(page, Wrappers.query(executionLog)));
|
||||
return R.ok(executionLogService.page(page, Wrappers.query(executionLog)));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ExecutionLogController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") String id) {
|
||||
return new R<>(executionLogService.getById(id));
|
||||
return R.ok(executionLogService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ public class ExecutionLogController {
|
||||
*/
|
||||
@PostMapping
|
||||
public R save(@RequestBody ExecutionLog executionLog) {
|
||||
return new R<>(executionLogService.save(executionLog));
|
||||
return R.ok(executionLogService.save(executionLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class ExecutionLogController {
|
||||
*/
|
||||
@PutMapping
|
||||
public R update(@RequestBody ExecutionLog executionLog) {
|
||||
return new R<>(executionLogService.updateById(executionLog));
|
||||
return R.ok(executionLogService.updateById(executionLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class ExecutionLogController {
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public R removeById(@PathVariable String id) {
|
||||
return new R<>(executionLogService.removeById(id));
|
||||
return R.ok(executionLogService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -45,7 +45,7 @@ public class StatusTraceLogController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getStatusTraceLogPage(Page<StatusTraceLog> page, StatusTraceLog statusTraceLog) {
|
||||
return new R<>(statusTraceLogService.page(page, Wrappers.query(statusTraceLog)));
|
||||
return R.ok(statusTraceLogService.page(page, Wrappers.query(statusTraceLog)));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StatusTraceLogController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") String id) {
|
||||
return new R<>(statusTraceLogService.getById(id));
|
||||
return R.ok(statusTraceLogService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public class StatusTraceLogController {
|
||||
*/
|
||||
@PostMapping
|
||||
public R save(@RequestBody StatusTraceLog statusTraceLog) {
|
||||
return new R<>(statusTraceLogService.save(statusTraceLog));
|
||||
return R.ok(statusTraceLogService.save(statusTraceLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ public class StatusTraceLogController {
|
||||
*/
|
||||
@PutMapping
|
||||
public R update(@RequestBody StatusTraceLog statusTraceLog) {
|
||||
return new R<>(statusTraceLogService.updateById(statusTraceLog));
|
||||
return R.ok(statusTraceLogService.updateById(statusTraceLog));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public class StatusTraceLogController {
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public R removeById(@PathVariable("id") String id) {
|
||||
return new R<>(statusTraceLogService.removeById(id));
|
||||
return R.ok(statusTraceLogService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+14
-15
@@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
@@ -66,7 +65,7 @@ public class SysJobController {
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "分页定时业务查询")
|
||||
public R getSysJobPage(Page page, SysJob sysJob) {
|
||||
return R.builder().data(sysJobService.page(page, Wrappers.query(sysJob))).build();
|
||||
return R.ok(sysJobService.page(page, Wrappers.query(sysJob)));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +78,7 @@ public class SysJobController {
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "唯一标识查询定时任务")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return R.builder().data(sysJobService.getById(id)).build();
|
||||
return R.ok(sysJobService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +94,7 @@ public class SysJobController {
|
||||
public R save(@RequestBody SysJob sysJob) {
|
||||
sysJob.setJobStatus(JOB_STATUS_RELEASE.getType());
|
||||
sysJob.setCreateBy(SecurityUtils.getUser().getUsername());
|
||||
return R.builder().data(sysJobService.save(sysJob)).build();
|
||||
return R.ok(sysJobService.save(sysJob));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +116,7 @@ public class SysJobController {
|
||||
} else if (JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
||||
sysJobService.updateById(sysJob);
|
||||
}
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +137,7 @@ public class SysJobController {
|
||||
} else if (JOB_STATUS_RELEASE.getType().equals(querySysJob.getJobStatus())) {
|
||||
this.sysJobService.removeById(id);
|
||||
}
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,13 +154,13 @@ public class SysJobController {
|
||||
int count = this.sysJobService.count(new LambdaQueryWrapper<SysJob>()
|
||||
.eq(SysJob::getJobStatus, JOB_STATUS_RUNNING.getType()));
|
||||
if (count <= 0) {
|
||||
return R.builder().msg("无正在运行定时任务").build();
|
||||
return R.ok("无正在运行定时任务");
|
||||
} else {
|
||||
//更新定时任务状态条件,运行状态2更新为暂停状态2
|
||||
this.sysJobService.update(SysJob.builder()
|
||||
.jobStatus(JOB_STATUS_NOT_RUNNING.getType()).build(), new UpdateWrapper<SysJob>()
|
||||
.lambda().eq(SysJob::getJobStatus, JOB_STATUS_RUNNING.getType()));
|
||||
return R.builder().msg("暂停成功").build();
|
||||
return R.ok("暂停成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ public class SysJobController {
|
||||
.getType()).build(), new UpdateWrapper<SysJob>().lambda()
|
||||
.eq(SysJob::getJobStatus, JOB_STATUS_NOT_RUNNING.getType()));
|
||||
taskUtil.startJobs(scheduler);
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +203,7 @@ public class SysJobController {
|
||||
taskUtil.removeJob(sysjob, scheduler);
|
||||
}
|
||||
});
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +227,7 @@ public class SysJobController {
|
||||
//更新定时任务状态条件,暂停状态3更新为运行状态2
|
||||
this.sysJobService.updateById(SysJob.builder().jobId(jobId)
|
||||
.jobStatus(JOB_STATUS_RUNNING.getType()).build());
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +245,7 @@ public class SysJobController {
|
||||
this.sysJobService.updateById(SysJob.builder().jobId(querySysJob.getJobId())
|
||||
.jobStatus(JOB_STATUS_NOT_RUNNING.getType()).build());
|
||||
taskUtil.pauseJob(querySysJob, scheduler);
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +256,7 @@ public class SysJobController {
|
||||
@GetMapping("/job-log")
|
||||
@ApiOperation(value = "唯一标识查询定时执行日志")
|
||||
public R getJobLog(Page page, SysJobLog sysJobLog) {
|
||||
return R.builder().data(sysJobLogService.page(page, Wrappers.query(sysJobLog))).build();
|
||||
return R.ok(sysJobLogService.page(page, Wrappers.query(sysJobLog)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,8 +267,8 @@ public class SysJobController {
|
||||
@GetMapping("/is-valid-task-name")
|
||||
@ApiOperation(value = "检验任务名称和任务组联合是否唯一")
|
||||
public R isValidTaskName(@RequestParam String jobName, @RequestParam String jobGroup) {
|
||||
return R.builder().data(this.sysJobService
|
||||
return this.sysJobService
|
||||
.count(Wrappers.query(SysJob.builder().jobName(jobName).jobGroup(jobGroup).build())) > 0
|
||||
? CommonConstants.FAIL : CommonConstants.SUCCESS).build();
|
||||
? R.failed() : R.ok();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -52,6 +52,6 @@ public class SysJobLogController {
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "分页定时任务日志查询")
|
||||
public R getSysJobLogPage(Page page, SysJobLog sysJobLog) {
|
||||
return R.builder().data(sysJobLogService.page(page, Wrappers.query(sysJobLog))).build();
|
||||
return R.ok(sysJobLogService.page(page, Wrappers.query(sysJobLog)));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -27,6 +27,6 @@ public class RestTaskDemo {
|
||||
@GetMapping("/{param}")
|
||||
public R demoMethod(@PathVariable("param") String param) {
|
||||
log.info("测试于:{},传入参数{}", LocalDateTime.now(), param);
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class RedisController {
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public R memory() {
|
||||
return R.builder().data(redisService.getInfo()).build();
|
||||
return R.ok(redisService.getInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-6
@@ -75,14 +75,10 @@ public class RedisServiceImpl implements RedisService {
|
||||
}
|
||||
return connection.execute(arrs[0], bytes);
|
||||
});
|
||||
return R.builder()
|
||||
.msg("success")
|
||||
.data(StrUtil.str(result, CharsetUtil.UTF_8)).build();
|
||||
return R.ok(StrUtil.str(result, CharsetUtil.UTF_8), "success");
|
||||
} catch (Exception e) {
|
||||
log.error("REDIS 命令执行失败", e);
|
||||
return R.builder()
|
||||
.msg("error")
|
||||
.data(e.getMessage()).build();
|
||||
return R.failed("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -50,7 +50,7 @@ public class WxAccountController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getWxAccountPage(Page page, WxAccount wxAccount) {
|
||||
return new R<>(wxAccountService.page(page, Wrappers.query(wxAccount)));
|
||||
return R.ok(wxAccountService.page(page, Wrappers.query(wxAccount)));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class WxAccountController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(wxAccountService.getById(id));
|
||||
return R.ok(wxAccountService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class WxAccountController {
|
||||
public R save(@RequestBody WxAccount wxAccount) {
|
||||
wxAccountService.save(wxAccount);
|
||||
wxMpConfiguration.initServices();
|
||||
return new R<>();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class WxAccountController {
|
||||
public R updateById(@RequestBody WxAccount wxAccount) {
|
||||
wxAccountService.updateById(wxAccount);
|
||||
wxMpConfiguration.initServices();
|
||||
return new R<>();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ public class WxAccountController {
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
wxAccountService.removeById(id);
|
||||
wxMpConfiguration.initServices();
|
||||
return new R<>();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ public class WxAccountController {
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
return new R<>(wxAccountService.list());
|
||||
return R.ok(wxAccountService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-6
@@ -49,7 +49,7 @@ public class WxAccountFansController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getWxAccountFansPage(Page page, WxAccountFans wxAccountFans) {
|
||||
return new R<>(wxAccountFansService.page(page, Wrappers.query(wxAccountFans)));
|
||||
return R.ok(wxAccountFansService.page(page, Wrappers.query(wxAccountFans)));
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class WxAccountFansController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(wxAccountFansService.getById(id));
|
||||
return R.ok(wxAccountFansService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class WxAccountFansController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxaccountfans_add')")
|
||||
public R save(@RequestBody WxAccountFans wxAccountFans) {
|
||||
return new R<>(wxAccountFansService.save(wxAccountFans));
|
||||
return R.ok(wxAccountFansService.save(wxAccountFans));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class WxAccountFansController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxaccountfans_edit')")
|
||||
public R updateById(@RequestBody WxAccountFans wxAccountFans) {
|
||||
return new R<>(wxAccountFansService.updateById(wxAccountFans));
|
||||
return R.ok(wxAccountFansService.updateById(wxAccountFans));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public class WxAccountFansController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxaccountfans_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(wxAccountFansService.removeById(id));
|
||||
return R.ok(wxAccountFansService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public class WxAccountFansController {
|
||||
*/
|
||||
@PostMapping("/sync/{appId}")
|
||||
public R sync(@PathVariable String appId) {
|
||||
return new R(wxAccountFansService.syncAccountFans(appId));
|
||||
return R.ok(wxAccountFansService.syncAccountFans(appId));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -51,7 +51,7 @@ public class WxFansMsgController {
|
||||
@GetMapping("/page")
|
||||
public R getWxFansMsgPage(Page page, WxFansMsg wxFansMsg) {
|
||||
wxFansMsg.setTenantId(TenantContextHolder.getTenantId());
|
||||
return new R<>(wxFansMsgService.page(page, Wrappers.query(wxFansMsg)));
|
||||
return R.ok(wxFansMsgService.page(page, Wrappers.query(wxFansMsg)));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class WxFansMsgController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(wxFansMsgService.getById(id));
|
||||
return R.ok(wxFansMsgService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class WxFansMsgController {
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_add')")
|
||||
public R save(@RequestBody WxFansMsg wxFansMsg) {
|
||||
wxFansMsg.setTenantId(TenantContextHolder.getTenantId());
|
||||
return new R<>(wxFansMsgService.save(wxFansMsg));
|
||||
return R.ok(wxFansMsgService.save(wxFansMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ public class WxFansMsgController {
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_edit')")
|
||||
public R updateById(@RequestBody WxFansMsg wxFansMsg) {
|
||||
wxFansMsg.setTenantId(TenantContextHolder.getTenantId());
|
||||
return new R<>(wxFansMsgService.updateById(wxFansMsg));
|
||||
return R.ok(wxFansMsgService.updateById(wxFansMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public class WxFansMsgController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsg_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(wxFansMsgService.removeById(id));
|
||||
return R.ok(wxFansMsgService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -49,7 +49,7 @@ public class WxFansMsgResController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getWxFansMsgResPage(Page page, WxFansMsgRes wxFansMsgRes) {
|
||||
return new R<>(wxFansMsgResService.page(page, Wrappers.query(wxFansMsgRes)));
|
||||
return R.ok(wxFansMsgResService.page(page, Wrappers.query(wxFansMsgRes)));
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class WxFansMsgResController {
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
return new R<>(wxFansMsgResService.getById(id));
|
||||
return R.ok(wxFansMsgResService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class WxFansMsgResController {
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsgres_edit')")
|
||||
public R updateById(@RequestBody WxFansMsgRes wxFansMsgRes) {
|
||||
return new R<>(wxFansMsgResService.updateById(wxFansMsgRes));
|
||||
return R.ok(wxFansMsgResService.updateById(wxFansMsgRes));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public class WxFansMsgResController {
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxfansmsgres_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
return new R<>(wxFansMsgResService.removeById(id));
|
||||
return R.ok(wxFansMsgResService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class WxMenuController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getWxMpMenuPage(Page page, WxMpMenu WxMpMenu) {
|
||||
return new R<>(wxMenuService.page(page, Wrappers.query(WxMpMenu)));
|
||||
return R.ok(wxMenuService.page(page, Wrappers.query(WxMpMenu)));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WxMenuController {
|
||||
@PostMapping("/{appId}")
|
||||
@PreAuthorize("@pms.hasPermission('mp_wxmenu_add')")
|
||||
public R save(@RequestBody JSONObject WxMpMenus, @PathVariable String appId) {
|
||||
return new R(wxMenuService.save(WxMpMenus, appId));
|
||||
return R.ok(wxMenuService.save(WxMpMenus, appId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-5
@@ -19,7 +19,6 @@ package com.pig4cloud.pigx.mp.service.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.mp.config.WxMpConfiguration;
|
||||
import com.pig4cloud.pigx.mp.entity.WxAccount;
|
||||
@@ -72,10 +71,10 @@ public class WxAccountServiceImpl extends ServiceImpl<WxAccountMapper, WxAccount
|
||||
baseMapper.updateById(wxAccount);
|
||||
} catch (WxErrorException e) {
|
||||
log.error(" 获取公众号二维码失败", e);
|
||||
return R.builder().code(CommonConstants.FAIL).msg("更新公众号二维码失败").build();
|
||||
return R.failed("更新公众号二维码失败");
|
||||
}
|
||||
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +127,9 @@ public class WxAccountServiceImpl extends ServiceImpl<WxAccountMapper, WxAccount
|
||||
result.add(dateList);
|
||||
} catch (WxErrorException e) {
|
||||
log.error(" 获取公众号统计数据报错", e);
|
||||
return R.builder().code(CommonConstants.FAIL).msg("获取公众号数据失败:" + e.getError().getErrorMsg()).build();
|
||||
return R.failed("获取公众号数据失败:" + e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
return R.builder().data(result).build();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -17,7 +17,6 @@
|
||||
package com.pig4cloud.pigx.mp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
@@ -75,7 +74,7 @@ public class WxFansMsgResServiceImpl extends ServiceImpl<WxFansMsgResMapper, WxF
|
||||
.build());
|
||||
} catch (WxErrorException e) {
|
||||
log.error("发送客服消息失败 ", e);
|
||||
return R.builder().code(CommonConstants.FAIL).msg(e.getError().getErrorMsg()).build();
|
||||
return R.failed(e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
@@ -85,6 +84,6 @@ public class WxFansMsgResServiceImpl extends ServiceImpl<WxFansMsgResMapper, WxF
|
||||
|
||||
wxFansMsg.setIsRes("1");
|
||||
wxFansMsgMapper.updateById(wxFansMsg);
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+8
-17
@@ -20,7 +20,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.mp.config.WxMpConfiguration;
|
||||
import com.pig4cloud.pigx.mp.entity.WxAccount;
|
||||
@@ -88,16 +87,12 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
|
||||
if (CollUtil.isEmpty(wxMpMenuList)) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg("微信菜单配置未保存,不能发布").build();
|
||||
return R.failed("微信菜单配置未保存,不能发布");
|
||||
}
|
||||
WxMpMenu wxMpMenu = wxMpMenuList.get(0);
|
||||
// 判断是否发布
|
||||
if (PUB_ED.equals(wxMpMenu.getPubFlag())) {
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg("微信菜单配置已发布,不要重复发布").build();
|
||||
return R.failed("微信菜单配置已发布,不要重复发布");
|
||||
}
|
||||
WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appId);
|
||||
WxMpMenuService menuService = wxMpService.getMenuService();
|
||||
@@ -107,15 +102,13 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
|
||||
menuService.menuCreate(wxMpMenu.getMenu());
|
||||
} catch (WxErrorException e) {
|
||||
log.error("发布微信菜单失败", e.getError().getErrorMsg());
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg(e.getError().getErrorMsg()).build();
|
||||
return R.failed(e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
//更新菜单发布标志
|
||||
wxMpMenu.setPubFlag(PUB_ED);
|
||||
baseMapper.updateById(wxMpMenu);
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +123,9 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
|
||||
if (CollUtil.isEmpty(wxMpMenuList)) {
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
return R.builder().data(wxMpMenuList.get(0).getMenu()).build();
|
||||
return R.ok(wxMpMenuList.get(0).getMenu());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,13 +142,11 @@ public class WxMenuServiceImpl extends ServiceImpl<WxMenuMapper, WxMpMenu> imple
|
||||
menuService.menuDelete();
|
||||
} catch (WxErrorException e) {
|
||||
log.error("微信菜单删除失败", e.getError().getErrorMsg());
|
||||
return R.builder()
|
||||
.code(CommonConstants.FAIL)
|
||||
.msg(e.getError().getErrorMsg()).build();
|
||||
return R.failed(e.getError().getErrorMsg());
|
||||
}
|
||||
|
||||
baseMapper.delete(Wrappers.<WxMpMenu>lambdaQuery()
|
||||
.eq(WxMpMenu::getWxAccountAppid, appId));
|
||||
return R.builder().build();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user