Browse Source

修改删除bug,及其他bug

master
lihua 5 years ago
parent
commit
8456d406cb
  1. 2
      src/main/java/cn/redrock/assetmanage/common/Constants.java
  2. 6
      src/main/java/cn/redrock/assetmanage/controller/MaterialController.java
  3. 6
      src/main/java/cn/redrock/assetmanage/controller/PublicAssetController.java
  4. 1
      src/main/java/cn/redrock/assetmanage/controller/UserController.java
  5. 4
      src/main/java/cn/redrock/assetmanage/dto/Material.java
  6. 2
      src/main/java/cn/redrock/assetmanage/service/MaterialService.java
  7. 2
      src/main/java/cn/redrock/assetmanage/service/PublicAssetService.java
  8. 23
      src/main/java/cn/redrock/assetmanage/service/impl/MaterialServiceImpl.java
  9. 4
      src/main/java/cn/redrock/assetmanage/service/impl/PublicAssetServiceImpl.java
  10. 10
      src/main/java/cn/redrock/assetmanage/service/impl/TokenServiceImpl.java
  11. 7
      src/main/java/cn/redrock/assetmanage/service/impl/UserServiceImpl.java
  12. 4
      src/main/java/cn/redrock/assetmanage/utils/ExcelUtils.java

2
src/main/java/cn/redrock/assetmanage/common/Constants.java

