jiangping
2023-10-07 7ed6c5a40c669a1b4dffcb3dca25bffebce16dcf
baseParam代码
已添加6个文件
423 ■■■■■ 文件已修改
server/platform/src/main/java/com/doumee/api/business/BaseParamController.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/db/business.base_param.permissions.sql 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/dao/business/BaseParamMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/dao/business/model/BaseParam.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/service/business/BaseParamService.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/platform/src/main/java/com/doumee/api/business/BaseParamController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,90 @@
package com.doumee.api.business;
import com.doumee.api.BaseController;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.dao.business.model.BaseParam;
import com.doumee.service.business.BaseParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author æ±Ÿè¹„蹄
 * @date 2023/10/07 15:19
 */
@Api(tags = "系统基础配置表")
@RestController
@RequestMapping("/business/baseParam")
public class BaseParamController extends BaseController {
    @Autowired
    private BaseParamService baseParamService;
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("business:baseparam:create")
    public ApiResponse create(@RequestBody BaseParam baseParam) {
        return ApiResponse.success(baseParamService.create(baseParam));
    }
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:baseparam:delete")
    public ApiResponse deleteById(@PathVariable String id) {
        baseParamService.deleteById(id);
        return ApiResponse.success(null);
    }
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:baseparam:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<String> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(id);
        }
        baseParamService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:baseparam:update")
    public ApiResponse updateById(@RequestBody BaseParam baseParam) {
        baseParamService.updateById(baseParam);
        return ApiResponse.success(null);
    }
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("business:baseparam:query")
    public ApiResponse<PageData<BaseParam>> findPage (@RequestBody PageWrap<BaseParam> pageWrap) {
        return ApiResponse.success(baseParamService.findPage(pageWrap));
    }
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:baseparam:exportExcel")
    public void exportExcel (@RequestBody PageWrap<BaseParam> pageWrap, HttpServletResponse response) {
        ExcelExporter.build(BaseParam.class).export(baseParamService.findPage(pageWrap).getRecords(), "系统基础配置表", response);
    }
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:baseparam:query")
    public ApiResponse findById(@PathVariable String id) {
        return ApiResponse.success(baseParamService.findById(id));
    }
}
server/services/db/business.base_param.permissions.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:create', '新建系统基础配置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0);
INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:delete', '删除系统基础配置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0);
INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:update', '修改系统基础配置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0);
INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:query', '查询系统基础配置表', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0);
INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:baseparam:exportExcel', '导出系统基础配置表(Excel)', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0);
server/services/src/main/java/com/doumee/dao/business/BaseParamMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.doumee.dao.business;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doumee.dao.business.model.BaseParam;
/**
 * @author æ±Ÿè¹„蹄
 * @date 2023/10/07 15:19
 */
public interface BaseParamMapper extends BaseMapper<BaseParam> {
}
server/services/src/main/java/com/doumee/dao/business/model/BaseParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
package com.doumee.dao.business.model;
import com.doumee.core.annotation.excel.ExcelColumn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * ç³»ç»ŸåŸºç¡€é…ç½®è¡¨
 * @author æ±Ÿè¹„蹄
 * @date 2023/10/07 15:19
 */
