12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package cn.efunbox.manage.base.service.impl;
- import cn.efunbox.manage.base.entity.CostType;
- import cn.efunbox.manage.base.enums.BaseStatusEnum;
- import cn.efunbox.manage.base.repository.CostTypeRepository;
- import cn.efunbox.manage.base.service.CostTypeService;
- import cn.efunbox.manage.common.result.ApiCode;
- import cn.efunbox.manage.common.result.ApiResult;
- import com.sun.xml.internal.rngom.parse.host.Base;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- import java.util.Objects;
- /**
- * CostTypeServiceImpl
- * Created by wangys on 2019/03/08
- */
- @Service
- public class CostTypeServiceImpl implements CostTypeService {
- @Autowired
- CostTypeRepository costTypeRepository;
- @Override
- public ApiResult list(CostType costType) {
- List<CostType> costTypes = costTypeRepository.findByStatusOrderBySortDesc(BaseStatusEnum.NORMAL);
- if(Objects.nonNull(costTypes)){
- return ApiResult.ok(costTypes);
- }
- return ApiResult.error(ApiCode.UNKNOWN_ERROR);
- }
- @Override
- public ApiResult save(CostType costType) {
- costType = costTypeRepository.save(costType);
- if(Objects.nonNull(costType)){
- return ApiResult.ok(costType);
- }
- return ApiResult.error(ApiCode.UNKNOWN_ERROR);
- }
- @Override
- public ApiResult update(CostType costType) {
- costType = costTypeRepository.update(costType);
- if(Objects.nonNull(costType)){
- return ApiResult.ok(costType);
- }
- return ApiResult.error(ApiCode.UNKNOWN_ERROR);
- }
- }
|