shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.ishop.merchant.platform;
 
import com.iplatform.base.Constants;
import com.ishop.merchant.BaseController;
import com.ishop.merchant.service.MerchantCategoryServiceImpl;
import com.ishop.model.po.EbMerchantCategory;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.web.ResponseValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * 平台端商户分类管理。
 * @date 2023-06-01
 */
@RestController
@RequestMapping("/platform/merchant/category")
public class MerchantCategoryController extends BaseController {
 
    private MerchantCategoryServiceImpl merchantCategoryService;
 
    @Autowired
    public MerchantCategoryController(MerchantCategoryServiceImpl merchantCategoryService){
        this.merchantCategoryService = merchantCategoryService;
    }
 
//    @ApiOperation(value="商户分类分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResponseValue list(){
        GenericPager<EbMerchantCategory> pager = this.merchantCategoryService.selectSplit(new EbMerchantCategory());
        return ResponseValue.success(pager);
    }
 
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public ResponseValue listAll(){
        List<EbMerchantCategory> list = this.merchantCategoryService.selectAll(new EbMerchantCategory());
        return ResponseValue.success(list);
    }
 
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResponseValue add(@RequestBody EbMerchantCategory category){
        if(category == null || StringUtils.isEmpty(category.getName())){
            return ResponseValue.error(Constants.ERROR_ARGUMENT);
        }
        category.setId(this.merchantCategoryService.queryNextId());
        this.merchantCategoryService.insert(category);
        return ResponseValue.success();
    }
 
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public ResponseValue update(@RequestBody EbMerchantCategory category){
        if(category == null || category.getId() == null || category.getId().intValue() <= 0){
            return ResponseValue.error(Constants.ERROR_ARGUMENT);
        }
        this.merchantCategoryService.save(category);
        return ResponseValue.success();
    }
 
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResponseValue delete(Integer id){
        if(id == null || id.intValue() <= 0){
            return ResponseValue.error(Constants.ERROR_ARGUMENT);
        }
        this.merchantCategoryService.delete(new EbMerchantCategory(id));
        return ResponseValue.success();
    }
}