mirror of https://github.com/elunez/eladmin
计量单位
parent
5bcc19a9ba
commit
77d103e63e
|
|
@ -9,4 +9,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
* @date 2019-07-26
|
* @date 2019-07-26
|
||||||
*/
|
*/
|
||||||
public interface MeasureUnitRepository extends JpaRepository<MeasureUnit, Long >, JpaSpecificationExecutor {
|
public interface MeasureUnitRepository extends JpaRepository<MeasureUnit, Long >, JpaSpecificationExecutor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,23 @@ package me.zhengjie.modules.wms.bd.rest;
|
||||||
|
|
||||||
import me.zhengjie.aop.log.Log;
|
import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
|
import me.zhengjie.modules.system.service.dto.DictDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||||
import me.zhengjie.modules.wms.bd.service.MeasureUnitService;
|
import me.zhengjie.modules.wms.bd.service.MeasureUnitService;
|
||||||
|
import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
||||||
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.Collections;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 黄星星
|
* @author 黄星星
|
||||||
|
|
@ -34,4 +41,23 @@ public class MeasureUnitController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity(measureUnitService.create(resources), HttpStatus.CREATED);
|
return new ResponseEntity(measureUnitService.create(resources), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("查看计量单位详情")
|
||||||
|
@GetMapping(value = "/measureUnit/{id}")
|
||||||
|
public ResponseEntity getMessureUnits(@PathVariable Long id){
|
||||||
|
return new ResponseEntity(measureUnitService.findById(id), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("删除计量单位")
|
||||||
|
@DeleteMapping(value = "/measureUnit/{id}")
|
||||||
|
public ResponseEntity delete(@PathVariable Long id){
|
||||||
|
measureUnitService.delete(id);
|
||||||
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("查询计量单位")
|
||||||
|
@GetMapping(value = "/measureUnit")
|
||||||
|
public ResponseEntity getDicts(MeasureUnitDTO resources, Pageable pageable){
|
||||||
|
return new ResponseEntity(measureUnitService.queryAll(resources,pageable),HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package me.zhengjie.modules.wms.bd.service;
|
package me.zhengjie.modules.wms.bd.service;
|
||||||
|
|
||||||
|
import me.zhengjie.modules.system.service.dto.DictDTO;
|
||||||
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||||
import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 黄星星
|
* @author 黄星星
|
||||||
|
|
@ -9,5 +11,11 @@ import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
||||||
*/
|
*/
|
||||||
public interface MeasureUnitService {
|
public interface MeasureUnitService {
|
||||||
|
|
||||||
public MeasureUnitDTO create(MeasureUnit resources);
|
MeasureUnitDTO create(MeasureUnit resources);
|
||||||
|
|
||||||
|
MeasureUnitDTO findById(long id);
|
||||||
|
|
||||||
|
void delete(Long id);
|
||||||
|
|
||||||
|
Object queryAll(MeasureUnitDTO dict, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package me.zhengjie.modules.wms.bd.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黄星星
|
||||||
|
* @date 2019-07-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MeasureUnitQueryCriteria implements Serializable {
|
||||||
|
|
||||||
|
@Query
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Query(type = Query.Type.INNER_LIKE)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Query
|
||||||
|
private Boolean status;
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,23 @@
|
||||||
package me.zhengjie.modules.wms.bd.service.impl;
|
package me.zhengjie.modules.wms.bd.service.impl;
|
||||||
|
|
||||||
|
import me.zhengjie.modules.system.domain.Dict;
|
||||||
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||||
import me.zhengjie.modules.wms.bd.repository.MeasureUnitRepository;
|
import me.zhengjie.modules.wms.bd.repository.MeasureUnitRepository;
|
||||||
import me.zhengjie.modules.wms.bd.service.MeasureUnitService;
|
import me.zhengjie.modules.wms.bd.service.MeasureUnitService;
|
||||||
import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
import me.zhengjie.modules.wms.bd.service.dto.MeasureUnitDTO;
|
||||||
import me.zhengjie.modules.wms.bd.service.mapper.MeasureUnitMapper;
|
import me.zhengjie.modules.wms.bd.service.mapper.MeasureUnitMapper;
|
||||||
|
import me.zhengjie.utils.PageUtil;
|
||||||
|
import me.zhengjie.utils.QueryHelp;
|
||||||
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 黄星星
|
* @author 黄星星
|
||||||
* @date 2019-07-27
|
* @date 2019-07-27
|
||||||
|
|
@ -30,4 +38,24 @@ public class MeasureUnitServiceImpl implements MeasureUnitService {
|
||||||
return measureUnitMapper.toDto(measureUnitRepository.save(resources));
|
return measureUnitMapper.toDto(measureUnitRepository.save(resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public MeasureUnitDTO findById(long id) {
|
||||||
|
Optional<MeasureUnit> measureUnit = measureUnitRepository.findById(id);
|
||||||
|
ValidationUtil.isNull(measureUnit,"MeasureUnit","id",id);
|
||||||
|
return measureUnitMapper.toDto(measureUnit.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Long id) {
|
||||||
|
measureUnitRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object queryAll(MeasureUnitDTO measureUnit, Pageable pageable) {
|
||||||
|
Page<MeasureUnit> page = measureUnitRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, measureUnit, cb), pageable);
|
||||||
|
return PageUtil.toPage(page.map(measureUnitMapper::toDto));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue