当前位置:网站首页>If you start from zero according to the frame

If you start from zero according to the frame

2022-04-23 17:14:00 ZHZHK001

1、 matters needing attention :

1、mysql Field name Use all lowercase letters !, Otherwise there will be problems
2、 The project path should preferably be in English , Whether there will be exceptions in Chinese , Not inspected

2、 Premise :

Install well jdk、IDEA, Good configuration MAVEN、tomcat

3、 Deployment project

3.1、 download

Go to Gitee The download page (https://gitee.com/y_project/RuoYi (opens new window)) Download and unzip to the working directory

3.2、 Import

Import to IDEA, menu File -> open, And then choose Unzipped folder , wait for

3.3、 Create database

3.3.1、 Create database

CREATE DATABASE database ry;
Change the encoding specification of the database to UTF-8mb4

CREATE DATABASE `ry` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
-- Don't use the above sentence , Or use utf8mb4 Well 
--2022-1-20 to update 

3.3.2、 Database authorization

to grant authorization , You can't start without authorization

grant all on  database ry.* to ' user '@'localhost' identified by ' password ';;

3.3.3、 Table building, etc

Run two of the projects sql file , Does the order matter? I didn't pay attention to , At present, the following operation sequence
ry_20210924.sql
quartz.sql

3.4 Modify the configuration file

Account number of database 、 password 、 Change login account and password, etc

3.4、 Run the project

Open project run com.ruoyi.RuoYiApplication.java, The following figure shows successful startup .
 Insert picture description here
Enter the web address in the browser :http://localhost/index, Log in items

4、 Project development

4.1 Look up the addition, deletion and modification of single table

Use code generators for development , have already been solved , The details are waiting to be sorted out

4.2 Addition, deletion, modification and query of joint table

The main method is to use views

--  The syntax for creating a view is 
CREATE VIEW   View name  AS  (SELECT sentence )

When linking tables, you can read the notes of the original table , If the annotation is repeated, it can be changed on the interface
It's better not to duplicate the same field results in the linked table
2022-1-21 The query of associated table can be done

4.3 Add buttons to the page 【 Not studied 】

The front end and back end don't know how to modify
Examples are as follows :
Functional requirements :
 Insert picture description here


/** *  Material management Controller * * @author ruoyi * @date 2022-01-19 */
@Controller
@RequestMapping("/system/goods")
public class LcGoodsController extends BaseController
{
    
    private String prefix = "system/goods";

    @Autowired
    private ILcGoodsService lcGoodsService;

    @RequiresPermissions("system:goods:view")
    @GetMapping()
    public String goods()
    {
    
        return prefix + "/goods";
    }

    /** *  Query the material management list  */
    @RequiresPermissions("system:goods:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LcGoods lcGoods)
    {
    
        startPage();
        List<LcGoods> list = lcGoodsService.selectLcGoodsList(lcGoods);
        return getDataTable(list);
    }

    /** *  Export material management list  */
    @RequiresPermissions("system:goods:export")
    @Log(title = " Material management ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LcGoods lcGoods)
    {
    
        List<LcGoods> list = lcGoodsService.selectLcGoodsList(lcGoods);
        ExcelUtil<LcGoods> util = new ExcelUtil<LcGoods>(LcGoods.class);
        return util.exportExcel(list, " Material management data ");
    }

    /** *  Add material management  */
    @GetMapping("/add")
    public String add()
    {
    
        return prefix + "/add";
    }

    /** *  Add / save material management  */
    @RequiresPermissions("system:goods:add")
    @Log(title = " Material management ", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LcGoods lcGoods)
    {
    
        return toAjax(lcGoodsService.insertLcGoods(lcGoods));
    }


    /** *  Copy new material management  todo  Copying new functions is not complete  */
// @RequiresPermissions("system:goods:copyAdd")
// @GetMapping("/copyAdd/{id}")
// public String copyAdd(@PathVariable("id") Integer id, ModelMap mmap)
// {
    
// LcGoods lcGoods = lcGoodsService.selectLcGoodsById(id);
// mmap.put("lcGoods", lcGoods);
// return prefix + "/edit";
// }


    /** *  Add / save material management  todo  Copying new functions is not complete  */
// @RequiresPermissions("system:goods:copyAdd")
// @Log(title = " Copy new material ", businessType = BusinessType.INSERT)
// @PostMapping("/add")
// @ResponseBody
// public AjaxResult copyAddSave(LcGoods lcGoods)
// {
    
// return toAjax(lcGoodsService.insertLcGoods(lcGoods));
// }



    /** *  Modify material management  */
    @RequiresPermissions("system:goods:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
    
        LcGoods lcGoods = lcGoodsService.selectLcGoodsById(id);
        mmap.put("lcGoods", lcGoods);
        return prefix + "/edit";
    }

    /** *  Modify and save material management  */
    @RequiresPermissions("system:goods:edit")
    @Log(title = " Material management ", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LcGoods lcGoods)
    {
    
        return toAjax(lcGoodsService.updateLcGoods(lcGoods));
    }

    /** *  Delete material management  */
    @RequiresPermissions("system:goods:remove")
    @Log(title = " Material management ", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
    
        return toAjax(lcGoodsService.deleteLcGoodsByIds(ids));
    }
}

Front page

     <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:goods:add">
                    <i class="fa fa-plus"></i>  add to 
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:goods:edit">
                    <i class="fa fa-edit"></i>  modify 
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:goods:remove">
                    <i class="fa fa-remove"></i>  Delete 
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.copyAdd()" shiro:hasPermission="system:goods:copyAdd">
                    <i class="fa fa-edit"></i>  Copy new 【 Here is the new 】
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:goods:export">
                    <i class="fa fa-download"></i>  export 
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:goods:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:goods:remove')}]];
        var prefix = ctx + "system/goods";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                createUrl: prefix + "/copyAdd/{id}",【 Here is the new , There is a problem , Need to adjust 】
                exportUrl: prefix + "/export",
                modalName: " Material management ",
                columns: [{

5、 Solutions to common problems

5.1、 How to add a new page

File path
\ruoyi-admin\src\main\resources\templates\system\quotetem*quotetem.html*

ctrl Settings in

Settings in the menu
Menu type : The directory represents his next level is the page
Superior menu : Click the button to select
Menu name : The interface shows
Request roughly :【/system/quotetem】— And xxxxx The content in corresponds to
Open mode :/
Permission means : The function of permission control
 Insert picture description here

5.1、 How to add a new page

6、 Waiting for research

6.1、 Verification code problem

The verification code is not easy to identify with the naked eye , Have not worked out how to change the correct font
If only for internal use , How to remove the verification code , Not studied
At present, the verification code is no longer used , By configuring

6.2、 Remove redundant menus

According to the official website 、 The example demonstrates how to remove undeveloped
 Insert picture description here

6.2、 Setting of drop-down options 、 Button state switching label setting

6.3、 If according to the system home page , How to modify the title and icon of this page

 Insert picture description here

7、 rest

7.1 Beginners add QQ Group : Communicate communication

7.2. Synchronization across computers

7.2.1、 Database synchronization

Use computers together Navicat Sync

Computers are not together

Method 1 【 recommend 】

The backup data
 Insert picture description here
Restore data
 Insert picture description here

Method 2
Backup phase
Backup tables with updated tables sql

Use Navicat Export table data
Merge all sql For a file

Recovery phase
Get the names of all tables

SELECT 

Clear all data in the local table

truncate  surface 1 ;
truncate  surface 2 ;

There is an updated table and the table is rebuilt

Run the combined sql file , Note that sometimes the operation will not succeed

-- Check the amount of data after running 
SELECT 
   TABLE_NAME, DATA_LENGTH, INDEX_LENGTH,( DATA_LENGTH + INDEX_LENGTH ) AS length, 
   TABLE_ROWS,
   concat( round(( DATA_LENGTH + INDEX_LENGTH )/ 1024 / 1024,3),'MB') AS total_size 
FROM
	information_schema.TABLES 
WHERE
	TABLE_SCHEMA = 'ry' 
ORDER BY
	TABLE_ROWS

Method 3 **【 Not yet 】**

7.2.2、 Synchronization of projects

Method 1 、SVN Sync 【 recommend 】
After all, there are only tens of trillion , Free space 100M Enough is enough

Method 2 、 Copy the replacement method 【 Not recommended
If you know what file changes , Need to find the modified file , Find a place , Replace
If you're not sure , The whole project , Reopening is after IDEA Need to reload MAVEN My bag or something , Time consuming

7.2.3、 Change the default number of tables

Global position
\ruoyi-admin\src\main\resources\static\ruoyi\js\ry-ui.js
 Insert picture description here
Single page location

 $(function() {
    
            var options = {
    
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: " material ",
                pageSize: 15, // Change the default number   Add this content manually 
                columns: [{
    
                    checkbox: true
                },
                {
    
                    field: 'id',
                    title: ' Primary key ',
                    visible: false
                },

版权声明
本文为[ZHZHK001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230553251216.html