当前位置:网站首页>2_ Introduction to SPU related services
2_ Introduction to SPU related services
2022-06-11 03:37:00 【The bright moon is always fresh】
List query function development
establish mapper
@Mapper
public interface SpuInfoMapper extends BaseMapper<SpuInfo> {
}
Create an interface ManageService
/** * spu Paging query * @param pageParam * @param spuInfo * @return */
IPage<SpuInfo> getSpuInfoPage(Page<SpuInfo> pageParam, SpuInfo spuInfo);
Create implementation classes ManageServiceImpl
@Autowired
private SpuInfoMapper spuInfoMapper;
@Override
public IPage<SpuInfo> getSpuInfoPage(Page<SpuInfo> pageParam, SpuInfo spuInfo) {
QueryWrapper<SpuInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("category3_id", spuInfo.getCategory3Id());
queryWrapper.orderByDesc("id");
return spuInfoMapper.selectPage(pageParam, queryWrapper);
}
Create controller SpuManageController
@RestController // @ResponseBody + @Controller
@RequestMapping("admin/product")
public class SpuManageController {
@Autowired
private ManageService manageService;
// Encapsulate the controller according to the query conditions
// springMVC When , There is an object attribute value transfer If the parameters submitted by the page are consistent with those of the entity class ,
// You can use entity classes to receive data
// http://api.gmall.com/admin/product/1/10?category3Id=61
// @RequestBody effect Pass it to the front desk json{"category3Id":"61"} The string changes to java object .
//
@GetMapping("{page}/{size}")
public Result getSpuInfoPage(@PathVariable Long page,
@PathVariable Long size,
SpuInfo spuInfo){
// Create a Page object
Page<SpuInfo> spuInfoPage = new Page<>(page,size);
// get data
IPage<SpuInfo> spuInfoPageList = manageService.getSpuInfoPage(spuInfoPage, spuInfo);
// Return the obtained data !
return Result.ok(spuInfoPageList);
}
}
Trademark and brand management
establish mapper
@Mapper
public interface BaseTrademarkMapper extends BaseMapper<BaseTrademark> {
}
Create an interface BaseTrademarkService
public interface BaseTrademarkService extends IService<BaseTrademark> {
/** * Banner Paging list * @param pageParam * @return */
IPage<BaseTrademark> getPage(Page<BaseTrademark> pageParam);
}
Create implementation classes BaseTrademarkServiceImpl
@Service
public class BaseTrademarkServiceImpl extends ServiceImpl<BaseTrademarkMapper, BaseTrademark> implements BaseTrademarkService {
@Autowired
private BaseTrademarkMapper baseTrademarkMapper;
@Override
public IPage<BaseTrademark> getPage(Page<BaseTrademark> pageParam) {
QueryWrapper<BaseTrademark> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("id");
IPage<BaseTrademark> page = baseTrademarkMapper.selectPage(pageParam, queryWrapper);
return page;
}
}
Create controller BaseTrademarkController
@RestController
@RequestMapping("/admin/product/baseTrademark")
public class BaseTrademarkController {
@Autowired
private BaseTrademarkService baseTrademarkService;
@ApiOperation(value = " Paging list ")
@GetMapping("{page}/{limit}")
public Result index(@PathVariable Long page,
@PathVariable Long limit) {
Page<BaseTrademark> pageParam = new Page<>(page, limit);
IPage<BaseTrademark> pageModel = baseTrademarkService.selectPage(pageParam);
return Result.ok(pageModel);
}
@ApiOperation(value = " obtain BaseTrademark")
@GetMapping("get/{id}")
public Result get(@PathVariable String id) {
BaseTrademark baseTrademark = baseTrademarkService.getById(id);
return Result.ok(baseTrademark);
}
@ApiOperation(value = " newly added BaseTrademark")
@PostMapping("save")
public Result save(@RequestBody BaseTrademark banner) {
baseTrademarkService.save(banner);
return Result.ok();
}
@ApiOperation(value = " modify BaseTrademark")
@PutMapping("update")
public Result updateById(@RequestBody BaseTrademark banner) {
baseTrademarkService.updateById(banner);
return Result.ok();
}
@ApiOperation(value = " Delete BaseTrademark")
@DeleteMapping("remove/{id}")
public Result remove(@PathVariable Long id) {
baseTrademarkService.removeById(id);
return Result.ok();
}
}
spu preservation
Load sales attributes
establish mapper
@Mapper
public interface BaseSaleAttrMapper extends BaseMapper<BaseSaleAttr> {
}
stay MangeService Add interface
Interface
/** * Query all sales attribute data * @return */
List<BaseSaleAttr> getBaseSaleAttrList();
Implementation class
@Autowired
private BaseSaleAttrMapper baseSaleAttrMapper;
@Override
public List<BaseSaleAttr> getBaseSaleAttrList() {
return baseSaleAttrMapper.selectList(null);
}
Add controller SpuManageController
@RestController
@RequestMapping("admin/product")
public class SpuManageController {
// Introducing service layer
@Autowired
private ManageService manageService;
// Sales attributes http://api.gmall.com/admin/product/baseSaleAttrList
@GetMapping("baseSaleAttrList")
public Result baseSaleAttrList(){
// Query all sales attribute sets
List<BaseSaleAttr> baseSaleAttrList = manageService.getBaseSaleAttrList();
return Result.ok(baseSaleAttrList);
}
}
边栏推荐
- Mavros controls UAV to conduct binocular slam in gazebo environment
- Vocabulary Construction -- code completion fast food tutorial (3) - word segmentation
- Implementation of publish and subscribe mode ----- hand tearing JS series
- Oppo reno6 turned sour by "inner roll"
- If the source code of the home page module is not separated ----- > nanny level source code analysis (1)
- postgresql 语句
- If not, use the code generator to generate a set of addition, deletion, modification and query (2)
- SQL查询连续三天登录的用户
- /10个值得推荐的学习编程的网站 世界已经进入了互联网的时代。据最近发布的一篇《2016年互联网趋势》报告显示,中国已成为互联网市场的领导者,中国互联网用户的数量达到了6.68亿。可以预见,有
- 右键 powershell here 功能添加
猜你喜欢

