Browse Source

修改入库失败问题

master
lihua 5 years ago
parent
commit
4cf88a9338
  1. 7
      src/main/java/cn/redrock/assetmanage/controller/MaterialController.java
  2. 7
      src/main/java/cn/redrock/assetmanage/controller/StaffAssetController.java
  3. 2
      src/main/java/cn/redrock/assetmanage/mapper/AmStaffAssetMapper.java
  4. 2
      src/main/java/cn/redrock/assetmanage/service/StaffAssetService.java
  5. 5
      src/main/java/cn/redrock/assetmanage/service/impl/MaterialServiceImpl.java
  6. 4
      src/main/java/cn/redrock/assetmanage/service/impl/StaffAssetServiceImpl.java

7
src/main/java/cn/redrock/assetmanage/controller/MaterialController.java

@ -93,12 +93,17 @@ public class MaterialController {
if(list == null || list.isEmpty()){
return Result.error(ResponseCode.EXCEL_PARSE_ERROR);
}
boolean ret;
boolean ret = false;
try {
if(isOverride != null && isOverride){
ret = materialService.batchAdd(list,true);
}else{
ret = materialService.batchAdd(list,false);
}
}catch (RuntimeException e){
e.printStackTrace();
}
if(!ret){
materialLogService.batchWriteLog(buildBatchLog(user.getId(),Constants.Operate.IN, Constants.Status.FAILED,list,getBatch(file)));
return Result.error(ResponseCode.ASSET_BATCH_ADD_FAIL);

7
src/main/java/cn/redrock/assetmanage/controller/StaffAssetController.java

@ -41,10 +41,9 @@ public class StaffAssetController {
return Result.ok();
}
@PostMapping("/edit")
public Result editAsset(@CurrentUser AmUser user,@Valid @RequestBody Asset asset) {
asset.setUserId(user.getId());
if(!staffAssetService.update(asset)){
@PostMapping("/edit/{id}")
public Result editAsset(@PathVariable("id") Integer id,@Valid @RequestBody Asset asset) {
if(!staffAssetService.update(id,asset)){
return Result.error(ResponseCode.ASSET_NO_EXISTED);
}
return Result.ok();

2
src/main/java/cn/redrock/assetmanage/mapper/AmStaffAssetMapper.java

@ -13,4 +13,6 @@ public interface AmStaffAssetMapper extends Mapper<AmStaffAsset> {
@Select(value = "select a.*,b.nickname user_name from am_staff_asset a,am_user b where a.user_id=#{userId} and a.name=#{name} and a.user_id=b.id")
AmStaffAsset find(@Param("userId") Integer userId, @Param("name") String name);
@Select(value = "select * from am_staff_asset where id=#{id}")
AmStaffAsset findById(Integer id);
}

2
src/main/java/cn/redrock/assetmanage/service/StaffAssetService.java

@ -15,6 +15,6 @@ import java.util.List;
public interface StaffAssetService {
boolean add(Asset asset);
List<AmStaffAsset> search(Integer userId,String field, String content, Integer pageNum, Integer pageSize);
boolean update(Asset asset);
boolean update(Integer id,Asset asset);
boolean delete(Integer id);
}

5
src/main/java/cn/redrock/assetmanage/service/impl/MaterialServiceImpl.java

@ -75,6 +75,7 @@ public class MaterialServiceImpl implements MaterialService {
log.info("update add material success from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}else{
log.error("update add material failed from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
throw new RuntimeException("update add material failed");
}
}else{
BeanUtils.copyProperties(material,newMaterial);
@ -83,10 +84,12 @@ public class MaterialServiceImpl implements MaterialService {
log.info("add material success {}", JSON.toJSONString(newMaterial));
}else{
log.error("add material failed {}", JSON.toJSONString(newMaterial));
throw new RuntimeException("add material failed");
}
}
}else{
return false;
log.error("add material failed {}", JSON.toJSONString(material));
throw new RuntimeException("add material failed");
}
}
return true;

4
src/main/java/cn/redrock/assetmanage/service/impl/StaffAssetServiceImpl.java

@ -55,8 +55,8 @@ public class StaffAssetServiceImpl implements StaffAssetService {
}
@Override
public boolean update(Asset asset) {
AmStaffAsset staffAsset = staffAssetMapper.find(asset.getUserId(),asset.getName());
public boolean update(Integer id,Asset asset) {
AmStaffAsset staffAsset = staffAssetMapper.findById(id);
if(staffAsset == null){
log.info("public asset {} not exists",asset.getName());
return false;

Loading…
Cancel
Save