feat: add charging card management
| New file |
| | |
| | | package com.ruoyi.account.api.dto; |
| | | |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "充电卡分页查询参数") |
| | | public class ChargingCardQueryDTO extends BasePage { |
| | | |
| | | @ApiModelProperty(value = "卡号") |
| | | private String cardNo; |
| | | |
| | | @ApiModelProperty(value = "状态:1启用,2禁用") |
| | | private Integer status; |
| | | } |
| New file |
| | |
| | | package com.ruoyi.account.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @TableName("t_charging_card") |
| | | @ApiModel(value = "充电卡") |
| | | public class TChargingCard implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @ApiModelProperty(value = "主键ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "卡号") |
| | | private String cardNo; |
| | | |
| | | @ApiModelProperty(value = "卡余额") |
| | | private BigDecimal balance; |
| | | |
| | | @ApiModelProperty(value = "状态:1启用,2禁用") |
| | | private Integer status; |
| | | |
| | | @TableLogic |
| | | @ApiModelProperty(value = "删除状态:0正常,2删除") |
| | | private Integer delFlag; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @ApiModelProperty(value = "添加时间") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "添加人ID") |
| | | private Long createBy; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @ApiModelProperty(value = "修改时间") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "修改人ID") |
| | | private Long updateBy; |
| | | } |
| New file |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | import com.ruoyi.account.service.TChargingCardService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @Api(tags = "卡片管理") |
| | | @RestController |
| | | @RequestMapping("/t-charging-card") |
| | | public class TChargingCardController extends BaseController { |
| | | |
| | | @Autowired |
| | | private TChargingCardService chargingCardService; |
| | | |
| | | @ApiOperation(value = "分页查询卡片列表") |
| | | @RequiresPermissions(value = {"/chargingCard/list"}, logical = Logical.OR) |
| | | @PostMapping("/page") |
| | | public R<IPage<TChargingCard>> page(@RequestBody ChargingCardQueryDTO query) { |
| | | return R.ok(chargingCardService.selectCardPage(query)); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.ruoyi.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface TChargingCardMapper extends BaseMapper<TChargingCard> { |
| | | |
| | | IPage<TChargingCard> selectCardPage(Page<TChargingCard> page, |
| | | @Param("query") ChargingCardQueryDTO query); |
| | | } |
| New file |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | |
| | | public interface TChargingCardService extends IService<TChargingCard> { |
| | | |
| | | IPage<TChargingCard> selectCardPage(ChargingCardQueryDTO query); |
| | | } |
| New file |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | import com.ruoyi.account.mapper.TChargingCardMapper; |
| | | import com.ruoyi.account.service.TChargingCardService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class TChargingCardServiceImpl extends ServiceImpl<TChargingCardMapper, TChargingCard> |
| | | implements TChargingCardService { |
| | | |
| | | @Override |
| | | public IPage<TChargingCard> selectCardPage(ChargingCardQueryDTO query) { |
| | | Page<TChargingCard> page = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | return baseMapper.selectCardPage(page, query); |
| | | } |
| | | } |
| New file |
| | |
| | | <?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.ruoyi.account.mapper.TChargingCardMapper"> |
| | | |
| | | <select id="selectCardPage" resultType="com.ruoyi.account.api.model.TChargingCard"> |
| | | SELECT id, |
| | | card_no, |
| | | balance, |
| | | status, |
| | | del_flag, |
| | | create_time, |
| | | create_by, |
| | | update_time, |
| | | update_by |
| | | FROM t_charging_card |
| | | WHERE del_flag = 0 |
| | | <if test="query.cardNo != null and query.cardNo != ''"> |
| | | AND card_no LIKE CONCAT('%', #{query.cardNo}, '%') |
| | | </if> |
| | | <if test="query.status != null"> |
| | | AND status = #{query.status} |
| | | </if> |
| | | ORDER BY create_time DESC, id DESC |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | -- 卡片管理:充电卡业务表、一级菜单、查询权限和超级管理员授权。 |
| | | -- 请使用具备 charging_pile_account、charging_pile_other 库权限的账号执行。 |
| | | |
| | | USE charging_pile_account; |
| | | |
| | | CREATE TABLE IF NOT EXISTS `t_charging_card` ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', |
| | | `card_no` varchar(64) NOT NULL COMMENT '卡号', |
| | | `balance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '卡余额', |
| | | `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态:1启用,2禁用', |
| | | `del_flag` tinyint NOT NULL DEFAULT '0' COMMENT '删除状态:0正常,2删除', |
| | | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间', |
| | | `create_by` bigint DEFAULT NULL COMMENT '添加人ID', |
| | | `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', |
| | | `update_by` bigint DEFAULT NULL COMMENT '修改人ID', |
| | | PRIMARY KEY (`id`), |
| | | UNIQUE KEY `uk_card_no` (`card_no`), |
| | | KEY `idx_status_del_flag` (`status`, `del_flag`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='充电卡'; |
| | | |
| | | USE charging_pile_other; |
| | | |
| | | INSERT INTO sys_menu |
| | | (menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, |
| | | menu_type, visible, status, perms, icon, create_by, create_time, remark) |
| | | SELECT '卡片管理', 0, 10, '/card', 'card', NULL, 1, 0, |
| | | 'C', '0', 0, '/chargingCard/list', 'credit-card', 'admin', NOW(), '卡片管理一级菜单' |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM sys_menu WHERE parent_id = 0 AND path = '/card' |
| | | ); |
| | | |
| | | SET @charging_card_menu_id := ( |
| | | SELECT menu_id |
| | | FROM sys_menu |
| | | WHERE parent_id = 0 AND path = '/card' |
| | | ORDER BY menu_id |
| | | LIMIT 1 |
| | | ); |
| | | |
| | | UPDATE sys_menu |
| | | SET menu_name = '卡片管理', |
| | | parent_id = 0, |
| | | order_num = 10, |
| | | component = 'card', |
| | | menu_type = 'C', |
| | | visible = '0', |
| | | status = 0, |
| | | perms = '/chargingCard/list', |
| | | icon = 'credit-card', |
| | | update_time = NOW(), |
| | | remark = '卡片管理一级菜单' |
| | | WHERE menu_id = @charging_card_menu_id; |
| | | |
| | | INSERT IGNORE INTO sys_role_menu (role_id, menu_id) |
| | | SELECT 1, @charging_card_menu_id |
| | | WHERE @charging_card_menu_id IS NOT NULL; |