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));
|
}
|
}
|