From fa8f28cf848d2c3aeaa548a7ac65f93b690392c3 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期五, 23 八月 2024 10:19:35 +0800
Subject: [PATCH] 1、配置文件上传
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java | 207 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 171 insertions(+), 36 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java
index 8cbe7c2..8cb409a 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/controller/SmRoleQueryController.java
@@ -1,18 +1,22 @@
package com.vci.frameworkcore.controller;
import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI;
-import com.vci.frameworkcore.pagemodel.SmRoleVO;
+import com.vci.constant.FrameWorkLangCodeConstant;
+import com.vci.dto.SmRoleDTO;
+import com.vci.pagemodel.SmRoleVO;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.*;
+import com.vci.starter.web.util.LocalFileUtil;
import com.vci.starter.web.util.VciBaseUtil;
-import lombok.extern.slf4j.Slf4j;
+import com.vci.starter.web.util.WebThreadLocalUtil;
+import com.vci.web.enumpck.UserTypeEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.File;
import java.util.List;
import java.util.Map;
@@ -23,7 +27,6 @@
*/
@RestController
@RequestMapping("/roleQueryController")
-@Slf4j
public class SmRoleQueryController {
/**
@@ -33,20 +36,59 @@
private SmRoleQueryServiceI roleQueryService;
/**
+ * 鏃ュ織
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ /**
* 瑙掕壊鐨勫垪琛ㄥ弬鐓�
* @param queryObject 鏌ヨ瀵硅薄锛屽寘鍚簡鏌ヨ鏉′欢锛屽垎椤碉紝鎺掑簭绛�,鍗冲厑璁镐娇鐢⊿mRoleVO閲岀殑鎵�鏈夊睘鎬т綔涓烘煡璇㈡潯浠�
* @return 鏅�氳鑹诧紙涓嶅寘鍚笁鍛樼殑瑙掕壊锛夌殑鏄剧ず瀵硅薄鍒楄〃鏁版嵁锛岃鑾峰彇鍏朵腑鐨刣ata灞炴��
* @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父锛屽鏋滄槸鑰佺殑椤圭洰閲屼笉鎶涘嚭寮傚父
*/
@RequestMapping(value = "/refDataGrid",method = RequestMethod.GET)
- public BaseResult<SmRoleVO> refDataGrid(BaseQueryObject queryObject) throws VciBaseException {
- if(queryObject == null){
- queryObject = new BaseQueryObject();
+ public BaseResult<SmRoleVO> refDataGrid(BaseQueryObject queryObject) {
+ try {
+ if(queryObject == null){
+ queryObject = new BaseQueryObject();
+ }
+ DataGrid<SmRoleVO> roleVODataGrid = roleQueryService.refGridRoles(queryObject.getConditionMap(),queryObject.getPageHelper());
+ return BaseResult.dataGrid(roleVODataGrid);
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "鏌ヨ瑙掕壊鍒楄〃鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
}
- DataGrid<SmRoleVO> roleVODataGrid = roleQueryService.refGridRoles(queryObject.getConditionMap(),queryObject.getPageHelper());
- return BaseResult.dataGrid(roleVODataGrid);
- //濡傛灉鏄�佺殑椤圭洰锛屽簲璇ュ湪refGridRoles涓婃坊鍔爐ry锛宑atch锛岀劧鍚巆atch閲屽簲璇ヤ娇鐢ㄤ笅闈㈢殑浠g爜
- //BaseResult.fail("杩欓噷杩斿洖鍓嶇鐨勯敊璇俊鎭�");
+ }
+
+ /**
+ * 瑙掕壊鐨勫垪琛ㄦ煡璇細鐢ㄤ簬瑙掕壊绠$悊鍒楄〃绛夋煡璇㈠満鏅細浼氭牴鎹綋鍓嶇櫥褰曠殑鐢ㄦ埛绫诲瀷鏉ュ喅瀹氭煡璇㈤偅浜涜鑹�
+ * @param queryObject 鏌ヨ瀵硅薄锛屽寘鍚簡鏌ヨ鏉′欢锛屽垎椤碉紝鎺掑簭绛�,鍗冲厑璁镐娇鐢⊿mRoleVO閲岀殑鎵�鏈夊睘鎬т綔涓烘煡璇㈡潯浠�
+ * @return 鍖呭惈涓夊憳鐨勮鑹� 鐨勬樉绀哄璞″垪琛ㄦ暟鎹紝璇疯幏鍙栧叾涓殑data灞炴��
+ * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父锛屽鏋滄槸鑰佺殑椤圭洰閲屼笉鎶涘嚭寮傚父
+ */
+ @RequestMapping(value = "/gridRoles",method = RequestMethod.GET)
+ public BaseResult<SmRoleVO> gridRoles(BaseQueryObject queryObject) {
+ try {
+ if(queryObject == null){
+ queryObject = new BaseQueryObject();
+ }
+ //鏍规嵁褰撳墠鐢ㄦ埛鏉ュ喅瀹氳兘鏌ラ偅浜涜鑹�
+ String usertype = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUsertype();
+ if(UserTypeEnum.SUPPER_ADMIN.getValue().equals(usertype)){
+ queryObject.getConditionMap().put("pltype","1");
+ }else {
+ queryObject.getConditionMap().put("pltype","2");
+ }
+ DataGrid<SmRoleVO> roleVOData = roleQueryService.gridRoles(queryObject.getConditionMap(),queryObject.getPageHelper());
+ return BaseResult.dataGrid(roleVOData);
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "鏌ヨ瑙掕壊鍒楄〃鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
}
/**
@@ -61,27 +103,9 @@
return BaseResult.dataList(roleQueryService.listRoleByUserOid(userOid,queryMap));
}catch (Exception e){
e.printStackTrace();
- String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
- log.error("鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇锛屽叧鑱旂殑瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + exceptionMessage);
- return BaseResult.fail("鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇锛屽叧鑱旂殑瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + exceptionMessage);
- }
- }
-
- /**
- * 鍒嗛厤瑙掕壊锛氫繚瀛樼敤鎴疯鑹插叧鑱斿叧绯�
- * @param userOid
- * @param roleIds
- * @return
- */
- @RequestMapping(value = "/saveRights",method = RequestMethod.POST)
- public BaseResult saveRights(String userOid, String[] roleIds){
- try {
- return roleQueryService.saveRights(userOid,roleIds) ? BaseResult.success("瑙掕壊鍒嗛厤鎴愬姛锛�"):BaseResult.fail("瑙掕壊鍒嗛厤澶辫触锛�");
- }catch (Exception e){
- e.printStackTrace();
- String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
- log.error("鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇锛屽叧鑱旂殑瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + exceptionMessage);
- return BaseResult.fail("鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇锛屽叧鑱旂殑瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + exceptionMessage);
+ String exceptionMessage = "鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇锛屽叧鑱旂殑瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
}
}
@@ -99,4 +123,115 @@
//BaseResult.fail("杩欓噷杩斿洖鍓嶇鐨勯敊璇俊鎭�");
}
+ /**
+ * 鏂板鍗曟潯瑙掕壊
+ * @param smRoleDTO
+ * @return
+ */
+ @RequestMapping(value = "/addRole",method = RequestMethod.POST)
+ public BaseResult addRole(@RequestBody SmRoleDTO smRoleDTO){
+ try {
+ return roleQueryService.addRole(smRoleDTO) ? BaseResult.success("瑙掕壊娣诲姞鎴愬姛锛�"):BaseResult.fail("瑙掕壊娣诲姞澶辫触锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "娣诲姞瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
+ }
+
+ /**
+ * 淇敼瑙掕壊
+ * @param smRoleDTO
+ * @return
+ */
+ @RequestMapping(value = "/updateRole",method = RequestMethod.PUT)
+ public BaseResult updateRole(@RequestBody SmRoleDTO smRoleDTO){
+ try {
+ return roleQueryService.updateRole(smRoleDTO) ? BaseResult.success("瑙掕壊淇敼鎴愬姛锛�"):BaseResult.fail("瑙掕壊淇敼澶辫触锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "淇敼瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
+ }
+
+ /**
+ * 鍒犻櫎瑙掕壊
+ * @param ids
+ * @return
+ */
+ @RequestMapping(value = "/deleteRole",method = RequestMethod.DELETE)
+ public BaseResult deleteRole(String[] ids){
+ try {
+ return roleQueryService.deleteRole(ids) ? BaseResult.success("鍒犻櫎鐢ㄦ埛鎴愬姛锛�"):BaseResult.fail("鍒犻櫎鐢ㄦ埛澶辫触锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "娣诲姞鐢ㄦ埛鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
+ }
+
+ /**
+ * 瀵煎叆瑙掕壊
+ * @param file
+ * @return
+ * @throws VciBaseException
+ */
+ @RequestMapping(value = "/importRole",method = RequestMethod.POST)
+ public BaseResult importRole(MultipartFile file){
+ String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
+ File file1 = new File(excelFileName);
+ try {
+ file.transferTo(new File(excelFileName));
+ if (file != null) {
+ return roleQueryService.importRole(file1);
+ } else {
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+ }
+ }catch (Throwable e) {
+ throw new VciBaseException(e.getMessage(),new String[0],e);
+ }finally {
+ file1.delete();
+ }
+ }
+
+ /**
+ * 鎴愬憳绠$悊鍒嗛厤瑙掕壊锛氫繚瀛樼敤鎴疯鑹插叧鑱斿叧绯�
+ * @param userOids
+ * @param roleIds
+ * @return
+ */
+ @RequestMapping(value = "/saveRights",method = RequestMethod.POST)
+ public BaseResult saveRights(String[] userOids, String[] roleIds){
+ try {
+ return roleQueryService.saveRights(userOids,roleIds) ? BaseResult.success("瑙掕壊鍒嗛厤鎴愬姛锛�"):BaseResult.fail("瑙掕壊鍒嗛厤澶辫触锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "鍒嗛厤瑙掕壊鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
+ }
+
+ /**
+ * 瑙掕壊绠$悊鍒嗛厤鎴愬憳锛氫繚瀛樼敤鎴疯鑹插叧鑱斿叧绯�
+ * @param userOids
+ * @param roleId
+ * @return
+ */
+ @RequestMapping(value = "/saveRight",method = RequestMethod.POST)
+ public BaseResult saveRight(String[] userOids, String roleId){
+ try {
+ return roleQueryService.saveRight(userOids,roleId) ? BaseResult.success("鎴愬憳鍒嗛厤鎴愬姛锛�"):BaseResult.fail("鎴愬憳鍒嗛厤澶辫触锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ String exceptionMessage = "鍒嗛厤鐢ㄦ埛鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+ logger.error(exceptionMessage);
+ return BaseResult.fail(exceptionMessage);
+ }
+ }
+
}
--
Gitblit v1.9.3