Guns学习记录

Guns笔记

Guns笔记

操作流程

  • 1.下载guns源码包

版本名称 说明 地址
Guns v6.0 最新开源版本,采用layui https://gitee.com/stylefeng/guns
Guns v5.1 Guns经典版的最新版,采用bootstrap 3 https://gitee.com/stylefeng/guns/tree/v5.1-final
  • 2.idea打开项目

  • 3.修改application.yml内数据库(端口、账号、密码)配置

  • 4.启动项目Gunsapplication

代码生成

  • 1.创建数据库

CREATE TABLE `yg_xinxibiao` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '员工ID',
`yg_Name` varchar(255) DEFAULT NULL COMMENT '员工姓名',
`yg_Sex` varchar(255) DEFAULT NULL COMMENT '员工性别',
`yg_TelPhone` int(11) DEFAULT NULL COMMENT '员工电话',
`yg_tianjiar` varchar(255) DEFAULT NULL COMMENT '添加人',
`yg_updatatime` datetime DEFAULT NULL COMMENT '添加更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='员工管理';
 
- 主键ID (错误示例 yg_id 正确:id)勾选自增
- 添加数据表注释
  • 2.进入 lcoalhost:8080选择 代码生成菜单,选择数据表内数据库生成的数据,选择右侧模板全部点击,更改业务名称、表前缀,父级菜单名称选择顶级,点击生成

  • 3.进入后台,点击生成的SQL文件,更改id为菜单后数字,执行!

搜索代码Controller(value = “/list”)

public Object list(String condition) {
Wrapper<Controller功能模块名> wrapper=new EntityWrapper<>();
wrapper.like("name",condition);//模糊查询(搜索文字) eq 精准查询(搜索数字)
return Controller功能模块名 .selectList(wrapper);
}

增加Controller(value = “/add”)

时间:(ps : html时间的标签要去掉)

方法名.setTime(new Data());

更新Controller(value = “/update”)

有时间就加代码,没有不加

方法名.setTime(new Data());

选择下拉列表select.tag

<div class="form-group">
<label class="col-sm-3 control-label">${name}</label>
<div class="col-sm-9">
<select class="form-control" id="${id}" name="${id}">
<option value="">请选择</option>
${tagBody!}
</select>
@if(isNotEmpty(hidden)){
<input class="form-control" type="hidden" id="${hidden}" value="${hiddenValue!}">
@}
</div>
</div>

显示页面(重置)

HTML
<#button name="重置" icon="fa-trash" clickFun="方法名.resetSearch()" space="true"/>
 
 
JS
/**
* 重置线上本周推荐列表
*/
方法名.resetSearch = function () {
$("#condition").val("");
方法名.search();
};

js
{title: ‘线上课程本周推荐管理主键’, field: ‘id’, visible: false, align: ‘center’, valign: ‘middle’},

html的add页面要删掉
<!–<#input id=”id” name=”线上课程本周推荐管理主键” underline=”true”/>

列表调用

@Autowired
private IJingxiasService jingxiasService;
 
/**
* 跳转到添加员工管理
*/
@RequestMapping("/xinxibiao_add")
public String xinxibiaoAdd() {
Wrapper<Jingxias> wrapper=new EntityWrapper<>();
List<Jingxias> jingxias=jingxiasService.selectList(wrapper);
super.setAttr("jingxias",jingxias);
return PREFIX + "xinxibiao_add.html";
}
 
 
 
HTML
<#select id="ygCereateName" name="添加人" underline="true"> //id="ygCereateName" 主体model模块
@for(jingxia in jingxias){ //要调用controller
<option value="${jingxia.jxName}">${jingxia.jxName} ${jingxia.jxTelphone} ${jingxia.jxDizhi}</option> //{jingxia.jxName}前面的controller.要调用的model列表名称
@}
</#select>

API

/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.modular.api;
 
import cn.stylefeng.guns.modular.system.model.*;
import cn.stylefeng.guns.modular.system.service.IJingxiasService;//更改
import cn.stylefeng.guns.modular.system.service.impl.JingxiasServiceImpl;//更改
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
* 接口控制器提供
*
* @author stylefeng
* @Date 2018/7/20 23:39
*/
RestController
RequestMapping("/api")
Api(tags = "。。。管理")//更改(API标题)
public class jingxiasAPI extends BaseController { /**根据Contriller修改**/
@Autowired //自动装配
private IJingxiasService jingxiasService;
//service包内文件
 
/**
* 根据。。。ID获取。。。基本信息
*/
@ApiOperation(value="根据。。。ID获取。。。基本信息",notes="根据。。。ID获取。。。基本信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "方法名Id",value = "内容ID",dataTypeClass = Integer.class,required = true)
})
@Transactional
@RequestMapping(value = "方法名Id",method = RequestMethod.POST)
public Object get方法名Id(@RequestParam("方法名Id") Integer 方法名Id) {
Jingxias jingxias = jingxiasService.selectById(方法名Id);
if(ToolUtil.isNotEmpty(jingxias)){
return new ResponseData(true,200,"获取成功",方法名);
}else{
return new ResponseData(true,200,"没有对应的经销商",null);
}
}
 
}

posted on 2020-06-05 16:17  沐軒  阅读(376)  评论(0)    收藏  举报