@ -13,7 +13,7 @@ public class Constants {
public static enum Status {
FAILED(-1),
NO_AUDIT(0),
SUCCESS(2);
SUCCESS(1);
@Getter
private Integer status;

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

@ -163,9 +163,9 @@ public class MaterialController {
}
@Admin
@DeleteMapping("/delete/{code}")
public Result deleteMaterial(@PathVariable("code") String code) {
if(!materialService.delete(code)){
@DeleteMapping("/delete/{id}")
public Result deleteMaterial(@PathVariable("id") Integer id) {
if(!materialService.delete(id)){
return Result.error(ResponseCode.ASSET_NO_EXISTED);
}
return Result.ok();

6
src/main/java/cn/redrock/assetmanage/controller/PublicAssetController.java

@ -45,9 +45,9 @@ public class PublicAssetController {
return Result.ok();
}
@DeleteMapping("/delete/{code}")
public Result deleteAsset(@PathVariable("code") String code) {
if(!publicAssetService.delete(code)){
@DeleteMapping("/delete/{id}")
public Result deleteAsset(@PathVariable("id") Integer id) {
if(!publicAssetService.delete(id)){
return Result.error(ResponseCode.ASSET_NO_EXISTED);
}
return Result.ok();

1
src/main/java/cn/redrock/assetmanage/controller/UserController.java

@ -101,6 +101,7 @@ public class UserController {
public Result edit(@CurrentUser AmUser user,Integer userId, @RequestBody UserInfo userInfo) {
if(userId == null){
userId = user.getId();
userInfo.setIsAdmin(user.getIsAdmin());
}
if(!userService.editUser(userId,userInfo)){
return Result.error(ResponseCode.USER_EXISTED);

4
src/main/java/cn/redrock/assetmanage/dto/Material.java

@ -16,12 +16,12 @@ import javax.validation.constraints.NotNull;
@Data
public class Material {
private Integer id;
@ExcelColumn(value = "物料编号", col = 1)
@ExcelColumn(value = "物料编号", col = 1)
@NotBlank
private String code;
@ExcelColumn(value = "数量", col = 2)
@ExcelColumn(value = "数量", col = 2)
@NotNull
private Integer num;

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

@ -20,6 +20,6 @@ public interface MaterialService {
void batchSub(List<Material> materials,List<Material> successMaterials,List<Material> failMaterials);
List<AmMaterial> search(String field, String content, Integer pageNum, Integer pageSize);
boolean update(Material material);
boolean delete(String code);
boolean delete(Integer id);
PageInfo<AmMaterial> warn(Integer pageNum, Integer pageSize);
}

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

@ -16,5 +16,5 @@ public interface PublicAssetService {
boolean add(PublicAsset publicAsset);
List<AmPublicAsset> search(String field, String content, Integer pageNum, Integer pageSize);
boolean update(PublicAsset publicAsset);
boolean delete(String code);
boolean delete(Integer id);
}

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

@ -70,7 +70,7 @@ public class MaterialServiceImpl implements MaterialService {
newMaterial.setCode(material.getCode());
newMaterial.setNum(num + material.getNum());
}
newMaterial.setUpdateTime(new Date());
newMaterial.setId(oldMaterial.getId());
if(materialMapper.updateByPrimaryKeySelective(newMaterial) > 0){
log.info("update add material success from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}else{
@ -133,23 +133,12 @@ public class MaterialServiceImpl implements MaterialService {
log.error("update sub material failed from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}
}else{
newMaterial.setId(oldMaterial.getId());
newMaterial.setCode(material.getCode());
newMaterial.setNum(0);
if(materialMapper.updateByPrimaryKeySelective(newMaterial) > 0){
log.info("update add material success from {} to {} for failed ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}else{
log.error("update add material failed from {} to {} for failed ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}
BeanUtils.copyProperties(oldMaterial,errorMaterial);
errorMaterial.setNum(material.getNum() - num);
errorMaterial.setId(material.getId());
failMaterials.add(errorMaterial);
}
}else{
errorMaterial.setId(material.getId());
errorMaterial.setCode(material.getCode());
errorMaterial.setNum(material.getNum());
errorMaterial.setNum(-1);
failMaterials.add(errorMaterial);
}
}
@ -182,12 +171,12 @@ public class MaterialServiceImpl implements MaterialService {
}
@Override
public boolean delete(String code) {
if(materialMapper.deleteByPrimaryKey(code) > 0){
log.info("delete material success {} ", code);
public boolean delete(Integer id) {
if(materialMapper.deleteByPrimaryKey(id) > 0){
log.info("delete material success {} ", id);
return true;
}
log.error("delete material failed {} ", code);
log.error("delete material failed {} ", id);
return false;
}

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

@ -66,7 +66,7 @@ public class PublicAssetServiceImpl implements PublicAssetService {
}
@Override
public boolean delete(String code) {
return publicAssetMapper.deleteByPrimaryKey(code) > 0;
public boolean delete(Integer id) {
return publicAssetMapper.deleteByPrimaryKey(id) > 0;
}
}

10
src/main/java/cn/redrock/assetmanage/service/impl/TokenServiceImpl.java

@ -39,9 +39,13 @@ public class TokenServiceImpl implements TokenService {
amToken.setToken(token);
tokenMapper.insert(amToken);
}else{
amToken.setToken(token);
amToken.setExpireTime(expireTime);
tokenMapper.updateTokenById(amToken);
if(amToken.getExpireTime().getTime() - new Date().getTime() < 0){
amToken.setToken(token);
amToken.setExpireTime(expireTime);
tokenMapper.updateTokenById(amToken);
}else{
token = amToken.getToken();
}
}
Map<String,Object> map = new HashMap<>();
map.put("token", token);

7
src/main/java/cn/redrock/assetmanage/service/impl/UserServiceImpl.java

@ -75,14 +75,9 @@ public class UserServiceImpl implements UserService {
log.info("can't find user with id {}",userId);
return false;
}
if(user.getName() != null && !oldUser.getName().equals(user.getName())){
if(userMapper.findUserByName(user.getName()) != null){
log.info("user {} already exists",user.getName());
return false;
}
}
BeanUtilsExt.copyPropertiesIgnoreNull(user,oldUser);
oldUser.setUpdateTime(new Date());
oldUser.setName(null);
return userMapper.updateByPrimaryKeySelective(oldUser) > 0;
}

4
src/main/java/cn/redrock/assetmanage/utils/ExcelUtils.java

@ -237,7 +237,7 @@ public class ExcelUtils {
})).collect(Collectors.toList());
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("sheet1");
Sheet sheet = wb.createSheet("Sheet1");
AtomicInteger ai = new AtomicInteger();
{
Row row = sheet.createRow(ai.getAndIncrement());
@ -288,7 +288,7 @@ public class ExcelUtils {
});
}
//冻结窗格
wb.getSheet("sheet1").createFreezePane(0, 1, 0, 1);
wb.getSheet("Sheet1").createFreezePane(0, 1, 0, 1);
return wb;
}

Loading…
Cancel
Save