fjj1.0
parent
ffa1eecd98
commit
8f5712d33e
|
@ -8,8 +8,10 @@ import net.srt.framework.common.page.PageResult;
|
|||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.query.StandardManagementQuery;
|
||||
import net.srt.service.DatastandardService;
|
||||
import net.srt.vo.MetamodelPropertyVO;
|
||||
import net.srt.vo.StandardManagementVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -60,6 +62,23 @@ public class DatastandardController {
|
|||
return Result.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
public Result<String> update(@RequestBody @Valid DatastandardEntity datastandardEntity){
|
||||
datastandardService.update1(datastandardEntity);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
public Result<String> delete(@RequestBody List<Long> idList) {
|
||||
datastandardService.delete(idList);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,15 @@ package net.srt.controller;
|
|||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import net.srt.entity.DatastandardEntity;
|
||||
import net.srt.entity.StandardEntity;
|
||||
import net.srt.framework.common.utils.BeanUtil;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.service.StandardService;
|
||||
import net.srt.vo.StandardManagementVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -44,5 +43,24 @@ public class StandardController {
|
|||
return Result.ok(nodeVo);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
public Result<String > save(@RequestBody StandardEntity standardEntity){
|
||||
standardService.save1(standardEntity);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
public Result<String > update(@RequestBody StandardEntity standardEntity){
|
||||
standardService.update1(standardEntity);
|
||||
return Result.ok();
|
||||
}
|
||||
@DeleteMapping("/id")
|
||||
@Operation(summary = "删除")
|
||||
public Result<String > del(@PathVariable Long id){
|
||||
standardService.del(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,7 @@ public interface DatastandardService extends BaseService<DatastandardEntity> {
|
|||
|
||||
List<DatastandardEntity> getTableCode();
|
||||
|
||||
void update1(DatastandardEntity datastandardEntity);
|
||||
|
||||
void delete(List<Long> idList);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,11 @@ import java.util.List;
|
|||
public interface StandardService extends BaseService<StandardEntity> {
|
||||
|
||||
List<TreeNodeVo> listTree();
|
||||
|
||||
void save1(StandardEntity standardEntity);
|
||||
|
||||
void update1(StandardEntity standardEntity);
|
||||
|
||||
void del(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.convert.DatastandardConvert;
|
||||
import net.srt.convert.MetamodelConvert;
|
||||
import net.srt.dao.DatastandardDao;
|
||||
import net.srt.entity.DatastandardEntity;
|
||||
import net.srt.entity.MetamodelEntity;
|
||||
import net.srt.framework.common.page.PageResult;
|
||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import net.srt.query.StandardManagementQuery;
|
||||
|
@ -39,7 +41,24 @@ public class DatastandardServiceImpl extends BaseServiceImpl<DatastandardDao, Da
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update1(DatastandardEntity datastandardEntity) {
|
||||
StandardManagementVo standardManagementVo=DatastandardConvert.INSTANCE.convert(datastandardEntity);
|
||||
standardManagementVo.setProjectId(getProjectId());
|
||||
updateById(datastandardEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<Long> idList) {
|
||||
removeByIds(idList);
|
||||
//删除
|
||||
for (Long id : idList) {
|
||||
LambdaQueryWrapper<DatastandardEntity> wrapper=Wrappers.lambdaQuery();
|
||||
wrapper.eq(DatastandardEntity::getCategoryId,id);
|
||||
datastandardDao.delete(wrapper);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private LambdaQueryWrapper<DatastandardEntity> getWrapper(StandardManagementQuery query) {
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static net.srt.framework.security.user.SecurityUser.getUserId;
|
||||
|
||||
/**
|
||||
* @ClassName : StandardServiceImpl
|
||||
* @Description :
|
||||
|
@ -40,5 +42,45 @@ public class StandardServiceImpl extends BaseServiceImpl<StandardDao, StandardEn
|
|||
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save1(StandardEntity standardEntity) {
|
||||
if (standardEntity.getId() == null) {
|
||||
standardEntity.setCreateTime(new java.util.Date());
|
||||
standardEntity.setUpdateTime(new java.util.Date());
|
||||
standardEntity.setDeleted(0);
|
||||
standardEntity.setVersion(0);
|
||||
standardEntity.setCreator(getUserId());
|
||||
standardEntity.setUpdater(getUserId());
|
||||
baseMapper.insert(standardEntity);
|
||||
} else {
|
||||
standardEntity.setUpdateTime(new java.util.Date());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update1(StandardEntity standardEntity) {
|
||||
if (standardEntity.getId()!= null) {
|
||||
standardEntity.setUpdateTime(new java.util.Date());
|
||||
standardEntity.setUpdater(getUserId());
|
||||
baseMapper.updateById(standardEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(Long id) {
|
||||
//判断是否有子节点
|
||||
LambdaQueryWrapper<StandardEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(StandardEntity::getParentId,id).last("limit 1");
|
||||
if(baseMapper.selectCount(wrapper)!=null){
|
||||
throw new RuntimeException("请先删除子节点");
|
||||
}
|
||||
removeById(id);
|
||||
//删除属性
|
||||
LambdaQueryWrapper<StandardEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(StandardEntity::getParentId,id);
|
||||
baseMapper.delete(wrapper1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class StandardManagementVo implements Serializable {
|
|||
private Integer standardCodeId;
|
||||
private Integer type;
|
||||
private String note;
|
||||
private Integer projectId;
|
||||
private Long projectId;
|
||||
private Integer status;
|
||||
private Integer version;
|
||||
private Integer deleted;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package net.srt;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @ClassName : ${NAME}
|
||||
* @Description : ${description}
|
||||
* @Author : FJJ
|
||||
* @Date: 2023-12-22 20:44
|
||||
*/
|
||||
@EnableFeignClients
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
public class ServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceApplication.class, args);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue