一 点睛

通过人人开源快速生成基本的前后端代码,以满足基本的增删改查,然后根据实际业务,去修改前面生成的基本代码,以满足实际业务需求。

二 依赖表的结构

/*表: pms_brand*/------------------/*列信息*/-----------Field         Type           Collation           Null    Key     Default  Extra           Privileges                       Comment
------------  -------------  ------------------  ------  ------  -------  --------------  -------------------------------  --------------------------------------
brand_id      bigint(20)     (NULL)              NO      PRI     (NULL)   auto_increment  select,insert,update,references  品牌id
name          char(50)       utf8mb4_general_ci  YES             (NULL)                   select,insert,update,references  品牌名
logo          varchar(2000)  utf8mb4_general_ci  YES             (NULL)                   select,insert,update,references  品牌logo地址
descript      longtext       utf8mb4_general_ci  YES             (NULL)                   select,insert,update,references  介绍
show_status   tinyint(4)     (NULL)              YES             (NULL)                   select,insert,update,references  显示状态[0-不显示;1-显示]
first_letter  char(1)        utf8mb4_general_ci  YES             (NULL)                   select,insert,update,references  检索首字母
sort          int(11)        (NULL)              YES             (NULL)                   select,insert,update,references  排序                                /*索引信息*/--------------Table      Non_unique  Key_name  Seq_in_index  Column_name  Collation  Cardinality  Sub_part  Packed  Null    Index_type  Comment  Index_comment
---------  ----------  --------  ------------  -----------  ---------  -----------  --------  ------  ------  ----------  -------  ---------------
pms_brand           0  PRIMARY              1  brand_id     A                    0    (NULL)  (NULL)          BTREE                               /*DDL 信息*/------------CREATE TABLE `pms_brand` (`brand_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '品牌id',`name` char(50) DEFAULT NULL COMMENT '品牌名',`logo` varchar(2000) DEFAULT NULL COMMENT '品牌logo地址',`descript` longtext COMMENT '介绍',`show_status` tinyint(4) DEFAULT NULL COMMENT '显示状态[0-不显示;1-显示]',`first_letter` char(1) DEFAULT NULL COMMENT '检索首字母',`sort` int(11) DEFAULT NULL COMMENT '排序',PRIMARY KEY (`brand_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='品牌'

三 人人开源相关配置

1 application.yml

server:port: 80# mysql
spring:datasource:type: com.alibaba.druid.pool.DruidDataSource#MySQL配置driverClassName: com.mysql.jdbc.Driver# 修改数据库的URLurl: jdbc:mysql://192.168.0.110:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false# 修改数据库的用户名username: root# 修改数据库的密码password: root#oracle配置#    driverClassName: oracle.jdbc.OracleDriver#    url: jdbc:oracle:thin:@47.100.206.162:1521:xe#    username: renren#    password: 123456#SQLServer配置#    driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver#    url: jdbc:sqlserver://192.168.10.10:1433;DatabaseName=renren_fast#    username: sa#    password: 123456#PostgreSQL配置#    driverClassName: org.postgresql.Driver#    url: jdbc:postgresql://192.168.10.10:5432/renren_fast#    username: postgres#    password: 123456jackson:time-zone: GMT+8date-format: yyyy-MM-dd HH:mm:ssresources:static-locations: classpath:/static/,classpath:/views/mybatis:mapperLocations: classpath:mapper/**/*.xmlpagehelper:reasonable: truesupportMethodsArguments: trueparams: count=countSql#指定数据库,可选值有【mysql、oracle、sqlserver、postgresql】
renren:database: mysql

2 generator.properties

# 代码生成器,配置信息
# 主目录格式: com + 组织名
mainPath=com.atguigu
# 包名格式: com + 组织名 + 项目名
package=com.atguigu.gulimall
# 模块名
moduleName=product
# 作者
author=cakin
# Email
email=798103175@qq.com
# 表前缀:类名不会包含表前缀
tablePrefix=pms_# 类型转换的配置信息,这部分内容固定
tinyint=Integer
smallint=Integer
mediumint=Integer
int=Integer
integer=Integer
bigint=Long
float=Float
double=Double
decimal=BigDecimal
bit=Booleanchar=String
varchar=String
tinytext=String
text=String
mediumtext=String
longtext=Stringdate=Date
datetime=Date
timestamp=DateNUMBER=Integer
INT=Integer
INTEGER=Integer
BINARY_INTEGER=Integer
LONG=String
FLOAT=Float
BINARY_FLOAT=Float
DOUBLE=Double
BINARY_DOUBLE=Double
DECIMAL=BigDecimal
CHAR=String
VARCHAR=String
VARCHAR2=String
NVARCHAR=String
NVARCHAR2=String
CLOB=String
BLOB=String
DATE=Date
DATETIME=Date
TIMESTAMP=Date
TIMESTAMP(6)=Dateint8=Long
int4=Integer
int2=Integer
numeric=BigDecimal

四 生成的前端代码

1 brand.vue

<template><div class="mod-config"><el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"><el-form-item><el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input></el-form-item><el-form-item><el-button @click="getDataList()">查询</el-button><el-button v-if="isAuth('product:brand:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button><el-button v-if="isAuth('product:brand:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button></el-form-item></el-form><el-table:data="dataList"borderv-loading="dataListLoading"@selection-change="selectionChangeHandle"style="width: 100%;"><el-table-columntype="selection"header-align="center"align="center"width="50"></el-table-column><el-table-columnprop="brandId"header-align="center"align="center"label="品牌id"></el-table-column><el-table-columnprop="name"header-align="center"align="center"label="品牌名"></el-table-column><el-table-columnprop="logo"header-align="center"align="center"label="品牌logo地址"></el-table-column><el-table-columnprop="descript"header-align="center"align="center"label="介绍"></el-table-column><el-table-columnprop="showStatus"header-align="center"align="center"label="显示状态[0-不显示;1-显示]"></el-table-column><el-table-columnprop="firstLetter"header-align="center"align="center"label="检索首字母"></el-table-column><el-table-columnprop="sort"header-align="center"align="center"label="排序"></el-table-column><el-table-columnfixed="right"header-align="center"align="center"width="150"label="操作"><template slot-scope="scope"><el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.brandId)">修改</el-button><el-button type="text" size="small" @click="deleteHandle(scope.row.brandId)">删除</el-button></template></el-table-column></el-table><el-pagination@size-change="sizeChangeHandle"@current-change="currentChangeHandle":current-page="pageIndex":page-sizes="[10, 20, 50, 100]":page-size="pageSize":total="totalPage"layout="total, sizes, prev, pager, next, jumper"></el-pagination><!-- 弹窗, 新增 / 修改 --><add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update></div>
</template><script>import AddOrUpdate from './brand-add-or-update'export default {data () {return {dataForm: {key: ''},dataList: [],pageIndex: 1,pageSize: 10,totalPage: 0,dataListLoading: false,dataListSelections: [],addOrUpdateVisible: false}},components: {AddOrUpdate},activated () {this.getDataList()},methods: {// 获取数据列表getDataList () {this.dataListLoading = truethis.$http({url: this.$http.adornUrl('/product/brand/list'),method: 'get',params: this.$http.adornParams({'page': this.pageIndex,'limit': this.pageSize,'key': this.dataForm.key})}).then(({data}) => {if (data && data.code === 0) {this.dataList = data.page.listthis.totalPage = data.page.totalCount} else {this.dataList = []this.totalPage = 0}this.dataListLoading = false})},// 每页数sizeChangeHandle (val) {this.pageSize = valthis.pageIndex = 1this.getDataList()},// 当前页currentChangeHandle (val) {this.pageIndex = valthis.getDataList()},// 多选selectionChangeHandle (val) {this.dataListSelections = val},// 新增 / 修改addOrUpdateHandle (id) {this.addOrUpdateVisible = truethis.$nextTick(() => {this.$refs.addOrUpdate.init(id)})},// 删除deleteHandle (id) {var ids = id ? [id] : this.dataListSelections.map(item => {return item.brandId})this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {this.$http({url: this.$http.adornUrl('/product/brand/delete'),method: 'post',data: this.$http.adornData(ids, false)}).then(({data}) => {if (data && data.code === 0) {this.$message({message: '操作成功',type: 'success',duration: 1500,onClose: () => {this.getDataList()}})} else {this.$message.error(data.msg)}})})}}}
</script>

2 brand-add-or-update.vue

<template><el-dialog:title="!dataForm.id ? '新增' : '修改'":close-on-click-modal="false":visible.sync="visible"><el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"><el-form-item label="品牌名" prop="name"><el-input v-model="dataForm.name" placeholder="品牌名"></el-input></el-form-item><el-form-item label="品牌logo地址" prop="logo"><el-input v-model="dataForm.logo" placeholder="品牌logo地址"></el-input></el-form-item><el-form-item label="介绍" prop="descript"><el-input v-model="dataForm.descript" placeholder="介绍"></el-input></el-form-item><el-form-item label="显示状态[0-不显示;1-显示]" prop="showStatus"><el-input v-model="dataForm.showStatus" placeholder="显示状态[0-不显示;1-显示]"></el-input></el-form-item><el-form-item label="检索首字母" prop="firstLetter"><el-input v-model="dataForm.firstLetter" placeholder="检索首字母"></el-input></el-form-item><el-form-item label="排序" prop="sort"><el-input v-model="dataForm.sort" placeholder="排序"></el-input></el-form-item></el-form><span slot="footer" class="dialog-footer"><el-button @click="visible = false">取消</el-button><el-button type="primary" @click="dataFormSubmit()">确定</el-button></span></el-dialog>
</template><script>export default {data () {return {visible: false,dataForm: {brandId: 0,name: '',logo: '',descript: '',showStatus: '',firstLetter: '',sort: ''},dataRule: {name: [{ required: true, message: '品牌名不能为空', trigger: 'blur' }],logo: [{ required: true, message: '品牌logo地址不能为空', trigger: 'blur' }],descript: [{ required: true, message: '介绍不能为空', trigger: 'blur' }],showStatus: [{ required: true, message: '显示状态[0-不显示;1-显示]不能为空', trigger: 'blur' }],firstLetter: [{ required: true, message: '检索首字母不能为空', trigger: 'blur' }],sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]}}},methods: {init (id) {this.dataForm.brandId = id || 0this.visible = truethis.$nextTick(() => {this.$refs['dataForm'].resetFields()if (this.dataForm.brandId) {this.$http({url: this.$http.adornUrl(`/product/brand/info/${this.dataForm.brandId}`),method: 'get',params: this.$http.adornParams()}).then(({data}) => {if (data && data.code === 0) {this.dataForm.name = data.brand.namethis.dataForm.logo = data.brand.logothis.dataForm.descript = data.brand.descriptthis.dataForm.showStatus = data.brand.showStatusthis.dataForm.firstLetter = data.brand.firstLetterthis.dataForm.sort = data.brand.sort}})}})},// 表单提交dataFormSubmit () {this.$refs['dataForm'].validate((valid) => {if (valid) {this.$http({url: this.$http.adornUrl(`/product/brand/${!this.dataForm.brandId ? 'save' : 'update'}`),method: 'post',data: this.$http.adornData({'brandId': this.dataForm.brandId || undefined,'name': this.dataForm.name,'logo': this.dataForm.logo,'descript': this.dataForm.descript,'showStatus': this.dataForm.showStatus,'firstLetter': this.dataForm.firstLetter,'sort': this.dataForm.sort})}).then(({data}) => {if (data && data.code === 0) {this.$message({message: '操作成功',type: 'success',duration: 1500,onClose: () => {this.visible = falsethis.$emit('refreshDataList')}})} else {this.$message.error(data.msg)}})}})}}}
</script>

五 生成后端代码

1 BrandController.java

package com.atguigu.gulimall.product.controller;import java.util.Arrays;
import java.util.Map;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import com.atguigu.gulimall.product.entity.BrandEntity;
import com.atguigu.gulimall.product.service.BrandService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;/**
* 品牌
*
* @author cakin
* @email 798103175@qq.com
* @date 2020-10-27 20:19:10
*/
@RestController
@RequestMapping("product/brand")
public class BrandController {@Autowiredprivate BrandService brandService;/*** 列表*/@RequestMapping("/list")//@RequiresPermissions("product:brand:list")public R list(@RequestParam Map<String, Object> params){PageUtils page = brandService.queryPage(params);return R.ok().put("page", page);}/*** 信息*/@RequestMapping("/info/{brandId}")//@RequiresPermissions("product:brand:info")public R info(@PathVariable("brandId") Long brandId){BrandEntity brand = brandService.getById(brandId);return R.ok().put("brand", brand);}/*** 保存*/@RequestMapping("/save")//@RequiresPermissions("product:brand:save")public R save(@RequestBody BrandEntity brand){brandService.save(brand);return R.ok();}/*** 修改*/@RequestMapping("/update")//@RequiresPermissions("product:brand:update")public R update(@RequestBody BrandEntity brand){brandService.updateById(brand);return R.ok();}/*** 删除*/@RequestMapping("/delete")//@RequiresPermissions("product:brand:delete")public R delete(@RequestBody Long[] brandIds){brandService.removeByIds(Arrays.asList(brandIds));return R.ok();}
}

2 BrandDao.java

package com.atguigu.gulimall.product.dao;import com.atguigu.gulimall.product.entity.BrandEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;/**
* 品牌
*
* @author cakin
* @email 798103175@qq.com
* @date 2020-10-27 20:19:10
*/
@Mapper
public interface BrandDao extends BaseMapper<BrandEntity> {
}

3 BrandEntity.java

package com.atguigu.gulimall.product.entity;import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;import java.io.Serializable;
import java.util.Date;
import lombok.Data;/**
* 品牌
*
* @author cakin
* @email 798103175@qq.com
* @date 2020-10-27 20:19:10
*/
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {private static final long serialVersionUID = 1L;/*** 品牌id*/@TableIdprivate Long brandId;/*** 品牌名*/private String name;/*** 品牌logo地址*/private String logo;/*** 介绍*/private String descript;/*** 显示状态[0-不显示;1-显示]*/private Integer showStatus;/*** 检索首字母*/private String firstLetter;/*** 排序*/private Integer sort;
}

4 BrandServiceImpl.java

package com.atguigu.gulimall.product.service.impl;import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;import com.atguigu.gulimall.product.dao.BrandDao;
import com.atguigu.gulimall.product.entity.BrandEntity;
import com.atguigu.gulimall.product.service.BrandService;@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {@Overridepublic PageUtils queryPage(Map<String, Object> params) {IPage<BrandEntity> page = this.page(new Query<BrandEntity>().getPage(params),new QueryWrapper<BrandEntity>());return new PageUtils(page);}
}

人人开源代码快速生成品牌管理的前后端基本代码相关推荐

  1. python︱写markdown一样写网页,代码快速生成web工具:streamlit 数据探索案例(六)

    系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...

  2. python︱写markdown一样写网页,代码快速生成web工具:streamlit 缓存(五)

    系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...

  3. python︱写markdown一样写网页,代码快速生成web工具:streamlit lay-out布局(四)

    文章目录 1 `streamlit.beta_container()` 2 分列展示 3 按照比例分列展示 4 折叠/展开 系列参考: python︱写markdown一样写网页,代码快速生成web工 ...

  4. python︱写markdown一样写网页,代码快速生成web工具:streamlit 展示组件(三)

    系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...

  5. python︱写markdown一样写网页,代码快速生成web工具:streamlit 重要组件介绍(二)

    python︱写markdown一样写网页,代码快速生成web工具:streamlit(一) 上篇主要是steamlit的介绍以及streamlit的一些初始化,这篇是一些组件的介绍,当然风格是直接上 ...

  6. 短网址、综合短网址、PT短网址生成源代码,含前后端源代码,做一个自己的短链生成网站

    短网址.综合短网址.PT短网址生成源代码,含前后端源代码,做一个自己的短链生成网站 安装步骤 直接上传到你的空间即可,要求php环境 添加接口 index.html中,添加网址单选 api.php中, ...

  7. 使用人人开源的代码生成器生成开发代码

    renren-generator是人人开源项目的代码生成器,可在线生成entity.xml.dao.service.html.js.sql代码,减少70%以上的开发任务 前提是:需要数据库中存在数据表 ...

  8. 用rapid-framework开源工具快速生成SSH的网站框架MVC模式

    使用开源工具rapid-framework快速搭建ssh项目框架 环境 IDE:myeclipse 8.5 详细搭建过程: 一:打开myeclipse 8.5新建一个web工程,取名web_frame ...

  9. WebRose-低代码PaaS平台的新流派,前后端都可直接在线极简式编码

    文章目录 前言 一.WebRose具体如何在线开发? 二.前端JS编码 1.创建前端组件的方法 2.操作前端组件方法 3.动态创建布局 4.与其他平台集成 5.前端跳转新页面 6.调用后端微服务Jav ...

最新文章

  1. Eclipse无法识别(手机)设备的解决方案
  2. 错误:'sys'未定义解决方法.(asp.net Ajax v1.0.61025版)
  3. 一种以动态库的方式使用资源表的方案
  4. java面向对象编程集合边框_java 面向对象编程-- 第15章 集合框架
  5. Angular单元测试的一个错误消息
  6. .NET Core微服务之服务间的调用方式(REST and RPC)
  7. python找不到csv文件_Python如何读取csv文件
  8. git撤销git commit
  9. 实战HTML5与CSS3 第一篇】初探水深,美丽的导航,绚丽的图片爆炸!!
  10. fsck 修复文件系统_微软推出Win10 20H2 Build 19042.608测试版 修复多种已知错误
  11. C语言 mallocfree
  12. php实现开关效果代码,JavaScript实现开关效果的代码分享
  13. windows netcat的安装与使用
  14. STM32固件库的安装
  15. 出行即服务(MAAS)框架
  16. 受益匪浅!Spring事务是如何传播的附架构师必备技术详解
  17. Python办公——三行代码拆分表格
  18. Lua中保留两位小数
  19. 悬浮View,可拖动,放手后自动吸附到屏幕边上。
  20. IE11中图片无法显示(完美解决)

热门文章

  1. 27、用户操作srv、web服务实现
  2. android电池管理系统
  3. 系统之家快速装机光盘 Ver.0803 (IE7+WMP11)
  4. Trust Nobody
  5. TCP面向连接中的“连接”究竟是什么,可靠与不可靠
  6. 学习日记day28 平面设计 构图
  7. Java 按顺序输入正方形的边长(a),长方形的长(l)和宽(d),以及圆的半径(r),计算并比较它们哪个图形面积更大,输出面积最大的图形
  8. nfc模块pn7150移植说明教程(android mtk rk3399 rk3588)
  9. [nRF51822] 15、穿戴式设备上电量检测装置的设计及细节技术点(偏专业硬件文章)...
  10. Servlet笔记十(文件上传和下载)