Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
36d2b9b505 | 6 months ago |
@ -0,0 +1,110 @@
|
|||||||
|
package cn.iocoder.hake.module.system.controller.admin.mcc;
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.hake.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import static cn.iocoder.hake.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.hake.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.hake.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.hake.module.system.enums.ErrorCodeConstants.MCC_EXISTS;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.module.system.controller.admin.mcc.vo.*;
|
||||||
|
import cn.iocoder.hake.module.system.dal.dataobject.mcc.MccDO;
|
||||||
|
import cn.iocoder.hake.module.system.service.mcc.MccService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 汇付MCC")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/huifu/mcc")
|
||||||
|
@Validated
|
||||||
|
public class MccController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MccService mccService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建汇付MCC")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:create')")
|
||||||
|
public CommonResult<Long> createMcc(@Valid @RequestBody MccSaveReqVO createReqVO) {
|
||||||
|
//判断是否存在数据
|
||||||
|
if (mccService.getMcc(createReqVO.getCode()) != null) {
|
||||||
|
throw exception(MCC_EXISTS);
|
||||||
|
}
|
||||||
|
return success(mccService.createMcc(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新汇付MCC")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:update')")
|
||||||
|
public CommonResult<Boolean> updateMcc(@Valid @RequestBody MccSaveReqVO updateReqVO) {
|
||||||
|
mccService.updateMcc(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除汇付MCC")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:delete')")
|
||||||
|
public CommonResult<Boolean> deleteMcc(@RequestParam("id") Long id) {
|
||||||
|
mccService.deleteMcc(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除汇付MCC")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:delete')")
|
||||||
|
public CommonResult<Boolean> deleteMccList(@RequestParam("ids") List<Long> ids) {
|
||||||
|
mccService.deleteMccListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得汇付MCC")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:query')")
|
||||||
|
public CommonResult<MccRespVO> getMcc(@RequestParam("id") Long id) {
|
||||||
|
MccDO mcc = mccService.getMcc(id);
|
||||||
|
return success(BeanUtils.toBean(mcc, MccRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得汇付MCC分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:query')")
|
||||||
|
public CommonResult<PageResult<MccRespVO>> getMccPage(@Valid MccPageReqVO pageReqVO) {
|
||||||
|
PageResult<MccDO> pageResult = mccService.getMccPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, MccRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出汇付MCC Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('huifu:mcc:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportMccExcel(@Valid MccPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<MccDO> list = mccService.getMccPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "汇付MCC.xls", "数据", MccRespVO.class,
|
||||||
|
BeanUtils.toBean(list, MccRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.hake.module.system.controller.admin.mcc.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.hake.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 汇付MCC分页 Request VO")
|
||||||
|
@Data
|
||||||
|
public class MccPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "大类名称")
|
||||||
|
private String majorCategory;
|
||||||
|
|
||||||
|
@Schema(description = "小类名称")
|
||||||
|
private String subCategory;
|
||||||
|
|
||||||
|
@Schema(description = "名称")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.hake.module.system.controller.admin.mcc.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 汇付MCC Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MccRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21735")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "大类名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("大类名称")
|
||||||
|
private String majorCategory;
|
||||||
|
|
||||||
|
@Schema(description = "小类名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("小类名称")
|
||||||
|
private String subCategory;
|
||||||
|
|
||||||
|
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("名称")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.hake.module.system.controller.admin.mcc.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 汇付MCC新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class MccSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1689")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "大类名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "大类名称不能为空")
|
||||||
|
private String majorCategory;
|
||||||
|
|
||||||
|
@Schema(description = "小类名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "小类名称不能为空")
|
||||||
|
private String subCategory;
|
||||||
|
|
||||||
|
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "名称不能为空")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "编码不能为空")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package cn.iocoder.hake.module.system.dal.dataobject.mcc;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.framework.tenant.core.aop.TenantIgnore;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.hake.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付MCC DO
|
||||||
|
*
|
||||||
|
* @author hake
|
||||||
|
*/
|
||||||
|
@TableName("huifu_mcc")
|
||||||
|
@KeySequence("huifu_mcc_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TenantIgnore
|
||||||
|
public class MccDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 大类名称
|
||||||
|
*/
|
||||||
|
private String majorCategory;
|
||||||
|
/**
|
||||||
|
* 小类名称
|
||||||
|
*/
|
||||||
|
private String subCategory;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String category;
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package cn.iocoder.hake.module.system.dal.mysql.mcc;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.hake.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.hake.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.hake.module.system.dal.dataobject.mcc.MccDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.hake.module.system.controller.admin.mcc.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付MCC Mapper
|
||||||
|
*
|
||||||
|
* @author hake
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MccMapper extends BaseMapperX<MccDO> {
|
||||||
|
|
||||||
|
default PageResult<MccDO> selectPage(MccPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<MccDO>()
|
||||||
|
.eqIfPresent(MccDO::getMajorCategory, reqVO.getMajorCategory())
|
||||||
|
.eqIfPresent(MccDO::getSubCategory, reqVO.getSubCategory())
|
||||||
|
.eqIfPresent(MccDO::getCategory, reqVO.getCategory())
|
||||||
|
.eqIfPresent(MccDO::getCode, reqVO.getCode())
|
||||||
|
.betweenIfPresent(MccDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(MccDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
default MccDO getMcc(String code) {
|
||||||
|
return selectOne(MccDO::getCode, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package cn.iocoder.hake.module.system.service.mcc;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.hake.module.system.controller.admin.mcc.vo.*;
|
||||||
|
import cn.iocoder.hake.module.system.dal.dataobject.mcc.MccDO;
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付MCC Service 接口
|
||||||
|
*
|
||||||
|
* @author hake
|
||||||
|
*/
|
||||||
|
public interface MccService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建汇付MCC
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createMcc(@Valid MccSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新汇付MCC
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateMcc(@Valid MccSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除汇付MCC
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteMcc(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除汇付MCC
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteMccListByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得汇付MCC
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 汇付MCC
|
||||||
|
*/
|
||||||
|
MccDO getMcc(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得汇付MCC分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 汇付MCC分页
|
||||||
|
*/
|
||||||
|
PageResult<MccDO> getMccPage(MccPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得汇付MCC
|
||||||
|
*
|
||||||
|
* @param code 编号
|
||||||
|
* @return 汇付MCC
|
||||||
|
*/
|
||||||
|
MccDO getMcc(String code);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
package cn.iocoder.hake.module.system.service.mcc;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.hake.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.module.system.controller.admin.mcc.vo.*;
|
||||||
|
import cn.iocoder.hake.module.system.dal.dataobject.mcc.MccDO;
|
||||||
|
import cn.iocoder.hake.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.hake.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.hake.module.system.dal.mysql.mcc.MccMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.hake.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.hake.module.system.enums.ErrorCodeConstants.MCC_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付MCC Service 实现类
|
||||||
|
*
|
||||||
|
* @author hake
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class MccServiceImpl implements MccService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MccMapper mccMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createMcc(MccSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
MccDO mcc = BeanUtils.toBean(createReqVO, MccDO.class);
|
||||||
|
mccMapper.insert(mcc);
|
||||||
|
// 返回
|
||||||
|
return mcc.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMcc(MccSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateMccExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
MccDO updateObj = BeanUtils.toBean(updateReqVO, MccDO.class);
|
||||||
|
updateObj.setUpdater(SecurityFrameworkUtils.getLoginUserId().toString());
|
||||||
|
mccMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMcc(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateMccExists(id);
|
||||||
|
// 删除
|
||||||
|
mccMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMccListByIds(List<Long> ids) {
|
||||||
|
// 校验存在
|
||||||
|
validateMccExists(ids);
|
||||||
|
// 删除
|
||||||
|
mccMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMccExists(List<Long> ids) {
|
||||||
|
List<MccDO> list = mccMapper.selectByIds(ids);
|
||||||
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
|
throw exception(MCC_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMccExists(Long id) {
|
||||||
|
if (mccMapper.selectById(id) == null) {
|
||||||
|
throw exception(MCC_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MccDO getMcc(Long id) {
|
||||||
|
return mccMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MccDO> getMccPage(MccPageReqVO pageReqVO) {
|
||||||
|
return mccMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MccDO getMcc(String code) {
|
||||||
|
return mccMapper.getMcc(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue