commit
dea5a65f0a
@ -1,95 +0,0 @@
|
||||
package com.chanko.yunxi.mes.module.heli.controller.admin.client;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.client.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.client.ClientDO;
|
||||
import com.chanko.yunxi.mes.module.heli.service.client.ClientService;
|
||||
|
||||
@Tag(name = "管理后台 - 客户")
|
||||
@RestController
|
||||
@RequestMapping("/heli/client")
|
||||
@Validated
|
||||
public class ClientController {
|
||||
|
||||
@Resource
|
||||
private ClientService clientService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客户")
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:create')")
|
||||
public CommonResult<Long> createClient(@Valid @RequestBody ClientSaveReqVO createReqVO) {
|
||||
return success(clientService.createClient(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客户")
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:update')")
|
||||
public CommonResult<Boolean> updateClient(@Valid @RequestBody ClientSaveReqVO updateReqVO) {
|
||||
clientService.updateClient(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除客户")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:delete')")
|
||||
public CommonResult<Boolean> deleteClient(@RequestParam("id") Long id) {
|
||||
clientService.deleteClient(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得客户")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:query')")
|
||||
public CommonResult<ClientRespVO> getClient(@RequestParam("id") Long id) {
|
||||
ClientDO client = clientService.getClient(id);
|
||||
return success(BeanUtils.toBean(client, ClientRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客户分页")
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:query')")
|
||||
public CommonResult<PageResult<ClientRespVO>> getClientPage(@Valid ClientPageReqVO pageReqVO) {
|
||||
PageResult<ClientDO> pageResult = clientService.getClientPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ClientRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出客户 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('heli:client:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportClientExcel(@Valid ClientPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ClientDO> list = clientService.getClientPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "客户.xls", "数据", ClientRespVO.class,
|
||||
BeanUtils.toBean(list, ClientRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.chanko.yunxi.mes.module.heli.dal.mysql.client;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.client.ClientDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.client.vo.*;
|
||||
|
||||
/**
|
||||
* 客户 Mapper
|
||||
*
|
||||
* @author 开发者
|
||||
*/
|
||||
@Mapper
|
||||
public interface ClientMapper extends BaseMapperX<ClientDO> {
|
||||
|
||||
default PageResult<ClientDO> selectPage(ClientPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ClientDO>()
|
||||
.likeIfPresent(ClientDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(ClientDO::getSimpleName, reqVO.getSimpleName())
|
||||
.likeIfPresent(ClientDO::getName, reqVO.getName())
|
||||
.likeIfPresent(ClientDO::getTelephone, reqVO.getTelephone())
|
||||
.eqIfPresent(ClientDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(ClientDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.client;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.client.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.client.ClientDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 客户 Service 接口
|
||||
*
|
||||
* @author 开发者
|
||||
*/
|
||||
public interface ClientService {
|
||||
|
||||
/**
|
||||
* 创建客户
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createClient(@Valid ClientSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新客户
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateClient(@Valid ClientSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除客户
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteClient(Long id);
|
||||
|
||||
/**
|
||||
* 获得客户
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 客户
|
||||
*/
|
||||
ClientDO getClient(Long id);
|
||||
|
||||
/**
|
||||
* 获得客户分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 客户分页
|
||||
*/
|
||||
PageResult<ClientDO> getClientPage(ClientPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.client;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.client.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.client.ClientDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.client.ClientMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 客户 Service 实现类
|
||||
*
|
||||
* @author 开发者
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ClientServiceImpl implements ClientService {
|
||||
|
||||
@Resource
|
||||
private ClientMapper clientMapper;
|
||||
|
||||
@Override
|
||||
public Long createClient(ClientSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ClientDO client = BeanUtils.toBean(createReqVO, ClientDO.class);
|
||||
clientMapper.insert(client);
|
||||
// 返回
|
||||
return client.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClient(ClientSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateClientExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ClientDO updateObj = BeanUtils.toBean(updateReqVO, ClientDO.class);
|
||||
clientMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteClient(Long id) {
|
||||
// 校验存在
|
||||
validateClientExists(id);
|
||||
// 删除
|
||||
clientMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateClientExists(Long id) {
|
||||
if (clientMapper.selectById(id) == null) {
|
||||
throw exception(CLIENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientDO getClient(Long id) {
|
||||
return clientMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClientDO> getClientPage(ClientPageReqVO pageReqVO) {
|
||||
return clientMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface ClientVO {
|
||||
id: number
|
||||
code: string
|
||||
simpleName: string
|
||||
name: string
|
||||
telephone: string
|
||||
address: string
|
||||
description: string
|
||||
status: number
|
||||
}
|
||||
|
||||
// 查询客户分页
|
||||
export const getClientPage = async (params) => {
|
||||
return await request.get({ url: `/heli/client/page`, params })
|
||||
}
|
||||
|
||||
// 查询客户详情
|
||||
export const getClient = async (id: number) => {
|
||||
return await request.get({ url: `/heli/client/get?id=` + id })
|
||||
}
|
||||
|
||||
// 新增客户
|
||||
export const createClient = async (data: ClientVO) => {
|
||||
return await request.post({ url: `/heli/client/create`, data })
|
||||
}
|
||||
|
||||
// 修改客户
|
||||
export const updateClient = async (data: ClientVO) => {
|
||||
return await request.put({ url: `/heli/client/update`, data })
|
||||
}
|
||||
|
||||
// 删除客户
|
||||
export const deleteClient = async (id: number) => {
|
||||
return await request.delete({ url: `/heli/client/delete?id=` + id })
|
||||
}
|
||||
|
||||
// 导出客户 Excel
|
||||
export const exportClient = async (params) => {
|
||||
return await request.download({ url: `/heli/client/export-excel`, params })
|
||||
}
|
Loading…
Reference in new issue