zjk
14 小时以前 a4afcfdb179e62a498b62cc6860d8cd46701a08f
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.ruoyi.user.controller;
 
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.user.domain.AccountProvider;
import com.ruoyi.user.domain.vo.AccountProviderForm;
import com.ruoyi.user.domain.vo.AccountProviderVo;
import com.ruoyi.user.service.IAccountProviderService;
 
/**
 * 服务商 信息操作处理
 *
 * 网关前缀 /account 由 StripPrefix=1 剥掉,故此处映射为 /user/provider,
 * 外部实际路径是 /account/user/provider/**。
 *
 * 与城市公司档案一样只有「增/查/改」没有「删」:原型操作列只有 查看 与 禁用,
 * 需要停用就改状态(且禁的只是服务商资格,不动会员账号)。
 *
 * 校验一律在服务层:建档要在一个事务里写三处,且手机号「必填」这道会员侧没有的口子
 * 必须自己堵(详见 AccountProviderServiceImpl 的类注释)。故这里几个写接口都很薄。
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/user/provider")
public class AccountProviderController extends BaseController
{
    @Autowired
    private IAccountProviderService providerService;
 
    /**
     * 查询服务商列表
     */
    @RequiresPermissions("member:provider:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountProviderVo provider)
    {
        startPage();
        List<AccountProviderVo> list = providerService.selectProviderList(provider);
        return getDataTable(list);
    }
 
    /**
     * 获取服务商详细信息(表单的查看与修改共用同一个页面,用它回填;不含密码)
     */
    @RequiresPermissions("member:provider:query")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(providerService.selectProviderById(id));
    }
 
    /**
     * 新增服务商(同时建登录账号并打上服务商标识)
     */
    @RequiresPermissions("member:provider:add")
    @Log(title = "服务商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountProviderForm form)
    {
        return toAjax(providerService.insertProvider(form));
    }
 
    /**
     * 修改服务商(登录账号/手机号同步到账号表,密码留空即不改)
     */
    @RequiresPermissions("member:provider:edit")
    @Log(title = "服务商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountProviderForm form)
    {
        return toAjax(providerService.updateProvider(form));
    }
 
    /**
     * 修改服务商状态(禁用/启用,只改服务商资格)
     */
    @RequiresPermissions("member:provider:edit")
    @Log(title = "服务商", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody AccountProvider provider)
    {
        return toAjax(providerService.changeStatus(provider));
    }
}