parent
55c364906c
commit
0bfee204a4
@ -0,0 +1,33 @@ |
||||
package cn.ey.biz.module.system.api.serviceline; |
||||
|
||||
import cn.ey.biz.common.pojo.R; |
||||
import cn.ey.biz.module.system.enums.ApiConstants; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiImplicitParam; |
||||
import io.swagger.annotations.ApiImplicitParams; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author zhangjunlong |
||||
* @since 2023/10/31 16:23 |
||||
*/ |
||||
|
||||
@FeignClient(name = ApiConstants.NAME) |
||||
public interface ServiceLineApi { |
||||
String PREFIX = ApiConstants.PREFIX + "/service-line-api"; |
||||
|
||||
/** |
||||
* 根据编码获取业务子线的名称 |
||||
* |
||||
* @param code 编码 |
||||
* @return |
||||
*/ |
||||
@GetMapping(PREFIX + "/sub-service-line-name") |
||||
R<String> getSubServiceLineName(@RequestParam("code") String code); |
||||
|
||||
} |
||||
@ -0,0 +1,35 @@ |
||||
package cn.ey.biz.module.system.api.serviceline; |
||||
|
||||
import cn.ey.biz.common.pojo.R; |
||||
import cn.ey.biz.module.system.dal.dataobject.codeblock.SubServiceLineDO; |
||||
import cn.ey.biz.module.system.service.serviceline.ServiceSubLineService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.apache.dubbo.config.annotation.DubboService; |
||||
import org.springframework.cache.annotation.Cacheable; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
import static cn.ey.biz.module.system.enums.ApiConstants.VERSION; |
||||
|
||||
/** |
||||
* @author zhangjunlong |
||||
* @since 2023/10/31 17:16 |
||||
*/ |
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口,给 Dubbo Consumer 调用
|
||||
@RequiredArgsConstructor |
||||
public class ServiceLineApiImpl implements ServiceLineApi { |
||||
private final ServiceSubLineService serviceSubLineService; |
||||
|
||||
/** |
||||
* 根据编码获取业务子线的名称 |
||||
* |
||||
* @param code 编码 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public R<String> getSubServiceLineName(String code) { |
||||
return R.success(serviceSubLineService.getSubServiceLineNameStr(code)); |
||||
} |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
package cn.ey.biz.module.system.dal.mapper.serviceline; |
||||
|
||||
import cn.ey.biz.module.system.dal.dataobject.codeblock.SubServiceLineDO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* @author zhangjunlong |
||||
* @since 2023/10/31 17:11 |
||||
*/ |
||||
@Mapper |
||||
public interface ServiceSubLineMapper extends BaseMapper<SubServiceLineDO> { |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
package cn.ey.biz.module.system.service.serviceline; |
||||
|
||||
import cn.ey.biz.module.system.dal.dataobject.codeblock.SubServiceLineDO; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* @author zhangjunlong |
||||
* @since 2023/10/31 16:31 |
||||
*/ |
||||
public interface ServiceSubLineService extends IService<SubServiceLineDO> { |
||||
String getSubServiceLineNameStr(String code); |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
package cn.ey.biz.module.system.service.serviceline; |
||||
|
||||
import cn.ey.biz.module.system.dal.dataobject.codeblock.SubServiceLineDO; |
||||
import cn.ey.biz.module.system.dal.mapper.serviceline.ServiceSubLineMapper; |
||||
import cn.ey.biz.module.system.service.serviceline.ServiceSubLineService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.cache.annotation.Cacheable; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author zhangjunlong |
||||
* @since 2023/10/31 17:13 |
||||
*/ |
||||
@Service |
||||
public class ServiceSubLineServiceImpl extends ServiceImpl<ServiceSubLineMapper, SubServiceLineDO> implements ServiceSubLineService { |
||||
@Override |
||||
@Cacheable(cacheNames = "ey:gpt:sub-service-line", key = "#code", unless = "#result==null") |
||||
public String getSubServiceLineNameStr(String code) { |
||||
SubServiceLineDO subServiceLineDO = |
||||
lambdaQuery().select(SubServiceLineDO::getSslName).eq(SubServiceLineDO::getSslCode, |
||||
code).one(); |
||||
if (Objects.isNull(subServiceLineDO)) { |
||||
return ""; |
||||
} |
||||
return subServiceLineDO.getSslName(); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue