feat:商户分类
This commit is contained in:
1 parent
a9682a6830
commit
e9f039e1ce
7 files changed
+294
No files matched your search
+94
@@ -0,0 +1,94 @@
|
||||
package com.bsd.pjcloud.wallet.api.entity.mch;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商户分类
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("mch_catgory")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "商户分类")
|
||||
public class MchCatgoryEntity extends Model<MchCatgoryEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分类名
|
||||
*/
|
||||
@Schema(description="分类名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 分类名类型
|
||||
*/
|
||||
@Schema(description="分类名类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description="排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description="备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+1
@@ -96,6 +96,7 @@ public class WalletTransactionController {
|
||||
@PostMapping("/page-cz")
|
||||
public R pageCz(@ParameterObject Page page, @RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
|
||||
dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
DataScope dataScope = new DataScope();
|
||||
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.bsd.pjcloud.wallet.controller.mch;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchCatgoryEntity;
|
||||
import com.bsd.pjcloud.wallet.service.MchCatgoryService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 商户分类
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/mch-catgory")
|
||||
@Tag(description = "mch-catgory", name = "商户分类管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class MchCatgoryController {
|
||||
|
||||
private final MchCatgoryService mchCatgoryService;
|
||||
|
||||
@Operation(summary = "下拉查询(没有权限)", description = "下拉查询(没有权限)")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject MchCatgoryEntity mchCatgory) {
|
||||
LambdaQueryWrapper<MchCatgoryEntity> wrapper = new LambdaQueryWrapper<MchCatgoryEntity>()
|
||||
.like(ObjectUtil.isNotEmpty(mchCatgory.getName()), MchCatgoryEntity::getName, mchCatgory.getName())
|
||||
.orderByDesc(MchCatgoryEntity::getCreateTime)
|
||||
.orderByDesc(MchCatgoryEntity::getId);
|
||||
return R.ok(mchCatgoryService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_view')")
|
||||
public R getMchCatgoryPage(@ParameterObject Page page, @ParameterObject MchCatgoryEntity mchCatgory) {
|
||||
LambdaQueryWrapper<MchCatgoryEntity> wrapper = new LambdaQueryWrapper<MchCatgoryEntity>()
|
||||
.like(ObjectUtil.isNotEmpty(mchCatgory.getName()), MchCatgoryEntity::getName, mchCatgory.getName())
|
||||
.orderByDesc(MchCatgoryEntity::getCreateTime)
|
||||
.orderByDesc(MchCatgoryEntity::getId);
|
||||
return R.ok(mchCatgoryService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(mchCatgoryService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增商户分类", description = "新增商户分类")
|
||||
@SysLog("新增商户分类")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_add')")
|
||||
public R save(@RequestBody MchCatgoryEntity dto) {
|
||||
return R.ok(mchCatgoryService.create(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改商户分类", description = "修改商户分类")
|
||||
@SysLog("修改商户分类")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_edit')")
|
||||
public R updateById(@RequestBody MchCatgoryEntity dto) {
|
||||
return R.ok(mchCatgoryService.edit(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除商户分类", description = "通过id删除商户分类")
|
||||
@SysLog("通过id删除商户分类")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(mchCatgoryService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('waller_mchCatgory_export')")
|
||||
public List<MchCatgoryEntity> export(MchCatgoryEntity mchCatgory, Long[] ids) {
|
||||
return mchCatgoryService.list(Wrappers.lambdaQuery(mchCatgory).in(ArrayUtil.isNotEmpty(ids), MchCatgoryEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.wallet.mapper.mch;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchCatgoryEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MchCatgoryMapper extends PjcloudBaseMapper<MchCatgoryEntity> {
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchCatgoryEntity;
|
||||
|
||||
public interface MchCatgoryService extends IService<MchCatgoryEntity> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
Long create(MchCatgoryEntity dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
Long edit(MchCatgoryEntity dto);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.mch;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchCatgoryEntity;
|
||||
import com.bsd.pjcloud.wallet.mapper.mch.MchCatgoryMapper;
|
||||
import com.bsd.pjcloud.wallet.service.MchCatgoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 商户分类
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MchCatgoryServiceImpl extends ServiceImpl<MchCatgoryMapper, MchCatgoryEntity> implements MchCatgoryService {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Override
|
||||
public Long create(MchCatgoryEntity dto) {
|
||||
if (existName(dto)) throw new RuntimeException("分类名不能重复");
|
||||
baseMapper.insert(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
@Override
|
||||
public Long edit(MchCatgoryEntity dto) {
|
||||
if (existName(dto)) throw new RuntimeException("分类名不能重复");
|
||||
baseMapper.updateById(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断分类名是否重复
|
||||
*/
|
||||
private boolean existName(MchCatgoryEntity dto) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchCatgoryEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getName()), MchCatgoryEntity::getName, dto.getName())
|
||||
.ne(ObjectUtil.isNotEmpty(dto.getId()), MchCatgoryEntity::getId, dto.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
return count >= 1;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.wallet.mapper.mch.MchCatgoryMapper">
|
||||
|
||||
<resultMap id="mchCatgoryMap" type="com.bsd.pjcloud.wallet.api.entity.mch.MchCatgoryEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<result property="sort" column="sort"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user