MallController.java 3.98 KB
package vion.controller.monitor;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.monitor.MallDTO;
import vion.model.monitor.MAccount;
import vion.model.monitor.RMallRemark;
import vion.service.monitor.IMallService;
import vion.service.monitor.IRMallRemarkService;
import vion.vo.monitor.MallVO;

import java.util.List;

/**
 * mall 信息
 */
@RestController
@RequestMapping("/api/mall")
@RequiredArgsConstructor
public class MallController {

    private final IMallService mallService;
    private final IRMallRemarkService mallRemarkService;

    @GetMapping("/account")
    @SaCheckPermission(value = "mall:account:list", orRole = "admin")
    public Page<MAccount> listAccount(MAccount dto) {
        return mallService.listAccount(dto);
    }

    @GetMapping("/attention/account")
    @SaCheckPermission(value = "mall:attention:account:list", orRole = "admin")
    public Page<MAccount> listAttentionAccount(MAccount dto) {
        return mallService.listAttentionAccount(dto);
    }

    @GetMapping
    @SaCheckPermission(value = "mall:list", orRole = "admin")
    public Page<MallVO> list(MallDTO dto) {
        return mallService.list(dto);
    }

    @GetMapping("/{id}")
    @SaCheckPermission(value = "mall:get", orRole = "admin")
    public MallVO get(@PathVariable Long id) {
        return mallService.get(id);
    }

    @GetMapping("/attention")
    @SaCheckPermission(value = "mall:attention:list", orRole = "admin")
    public Page<MallVO> listAttention(MallDTO dto) {
        return mallService.listAttention(dto);
    }

    @GetMapping("/errorAttention")
    @SaCheckPermission(value = "mall:attention:listError", orRole = "admin")
    public Page<MallVO> listErrorAttention(MallDTO dto) {
        return mallService.listErrorAttention(dto);
    }

    @PostMapping("/attention")
    @SaCheckPermission(value = "mall:attention:edit", orRole = "admin")
    public String attention(@RequestBody List<MallDTO> dtoList) {
        return mallService.attention(dtoList);
    }

    @PostMapping("/attention/account/{accountUid}")
    @SaCheckPermission(value = "mall:attention:account", orRole = "admin")
    public String attentionByAccount(@PathVariable String accountUid) {
        return mallService.attentionByAccount(accountUid);
    }

    @PostMapping("/attention/{id}")
    @SaCheckPermission(value = "mall:attention:cancel", orRole = "admin")
    public String cancelAttention(@PathVariable Long id) {
        return mallService.cancelAttention(id);
    }

    // region   备注
    @GetMapping("/remark")
    @SaCheckPermission(value = "mall:remark:list", orRole = "admin")
    public Page<RMallRemark> listRemark(RMallRemark dto) {
        return mallRemarkService.lambdaQuery(dto)
                .orderByDesc(RMallRemark::getRemarkDate, RMallRemark::getCreateTime)
                .page(Page.of(dto.getPageNum(), dto.getPageSize()));
    }

    @GetMapping("/remark/{id}")
    @SaCheckPermission(value = "mall:remark:get", orRole = "admin")
    public RMallRemark getRemark(@PathVariable Long id) {
        return mallRemarkService.getById(id);
    }

    @PostMapping("/remark")
    @SaCheckPermission(value = "mall:remark:save", orRole = "admin")
    public String remark(@RequestBody RMallRemark dto) {
        return mallRemarkService.save(dto) ? "添加成功" : "添加失败";
    }

    @PostMapping("/remark/{id}")
    @SaCheckPermission(value = "mall:remark:edit", orRole = "admin")
    public String editRemark(@PathVariable Long id, @RequestBody RMallRemark dto) {
        dto.setId(id);
        return mallRemarkService.updateById(dto) ? "修改成功" : "修改失败";
    }

    @DeleteMapping("/remark/{id}")
    @SaCheckPermission(value = "mall:remark:remove", orRole = "admin")
    public String removeRemark(@PathVariable Long id) {
        return mallRemarkService.removeById(id) ? "删除成功" : "删除失败";
    }

    // endregion
}