@Data
@ApiModel("系统基础配置表")
@TableName("`base_param`")
public class BaseParam {
    @ApiModelProperty(value = "编码")
    @ExcelColumn(name="编码")
    private String id;
    @ApiModelProperty(value = "创建时间")
    @ExcelColumn(name="创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createDate;
    @ApiModelProperty(value = "创建人")
    @ExcelColumn(name="创建人")
    private String creator;
    @ApiModelProperty(value = "编辑时间")
    @ExcelColumn(name="编辑时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date editDate;
    @ApiModelProperty(value = "编辑人")
    @ExcelColumn(name="编辑人")
    private String editor;
    @ApiModelProperty(value = "是否已删除 0未删除 1已删除", example = "1")
    @ExcelColumn(name="是否已删除 0未删除 1已删除")
    private Integer isdeleted;
    @ApiModelProperty(value = "名称")
    @ExcelColumn(name="名称")
    private String name;
    @ApiModelProperty(value = "排序码(升序)", example = "1")
    @ExcelColumn(name="排序码(升序)")
    private Integer sortnum;
    @ApiModelProperty(value = "类型 0车辆保修原因 1强制还车原因 2时长减免原因 3单车类型", example = "1")
    @ExcelColumn(name="类型 0车辆保修原因 1强制还车原因 2时长减免原因 3单车类型")
    private Integer type;
    @ApiModelProperty(value = "状态 0启用 1禁用", example = "1")
    @ExcelColumn(name="状态 0启用 1禁用")
    private Integer status;
    @ApiModelProperty(value = "备注")
    @ExcelColumn(name="备注")
    private String info;
    @ApiModelProperty(value = "备注是否必填 0否 1是", example = "1")
    @ExcelColumn(name="备注是否必填 0否 1是")
    private Integer required;
}
server/services/src/main/java/com/doumee/service/business/BaseParamService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,97 @@
package com.doumee.service.business;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.BaseParam;
import java.util.List;
/**
 * ç³»ç»ŸåŸºç¡€é…ç½®è¡¨Service定义
 * @author æ±Ÿè¹„蹄
 * @date 2023/10/07 15:19
 */
public interface BaseParamService {
    /**
     * åˆ›å»º
     *
     * @param baseParam å®žä½“对象
     * @return String
     */
    String create(BaseParam baseParam);
    /**
     * ä¸»é”®åˆ é™¤
     *
     * @param id ä¸»é”®
     */
    void deleteById(String id);
    /**
     * åˆ é™¤
     *
     * @param baseParam å®žä½“对象
     */
    void delete(BaseParam baseParam);
    /**
     * æ‰¹é‡ä¸»é”®åˆ é™¤
     *
     * @param ids ä¸»é”®é›†
     */
    void deleteByIdInBatch(List<String> ids);
    /**
     * ä¸»é”®æ›´æ–°
     *
     * @param baseParam å®žä½“对象
     */
    void updateById(BaseParam baseParam);
    /**
     * æ‰¹é‡ä¸»é”®æ›´æ–°
     *
     * @param baseParams å®žä½“集
     */
    void updateByIdInBatch(List<BaseParam> baseParams);
    /**
     * ä¸»é”®æŸ¥è¯¢
     *
     * @param id ä¸»é”®
     * @return BaseParam
     */
    BaseParam findById(String id);
    /**
     * æ¡ä»¶æŸ¥è¯¢å•条记录
     *
     * @param baseParam å®žä½“对象
     * @return BaseParam
     */
    BaseParam findOne(BaseParam baseParam);
    /**
     * æ¡ä»¶æŸ¥è¯¢
     *
     * @param baseParam å®žä½“对象
     * @return List<BaseParam>
     */
    List<BaseParam> findList(BaseParam baseParam);
    /**
     * åˆ†é¡µæŸ¥è¯¢
     *
     * @param pageWrap åˆ†é¡µå¯¹è±¡
     * @return PageData<BaseParam>
     */
    PageData<BaseParam> findPage(PageWrap<BaseParam> pageWrap);
    /**
     * æ¡ä»¶ç»Ÿè®¡
     *
     * @param baseParam å®žä½“对象
     * @return long
     */
    long count(BaseParam baseParam);
}
server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,145 @@
package com.doumee.service.business.impl;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.BaseParamMapper;
import com.doumee.dao.business.model.BaseParam;
import com.doumee.service.business.BaseParamService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
 * ç³»ç»ŸåŸºç¡€é…ç½®è¡¨Service实现
 * @author æ±Ÿè¹„蹄
 * @date 2023/10/07 15:19
 */
@Service
public class BaseParamServiceImpl implements BaseParamService {
    @Autowired
    private BaseParamMapper baseParamMapper;
    @Override
    public String create(BaseParam baseParam) {
        baseParamMapper.insert(baseParam);
        return baseParam.getId();
    }
    @Override
    public void deleteById(String id) {
        baseParamMapper.deleteById(id);
    }
    @Override
    public void delete(BaseParam baseParam) {
        UpdateWrapper<BaseParam> deleteWrapper = new UpdateWrapper<>(baseParam);
        baseParamMapper.delete(deleteWrapper);
    }
    @Override
    public void deleteByIdInBatch(List<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
        baseParamMapper.deleteBatchIds(ids);
    }
    @Override
    public void updateById(BaseParam baseParam) {
        baseParamMapper.updateById(baseParam);
    }
    @Override
    public void updateByIdInBatch(List<BaseParam> baseParams) {
        if (CollectionUtils.isEmpty(baseParams)) {
            return;
        }
        for (BaseParam baseParam: baseParams) {
            this.updateById(baseParam);
        }
    }
    @Override
    public BaseParam findById(String id) {
        return baseParamMapper.selectById(id);
    }
    @Override
    public BaseParam findOne(BaseParam baseParam) {
        QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam);
        return baseParamMapper.selectOne(wrapper);
    }
    @Override
    public List<BaseParam> findList(BaseParam baseParam) {
        QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam);
        return baseParamMapper.selectList(wrapper);
    }
    @Override
    public PageData<BaseParam> findPage(PageWrap<BaseParam> pageWrap) {
        IPage<BaseParam> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        QueryWrapper<BaseParam> queryWrapper = new QueryWrapper<>();
        Utils.MP.blankToNull(pageWrap.getModel());
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.lambda().eq(BaseParam::getId, pageWrap.getModel().getId());
        }
        if (pageWrap.getModel().getCreateDate() != null) {
            queryWrapper.lambda().ge(BaseParam::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
            queryWrapper.lambda().le(BaseParam::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
        }
        if (pageWrap.getModel().getCreator() != null) {
            queryWrapper.lambda().eq(BaseParam::getCreator, pageWrap.getModel().getCreator());
        }
        if (pageWrap.getModel().getEditDate() != null) {
            queryWrapper.lambda().ge(BaseParam::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
            queryWrapper.lambda().le(BaseParam::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
        }
        if (pageWrap.getModel().getEditor() != null) {
            queryWrapper.lambda().eq(BaseParam::getEditor, pageWrap.getModel().getEditor());
        }
        if (pageWrap.getModel().getIsdeleted() != null) {
            queryWrapper.lambda().eq(BaseParam::getIsdeleted, pageWrap.getModel().getIsdeleted());
        }
        if (pageWrap.getModel().getName() != null) {
            queryWrapper.lambda().eq(BaseParam::getName, pageWrap.getModel().getName());
        }
        if (pageWrap.getModel().getSortnum() != null) {
            queryWrapper.lambda().eq(BaseParam::getSortnum, pageWrap.getModel().getSortnum());
        }
        if (pageWrap.getModel().getType() != null) {
            queryWrapper.lambda().eq(BaseParam::getType, pageWrap.getModel().getType());
        }
        if (pageWrap.getModel().getStatus() != null) {
            queryWrapper.lambda().eq(BaseParam::getStatus, pageWrap.getModel().getStatus());
        }
        if (pageWrap.getModel().getInfo() != null) {
            queryWrapper.lambda().eq(BaseParam::getInfo, pageWrap.getModel().getInfo());
        }
        if (pageWrap.getModel().getRequired() != null) {
            queryWrapper.lambda().eq(BaseParam::getRequired, pageWrap.getModel().getRequired());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        return PageData.from(baseParamMapper.selectPage(page, queryWrapper));
    }
    @Override
    public long count(BaseParam baseParam) {
        QueryWrapper<BaseParam> wrapper = new QueryWrapper<>(baseParam);
        return baseParamMapper.selectCount(wrapper);
    }
}