/*
|
* 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.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
import com.vci.ubcs.code.entity.CodeButtonEntity;
|
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.CodeButtonVO;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* 模板扩展池 服务实现类
|
*
|
* @author yuxc
|
* @since 2023-03-29
|
*/
|
@Service
|
public class CodeButtonServiceImpl implements ICodeButtonService {
|
|
@Autowired
|
CodeButtonMapper codeButtonMapper;
|
|
@Override
|
public IPage<CodeButtonVO> selectcodebuttonPage(IPage<CodeButtonVO> page, CodeButtonVO codebutton) {
|
return page.setRecords(codeButtonMapper.selectcodebuttonPage(page, codebutton));
|
}
|
|
@Override
|
public R enableCodeButton(String id) {
|
CodeButtonEntity codebutton = codeButtonMapper.selectById(id);
|
return changeLcStatus(codebutton,true);
|
}
|
/**
|
* 停用
|
*
|
* @param oid 数据传输对象
|
* @return 执行结果
|
*/
|
@Override
|
public R disableOrgDuty(String oid) {
|
CodeButtonEntity codebutton = codeButtonMapper.selectById(oid);
|
return changeLcStatus(codebutton,false);
|
}
|
|
// @Override
|
// public R deleteCodeButton(String ids) {
|
//// VciBaseUtil.alertNotNull(codeButtonDTO,"主数据中的按钮扩展数据对象",codeButtonDTO.getOid(),"主数据中的按钮扩展的主键");
|
// if(StringUtils.isEmpty(ids)){
|
// return R.fail("传入非法数据!");
|
// }
|
// CodeButtonEntity codebutton = codeButtonMapper.selectById(ids);
|
//
|
// 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 buttonDTO 数据传输对象,必须要有oid和ts
|
* @param disable 是否为停用
|
* @return 执行的结果
|
*/
|
private R changeLcStatus(CodeButtonEntity 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());
|
}
|
|
// /**
|
// * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除
|
// * @param codeButtonDTO 数据传输对象
|
// * @param codeButtonDO 数据库中的数据对象
|
// * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级
|
// */
|
// 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[]{""});
|
// }
|
// }
|
|
}
|