2022-03-01 09:36:56 +08:00
|
|
|
package com.xkrs.controller;
|
|
|
|
|
|
|
|
import com.xkrs.dao.SpecDao;
|
|
|
|
import com.xkrs.encapsulation.PromptMessageEnum;
|
|
|
|
import com.xkrs.model.entity.SpecEntity;
|
|
|
|
import com.xkrs.model.qo.SpecQo;
|
|
|
|
import com.xkrs.service.SpecService;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2022-03-01 11:59:54 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2022-03-01 09:36:56 +08:00
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.Locale;
|
2022-03-01 11:59:54 +08:00
|
|
|
import java.util.Optional;
|
2022-03-01 09:36:56 +08:00
|
|
|
|
|
|
|
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author: XinYi Song
|
|
|
|
* @Date: 2022/1/20 16:01
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
public class SpecController {
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private SpecService specService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private SpecDao specDao;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加规格数据
|
|
|
|
*
|
|
|
|
* @param specQo
|
|
|
|
*/
|
|
|
|
@PostMapping("/insertSpec")
|
2022-03-01 11:59:54 +08:00
|
|
|
public String insertSpec(@RequestBody SpecQo specQo) {
|
2022-03-01 09:36:56 +08:00
|
|
|
return specService.insertSpec(specQo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询规格信息
|
|
|
|
*/
|
2022-03-01 11:59:54 +08:00
|
|
|
@GetMapping("/selectSpec")
|
|
|
|
public String selectSpec(@RequestParam("partNo") String partNo, @RequestParam("inspectionItemCode") String inspectionItemCode) {
|
2022-03-01 09:36:56 +08:00
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
2022-03-01 11:59:54 +08:00
|
|
|
Optional<SpecEntity> byPartNoAndInspectionItemCode = specDao.findByPartNoAndInspectionItemCode(partNo, inspectionItemCode);
|
|
|
|
if (byPartNoAndInspectionItemCode.isEmpty()) {
|
2022-03-01 09:36:56 +08:00
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的规格信息!", locale);
|
|
|
|
}
|
2022-03-01 11:59:54 +08:00
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byPartNoAndInspectionItemCode.get(), locale);
|
2022-03-01 09:36:56 +08:00
|
|
|
}
|
|
|
|
}
|