zxl
7 天以前 0fb6b9d8d414822668c401a2b507df1fe6d1fa2d
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
package cn.lili.controller.permission;
 
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.common.vo.SearchVO;
import cn.lili.modules.member.entity.dos.StoreDepartment;
import cn.lili.modules.member.entity.vo.StoreDepartmentVO;
import cn.lili.modules.member.service.StoreDepartmentService;
import cn.lili.mybatis.util.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
 
/**
 * 管理端,部门管理接口
 *
 * @author Chopper
 * @since 2020/11/22 12:06
 */
@RestController
@Api(tags = "店铺端,部门管理接口")
@RequestMapping("/store/department")
public class StoreDepartmentController {
    @Autowired
    private StoreDepartmentService storeDepartmentService;
 
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "查看部门详情")
    public ResultMessage<StoreDepartment> get(@PathVariable String id) {
        StoreDepartment storeDepartment = storeDepartmentService.getById(id);
        return ResultUtil.data(storeDepartment);
    }
 
    @GetMapping
    @ApiOperation(value = "获取树状结构")
    public ResultMessage<List<StoreDepartmentVO>> getByPage(StoreDepartment entity,
                                                            SearchVO searchVo) {
        entity.setStoreId(UserContext.getCurrentUser().getStoreId());
        return ResultUtil.data(storeDepartmentService.tree(PageUtil.initWrapper(entity, searchVo)));
 
    }
 
    @PostMapping
    @ApiOperation(value = "新增部门")
    public ResultMessage<StoreDepartment> save(StoreDepartment storeDepartment) {
        storeDepartment.setStoreId(UserContext.getCurrentUser().getStoreId());
        storeDepartmentService.save(storeDepartment);
        return ResultUtil.data(storeDepartment);
    }
 
    @PutMapping("/{id}")
    @ApiOperation(value = "更新部门")
    public ResultMessage<StoreDepartment> update(@PathVariable String id, StoreDepartment storeDepartment) {
        storeDepartment.setId(id);
        storeDepartmentService.update(storeDepartment);
        return ResultUtil.data(storeDepartment);
    }
 
    @DeleteMapping(value = "/{ids}")
    @ApiOperation(value = "删除部门")
    public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
        storeDepartmentService.deleteByIds(ids);
        return ResultUtil.success();
    }
}