forked from zeasin/qihangerp-oms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
启航
committed
Mar 16, 2024
1 parent
ec3b56a
commit 38d6987
Showing
192 changed files
with
556 additions
and
15,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
sys-api/src/main/java/com/qihang/sys/api/controller/BaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,136 @@ | ||
package com.qihang.sys.api.controller; | ||
|
||
import com.qihang.common.common.AjaxResult; | ||
import com.qihang.common.utils.StringUtils; | ||
import com.qihang.security.LoginUser; | ||
import com.qihang.sys.api.common.SecurityUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.web.bind.WebDataBinder; | ||
import org.springframework.web.bind.annotation.InitBinder; | ||
|
||
import java.beans.PropertyEditorSupport; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
/** | ||
* web层通用数据处理 | ||
* | ||
* @author qihang | ||
*/ | ||
public class BaseController | ||
{ | ||
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
|
||
|
||
/** | ||
* 返回成功 | ||
*/ | ||
public AjaxResult success() | ||
{ | ||
return AjaxResult.success(); | ||
} | ||
|
||
/** | ||
* 返回失败消息 | ||
*/ | ||
public AjaxResult error() | ||
{ | ||
return AjaxResult.error(); | ||
} | ||
|
||
/** | ||
* 返回成功消息 | ||
*/ | ||
public AjaxResult success(String message) | ||
{ | ||
return AjaxResult.success(message); | ||
} | ||
|
||
/** | ||
* 返回成功消息 | ||
*/ | ||
public AjaxResult success(Object data) | ||
{ | ||
return AjaxResult.success(data); | ||
} | ||
|
||
/** | ||
* 返回失败消息 | ||
*/ | ||
public AjaxResult error(String message) | ||
{ | ||
return AjaxResult.error(message); | ||
} | ||
|
||
/** | ||
* 返回警告消息 | ||
*/ | ||
public AjaxResult warn(String message) | ||
{ | ||
return AjaxResult.warn(message); | ||
} | ||
|
||
/** | ||
* 响应返回结果 | ||
* | ||
* @param rows 影响行数 | ||
* @return 操作结果 | ||
*/ | ||
protected AjaxResult toAjax(int rows) | ||
{ | ||
return rows > 0 ? AjaxResult.success() : AjaxResult.error(); | ||
} | ||
|
||
/** | ||
* 响应返回结果 | ||
* | ||
* @param result 结果 | ||
* @return 操作结果 | ||
*/ | ||
protected AjaxResult toAjax(boolean result) | ||
{ | ||
return result ? success() : error(); | ||
} | ||
|
||
/** | ||
* 页面跳转 | ||
*/ | ||
public String redirect(String url) | ||
{ | ||
return StringUtils.format("redirect:{}", url); | ||
} | ||
|
||
/** | ||
* 获取用户缓存信息 | ||
*/ | ||
public LoginUser getLoginUser() | ||
{ | ||
return SecurityUtils.getLoginUser(); | ||
} | ||
|
||
/** | ||
* 获取登录用户id | ||
*/ | ||
public Long getUserId() | ||
{ | ||
return getLoginUser().getUserId(); | ||
} | ||
|
||
/** | ||
* 获取登录部门id | ||
*/ | ||
public Long getDeptId() | ||
{ | ||
return getLoginUser().getDeptId(); | ||
} | ||
|
||
/** | ||
* 获取登录用户名 | ||
*/ | ||
public String getUsername() | ||
{ | ||
return getLoginUser().getUsername(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.