From 4470052c3b6bdeb18e45987f8aa293d1e93d0552 Mon Sep 17 00:00:00 2001
From: Ludc <2870569285@qq.com>
Date: 星期二, 18 十一月 2025 11:59:12 +0800
Subject: [PATCH] 所有文件上传接口增加文件安全校验逻辑。
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java | 645 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 348 insertions(+), 297 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
index 401e4a7..8fba98f 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeButtonServiceImpl.java
@@ -1,324 +1,375 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 搴勯獮 (smallchill@163.com)
+ */
package com.vci.ubcs.code.service.impl;
-import com.vci.ubcs.code.entity.CodeButtonDO;
-import com.vci.ubcs.code.mapper.CodeButtonMapper;
-import com.vci.ubcs.code.service.CodeButtonServiceI;
-import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus;
-import com.vci.starter.revision.service.RevisionModelUtil;
-import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.pagemodel.BaseResult;
-import com.vci.starter.web.pagemodel.DataGrid;
-import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.util.BeanUtil;
-import com.vci.starter.web.util.BeanUtilForVCI;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.web.pageModel.BatchCBO;
-import com.vci.web.service.WebBoServiceI;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
+
import com.vci.ubcs.code.dto.CodeButtonDTO;
+import com.vci.ubcs.code.dto.CodeFixedValueDTO;
+import com.vci.ubcs.code.entity.CodeButton;
+import com.vci.ubcs.code.entity.CodeFixedValue;
+import com.vci.ubcs.code.enumpack.CodeUseButtonPositionTypeEnum;
+import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus;
+import com.vci.ubcs.code.mapper.CodeButtonMapper;
+import com.vci.ubcs.code.service.ICodeButtonService;
import com.vci.ubcs.code.vo.pagemodel.CodeButtonVO;
+import com.vci.ubcs.common.utils.PageDO2PageVO;
+import com.vci.ubcs.starter.exception.VciBaseException;
+import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
+import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
+import com.vci.ubcs.starter.util.MdmBtmTypeConstant;
+import com.vci.ubcs.starter.web.pagemodel.DataGrid;
+import com.vci.ubcs.starter.web.pagemodel.PageHelper;
+import com.vci.ubcs.starter.web.util.BeanUtil;
+import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
+import com.vci.ubcs.starter.web.util.VciBaseUtil;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
+import org.springframework.cglib.beans.BeanMap;
+import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
-import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*;
+import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*;
/**
- * 涓绘暟鎹腑鐨勬寜閽墿灞曟湇鍔�
- * @author weidy
- * @date 2022-01-24
+ * 妯℃澘鎵╁睍姹� 鏈嶅姟瀹炵幇绫�
+ *
+ * @author yuxc
+ * @since 2023-03-29
*/
@Service
-public class CodeButtonServiceImpl implements CodeButtonServiceI {
+public class CodeButtonServiceImpl implements ICodeButtonService {
- /**
- * 鏃ュ織
- */
- private Logger logger = LoggerFactory.getLogger(getClass());
+ @Resource
+ private CodeButtonMapper codeButtonMapper;
- /**
- * 鏁版嵁鎿嶄綔灞�
- */
- @Resource
- private CodeButtonMapper codeButtonMapper;
+ /**
+ * 瀵硅薄鐨勬搷浣�
+ */
+ @Autowired
+ private RevisionModelUtil revisionModelUtil;
- /**
- * 涓氬姟绫诲瀷鎿嶄綔鐨勬湇鍔�
- */
- @Autowired
- @Lazy
- private WebBoServiceI boService;
+ @Override
+ public IPage<CodeButtonVO> selectcodebuttonPage(IPage<CodeButtonVO> page, CodeButtonVO codebutton) {
+ return page.setRecords(codeButtonMapper.selectcodebuttonPage(page, codebutton));
+ }
- /**
- * 瀵硅薄鐨勬搷浣�
- */
- @Autowired
- private RevisionModelUtil revisionModelUtil;
+ /**
+ * 鏌ヨ鎵�鏈夌殑涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param pageHelper 鍒嗛〉鍜屾帓搴�
+ * @return 鎵ц缁撴灉
+ * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public IPage<CodeButtonVO> gridCodeButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
+ Query query = new Query();
+ if (pageHelper == null) {
+ query.setSize(-1);
+ }else {
+ query.setSize(pageHelper.getLimit());
+ query.setCurrent(pageHelper.getPage());
+ }
+ query.setDescs("createTime");
+ CodeButton codeButton = new CodeButton();
+ BeanMap beanMap = BeanMap.create(codeButton);
+ beanMap.putAll(conditionMap);
+ IPage<CodeButton> doList = codeButtonMapper.selectPage(Condition.getPage(query),Condition.getQueryWrapper(codeButton));
+ IPage<CodeButtonVO> voList = new Page<>();
+ if (!CollectionUtils.isEmpty(doList.getRecords())) {
+ voList.setRecords(codeButtonDO2VOs(doList.getRecords()));
+ PageDO2PageVO.pageDO2PageVO(doList,voList);
+ }
+ return voList;
+ }
+ /**
+ * 澧炲姞涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞�
+ * @return 鎵ц缁撴灉
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeButtonVO addSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{
+ VciBaseUtil.alertNotNull(codeButtonDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
+ //灏咲TO杞崲涓篋O
+ CodeButton codeButtonDO = new CodeButton();
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDTO,codeButtonDO);
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeButtonDO, MdmBtmTypeConstant.CODE_BUTTON);
+ boolean resInsertCodeButton = codeButtonMapper.insert(codeButtonDO) > 0;
+ return resInsertCodeButton ? codeButtonDO2VO(codeButtonDO):null;
+ }
- /**
- * 鏌ヨ鎵�鏈夌殑涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param conditionMap 鏌ヨ鏉′欢
- * @param pageHelper 鍒嗛〉鍜屾帓搴�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public DataGrid<CodeButtonVO> gridCodeButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
- if (pageHelper == null) {
- pageHelper = new PageHelper(-1);
- }
- pageHelper.addDefaultDesc("createTime");
- List<CodeButtonDO> doList = codeButtonMapper.selectByCondition(conditionMap,pageHelper);
- DataGrid<CodeButtonVO> dataGrid=new DataGrid<CodeButtonVO>();
- if (!CollectionUtils.isEmpty(doList)) {
- dataGrid.setData(codeButtonDO2VOs(doList));
- dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeButtonMapper.countByCondition(conditionMap))));
- }
- return dataGrid;
+ /**
+ * 淇敼涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞�
+ * @return 鎵ц缁撴灉
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeButtonVO editSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{
+ VciBaseUtil.alertNotNull(codeButtonDTO,"鏁版嵁瀵硅薄",codeButtonDTO.getOid(),"涓绘暟鎹腑鐨勬寜閽墿灞曚富閿�");
+ //灏咲TO杞崲涓篋O
+ CodeButton codeButtonDO = selectByOid(codeButtonDTO.getOid());
+ revisionModelUtil.copyFromDTOIgnore(codeButtonDTO,codeButtonDO);
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeButtonDO);
+ boolean resUpdateCodeButton = codeButtonMapper.updateById(codeButtonDO) > 0;
+ return resUpdateCodeButton ? codeButtonDO2VO(codeButtonDO):null;
+ }
+
+ /**
+ * 鍒犻櫎涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
+ * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
+ * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
+ */
+ @Override
+ public R deleteCodeButton(CodeButtonDTO codeButtonDTO) throws VciBaseException{
+ VciBaseUtil.alertNotNull(codeButtonDTO,"涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹璞�",codeButtonDTO.getOid(),"涓绘暟鎹腑鐨勬寜閽墿灞曠殑涓婚敭");
+ CodeButton codeButtonDO = selectByOid(codeButtonDTO.getOid());
+ R baseResult = checkIsCanDeleteForDO(codeButtonDTO,codeButtonDO);
+ if(baseResult.isSuccess()) {
+ }else{
+ return baseResult;
+ }
+ //鎵ц鍒犻櫎鎿嶄綔
+ boolean resDeleteCodeButton = codeButtonMapper.deleteById(codeButtonDO.getOid()) > 0;
+ return resDeleteCodeButton ? R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL);
+ }
+
+ /**
+ * 涓婚敭鑾峰彇涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param oid 涓婚敭
+ * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞�
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeButtonVO getObjectByOid(String oid) throws VciBaseException{
+ return codeButtonDO2VO(selectByOid(oid));
+ }
+
+ /**
+ * 鍙傜収涓绘暟鎹腑鐨勬寜閽墿灞曞垪琛�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param pageHelper 鍒嗛〉鍜屾帓搴�
+ * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹�
+ * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public IPage<CodeButtonVO> refDataGridCodeButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
+ if(conditionMap == null){
+ conditionMap = new HashMap<String, String>();
+ }
+ return gridCodeButton(conditionMap,pageHelper);
+ }
+
+ /**
+ * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
+ * @param codeButtonDTO 鏁版嵁浼犺緭瀵硅薄
+ * @param codeButtonDO 鏁版嵁搴撲腑鐨勬暟鎹璞�
+ * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
+ */
+ private R checkIsCanDeleteForDO(CodeButtonDTO codeButtonDTO, CodeButton codeButtonDO) {
+ CodeButton buttonDO = new CodeButton();
+ BeanUtil.convert(codeButtonDTO,buttonDO);
+ if (!checkTs(codeButtonDTO,buttonDO)) {
+ return R.fail(TS_NOT_PROCESS);
+ }
+ if(!checkIsLinked(codeButtonDO.getOid())) {
+ return R.success("success");
+ }else{
+ return R.fail(DATA_LINKED_NOT_DELETE);
+ }
+ }
+
+ /**
+ * 妫�鏌s
+ * @param tempDO
+ * @return
+ */
+ private boolean checkTs(CodeButtonDTO tempDO, CodeButton codeButton){
+ Date dbTs = codeButton.getTs();
+ Date currentTs = tempDO.getTs();
+ if(currentTs == null ? dbTs == null:currentTs.compareTo(dbTs)==0){
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 鏍¢獙鏄惁琚紩鐢�
+ * @param oid 涓婚敭
+ * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ private boolean checkIsLinked(String oid) throws VciBaseException{
+ //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟
+ return false;
+ }
+
+ /**
+ * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
+ * @param oid 涓婚敭
+ * @return 鏁版嵁瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ private CodeButton selectByOid(String oid) throws VciBaseException{
+ VciBaseUtil.alertNotNull(oid,"涓婚敭");
+ CodeButton codeButtonDO = codeButtonMapper.selectById(oid.trim());
+ if(codeButtonDO == null || StringUtils.isBlank(codeButtonDO.getOid())){
+ throw new VciBaseException(DATA_OID_NOT_EXIST);
+ }
+ return codeButtonDO;
+ }
+
+ /**
+ * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹腑鐨勬寜閽墿灞�
+ * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
+ * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞�
+ * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
+ */
+ @Override
+ public Collection<CodeButtonVO> listCodeButtonByOids(Collection<String> oidCollections) throws VciBaseException {
+ VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎");
+ List<CodeButton> codeButtonDOList = listCodeButtonDOByOidCollections(oidCollections);
+ return codeButtonDO2VOs(codeButtonDOList);
+ }
+
+ /**
+ * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ * @param codeButtonDOs 鏁版嵁瀵硅薄鍒楄〃
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<CodeButtonVO> codeButtonDO2VOs(Collection<CodeButton> codeButtonDOs) throws VciBaseException{
+ List<CodeButtonVO> voList = new ArrayList<CodeButtonVO>();
+ if(!CollectionUtils.isEmpty(codeButtonDOs)){
+ for(CodeButton s: codeButtonDOs){
+ CodeButtonVO vo = codeButtonDO2VO(s);
+ if(vo != null){
+ voList.add(vo);
+ }
+ }
+ }
+ return voList;
+ }
+
+ /**
+ * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ * @param codeButtonDO 鏁版嵁瀵硅薄
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeButtonVO codeButtonDO2VO(CodeButton codeButtonDO) throws VciBaseException{
+ CodeButtonVO vo = new CodeButtonVO();
+ if(codeButtonDO != null){
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDO,vo);
+ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+ vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()));
+ vo.setUsedpositiontypeText(CodeUseButtonPositionTypeEnum.getTextByValue(codeButtonDO.getUsedPositionType()));
+ }
+ return vo;
+ }
+
+ @Override
+ public List<CodeButton> selectByPrimaryKeyCollection(Collection<String> oids) {
+ VciBaseUtil.alertNotNull(oids,"涓婚敭闆嗗悎");
+ return codeButtonMapper.selectBatchIds(oids);
+ }
+
+ /**
+ * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
+ * @param oidCollections 涓婚敭鐨勯泦鍚�
+ * @return 鏁版嵁瀵硅薄鍒楄〃
+ */
+ private List<CodeButton> listCodeButtonDOByOidCollections(Collection<String> oidCollections){
+ List<CodeButton> codeButtonDOList = new ArrayList<CodeButton>();
+ if(!CollectionUtils.isEmpty(oidCollections)){
+ Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
+ for(Collection<String> oids: oidCollectionsList){
+ List<CodeButton> tempDOList = codeButtonMapper.selectBatchIds(oids);
+ if(!CollectionUtils.isEmpty(tempDOList)){
+ codeButtonDOList.addAll(tempDOList);
+ }
+ }
+ }
+ return codeButtonDOList;
+ }
+
+ @Override
+ public R enableCodeButton(String id) {
+ CodeButton codebutton = codeButtonMapper.selectById(id);
+ return changeLcStatus(codebutton,true);
}
- /**
- * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
- * @param codeButtonDOs 鏁版嵁瀵硅薄鍒楄〃
- * @return 鏄剧ず瀵硅薄
- * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
- */
- @Override
- public List<CodeButtonVO> codeButtonDO2VOs(Collection<CodeButtonDO> codeButtonDOs) throws VciBaseException{
- List<CodeButtonVO> voList = new ArrayList<CodeButtonVO>();
- if(!CollectionUtils.isEmpty(codeButtonDOs)){
- for(CodeButtonDO s: codeButtonDOs){
- CodeButtonVO vo = codeButtonDO2VO(s);
- if(vo != null){
- voList.add(vo);
- }
- }
- }
- return voList;
- }
+ /**
+ * 鍋滅敤
+ *
+ * @param oid 鏁版嵁浼犺緭瀵硅薄
+ * @return 鎵ц缁撴灉
+ */
+ @Override
+ public R disableOrgDuty(String oid) {
+ CodeButton codebutton = codeButtonMapper.selectById(oid);
+ return changeLcStatus(codebutton,false);
+ }
- /**
- * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
- * @param codeButtonDO 鏁版嵁瀵硅薄
- * @return 鏄剧ず瀵硅薄
- * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public CodeButtonVO codeButtonDO2VO(CodeButtonDO codeButtonDO) throws VciBaseException{
- CodeButtonVO vo = new CodeButtonVO();
- if(codeButtonDO != null){
- BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDO,vo);
- //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
- vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()));
+ /**
+ * 淇敼鐢熷懡鍛ㄦ湡鐨勭姸鎬侊紝濡傚仠鐢ㄥ拰鍚敤
+ * @param buttonDTO 鏁版嵁浼犺緭瀵硅薄锛屽繀椤昏鏈塷id鍜宼s
+ * @param disable 鏄惁涓哄仠鐢�
+ * @return 鎵ц鐨勭粨鏋�
+ */
+ private R changeLcStatus(CodeButton buttonDTO, boolean disable){
+ // VciBaseUtil.alertNotNull(buttonDTO,"鏁版嵁瀵硅薄",buttonDTO.getOid(),"涓婚敭");
+ if(disable){
+ buttonDTO.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue());
+ }else{
+ buttonDTO.setLcStatus(FrameworkDataLCStatus.DISABLED.getValue());
+ }
+ return SqlHelper.retBool(codeButtonMapper.updateById(buttonDTO))?
+ R.success(FrameworkDataLCStatus.ENABLED.getValue()):R.fail(FrameworkDataLCStatus.DISABLED.getValue());
+ }
- }
- return vo;
- }
+ // /**
+// * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
+// * @param codeButtonDTO 鏁版嵁浼犺緭瀵硅薄
+// * @param codeButtonDO 鏁版嵁搴撲腑鐨勬暟鎹璞�
+// * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
+// */
+// private R checkIsCanDeleteForDO(CodeButtonEntity codeButtonDTO, CodeButtonVO codeButtonDO) {
+// CodeButtonVO buttonDO = new CodeButtonVO();
+// BeanUtil.convert(codeButtonDTO,buttonDO);
+// boService.checkTs(buttonDO);
+// if(!checkIsLinked(codeButtonDO.getOid())) {
+// return BaseResult.success();
+// }else{
+// return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""});
+// }
+// }
- /**
- * 澧炲姞涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodeButtonVO addSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codeButtonDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
- //灏咲TO杞崲涓篋O
- CodeButtonDO codeButtonDO = new CodeButtonDO();
- BeanUtilForVCI.copyPropertiesIgnoreCase(codeButtonDTO,codeButtonDO);
- codeButtonMapper.insert(codeButtonDO);
- return codeButtonDO2VO(codeButtonDO);
- }
-
- /**
- * 淇敼涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞�
- * @return 鎵ц缁撴灉
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodeButtonVO editSave(CodeButtonDTO codeButtonDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codeButtonDTO,"鏁版嵁瀵硅薄",codeButtonDTO.getOid(),"涓绘暟鎹腑鐨勬寜閽墿灞曚富閿�");
- //灏咲TO杞崲涓篋O
- CodeButtonDO codeButtonDO = selectByOid(codeButtonDTO.getOid());
- revisionModelUtil.copyFromDTOIgnore(codeButtonDTO,codeButtonDO);
- codeButtonMapper.updateByPrimaryKey(codeButtonDO);
- return codeButtonDO2VO(codeButtonDO);
- }
-
-
- /**
- * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
- * @param codeButtonDTO 鏁版嵁浼犺緭瀵硅薄
- * @param codeButtonDO 鏁版嵁搴撲腑鐨勬暟鎹璞�
- * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
- */
- private BaseResult checkIsCanDeleteForDO(CodeButtonDTO codeButtonDTO, CodeButtonDO codeButtonDO) {
- CodeButtonDO buttonDO = new CodeButtonDO();
- BeanUtil.convert(codeButtonDTO,buttonDO);
- boService.checkTs(buttonDO);
- if(!checkIsLinked(codeButtonDO.getOid())) {
- return BaseResult.success();
- }else{
- return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""});
- }
- }
-
- /**
- * 鏍¢獙鏄惁琚紩鐢�
- * @param oid 涓婚敭
- * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父
- */
- private boolean checkIsLinked(String oid) throws VciBaseException{
- //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟
- return false;
- }
-
-
-
- /**
- * 鍒犻櫎涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param codeButtonDTO 涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
- * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
- * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
- */
- @Override
- public BaseResult deleteCodeButton(CodeButtonDTO codeButtonDTO) throws VciBaseException{
- VciBaseUtil.alertNotNull(codeButtonDTO,"涓绘暟鎹腑鐨勬寜閽墿灞曟暟鎹璞�",codeButtonDTO.getOid(),"涓绘暟鎹腑鐨勬寜閽墿灞曠殑涓婚敭");
- CodeButtonDO codeButtonDO = selectByOid(codeButtonDTO.getOid());
- BaseResult baseResult = checkIsCanDeleteForDO(codeButtonDTO,codeButtonDO);
- if(baseResult.isSuccess()) {
- }else{
- return baseResult;
- }
- //鎵ц鍒犻櫎鎿嶄綔
- BatchCBO batchCBO = codeButtonMapper.deleteByPrimaryKey(codeButtonDO.getOid());
- return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.fail(DELETE_FAIL);
- }
-
- /**
- * 涓婚敭鑾峰彇涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param oid 涓婚敭
- * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞�
- * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
- */
- @Override
- public CodeButtonVO getObjectByOid(String oid) throws VciBaseException{
- return codeButtonDO2VO(selectByOid(oid));
- }
-
- /**
- * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
- * @param oid 涓婚敭
- * @return 鏁版嵁瀵硅薄
- * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
- */
- private CodeButtonDO selectByOid(String oid) throws VciBaseException{
- VciBaseUtil.alertNotNull(oid,"涓婚敭");
- CodeButtonDO codeButtonDO = codeButtonMapper.selectByPrimaryKey(oid.trim());
- if(codeButtonDO == null || StringUtils.isBlank(codeButtonDO.getOid())){
- throw new VciBaseException(DATA_OID_NOT_EXIST);
- }
- return codeButtonDO;
- }
-
- /**
- * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹腑鐨勬寜閽墿灞�
- * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
- * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞�
- * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
- */
- @Override
- public Collection<CodeButtonVO> listCodeButtonByOids(Collection<String> oidCollections) throws VciBaseException{
- VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎");
- List<CodeButtonDO> codeButtonDOList = listCodeButtonDOByOidCollections(oidCollections);
- return codeButtonDO2VOs(codeButtonDOList);
- }
-
- /**
- * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
- * @param oidCollections 涓婚敭鐨勯泦鍚�
- * @return 鏁版嵁瀵硅薄鍒楄〃
- */
- private List<CodeButtonDO> listCodeButtonDOByOidCollections(Collection<String> oidCollections){
- List<CodeButtonDO> codeButtonDOList = new ArrayList<CodeButtonDO>();
- if(!CollectionUtils.isEmpty(oidCollections)){
- Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
- for(Collection<String> oids: oidCollectionsList){
- List<CodeButtonDO> tempDOList = codeButtonMapper.selectByPrimaryKeyCollection(oids);
- if(!CollectionUtils.isEmpty(tempDOList)){
- codeButtonDOList.addAll(tempDOList);
- }
- }
- }
- return codeButtonDOList;
- }
-
-
-
- /**
- * 鍙傜収涓绘暟鎹腑鐨勬寜閽墿灞曞垪琛�
- * @param conditionMap 鏌ヨ鏉′欢
- * @param pageHelper 鍒嗛〉鍜屾帓搴�
- * @return 涓绘暟鎹腑鐨勬寜閽墿灞曟樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹�
- * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
- */
- @Override
- public DataGrid<CodeButtonVO> refDataGridCodeButton(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
- if(conditionMap == null){
- conditionMap = new HashMap<String, String>();
- }
- return gridCodeButton(conditionMap,pageHelper);
- }
-
- /**
- * 鍚敤
- *
- * @param buttonDTO 鏁版嵁浼犺緭瀵硅薄
- * @return 鎵ц缁撴灉
- */
- @Override
- public BaseResult enableCodeButton(CodeButtonDTO buttonDTO) {
- return changeLcStatus(buttonDTO,false);
- }
-
- /**
- * 鍋滅敤
- *
- * @param buttonDTO 鏁版嵁浼犺緭瀵硅薄
- * @return 鎵ц缁撴灉
- */
- @Override
- public BaseResult disableCodeButton(CodeButtonDTO buttonDTO) {
- return changeLcStatus(buttonDTO,true);
- }
-
- /**
- * 淇敼鐢熷懡鍛ㄦ湡鐨勭姸鎬侊紝濡傚仠鐢ㄥ拰鍚敤
- * @param buttonDTO 鏁版嵁浼犺緭瀵硅薄锛屽繀椤昏鏈塷id鍜宼s
- * @param disable 鏄惁涓哄仠鐢�
- * @return 鎵ц鐨勭粨鏋�
- */
- private BaseResult changeLcStatus(CodeButtonDTO buttonDTO, boolean disable){
- VciBaseUtil.alertNotNull(buttonDTO,"鏁版嵁瀵硅薄",buttonDTO.getOid(),"涓婚敭");
- CodeButtonDO buttonDO = selectByOid(buttonDTO.getOid());
- CodeButtonDO outButtonDO = new CodeButtonDO();
- BeanUtil.convert(buttonDTO,outButtonDO);
- boService.checkTs(outButtonDO);
- if(disable){
- buttonDO.setLcStatus(FrameworkDataLCStatus.DISABLED.getValue());
- }else{
- buttonDO.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue());
- }
- return (codeButtonMapper.updateLcStatus(buttonDO.getOid(),buttonDO.getLcStatus()) >0 )?(BaseResult.successMsg((disable?DISABLE_SUCCESS:ENABLE_SUCCESS))):(BaseResult.fail((disable?DISABLE_FAIL:ENABLE_FAIL)));
- }
}
-
--
Gitblit v1.9.3