OpenGL Chapter 11 multiple light sources

Shangpinhui mall_ Background homepage of

正则表达式

canvas交互式星星动画背景js特效

UML系列文章(28)体系结构建模---协作

Product milestones in May 2022

基于SSM的考试项目管理系统

net::ERR_ FILE_ NOT_ Found error

J. Balanced Tree

The key data of music genuine rate is missing. What is the odds of Netease cloud music IPO?
随机推荐
/10个值得推荐的学习编程的网站 世界已经进入了互联网的时代。据最近发布的一篇《2016年互联网趋势》报告显示,中国已成为互联网市场的领导者,中国互联网用户的数量达到了6.68亿。可以预见,有
Pthread in the multithreaded Trilogy
实现发布订阅模式-----手撕js系列
正则表达式
Iqoo 8 measured hands-on experience: return of the king, never high profile
Jeecgboot learning_ Online form first experience
023 MySQL index optimization tips - common cases of index failure
C. Jump and Treasure(dp + 单调队列优化)
OpenGL error Guide
Oppo reno6 turned sour by "inner roll"
ThoughtWorks. QRcode full-featured generator
JS click the sun and moon to switch between day and night JS special effect
Nsthread of the multithreaded Trilogy
Using minted to insert highlighted code in texstudio in latex environment
three. JS cool technology background H5 animation
基于SSM框架的学生在线教育教学课程管理系统
Xu Li 618, how can Suning fight this hard battle?
[elt.zip] openharmony paper Club - Data high-throughput lossless compression scheme
Picking peaches (double pointer)
UML series articles (28) architecture modeling - collaboration