Author Archives: Robins

Laravel 8: How to Use command to create custom files

1. First create a command file with the make: command command command

php artisan make:command ServicesCommand

2. A servicescommand file will be generated under app\console\commands

<?php

namespace App\Console\Commands;

use Illuminate\Console\GeneratorCommand;

// GeneratorCommand
class ServicesCommand extends GeneratorCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'make:service'; 

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new service';

    /**
     * The console command type.
     */
    protected $type = 'service'; 


    // The template that the generated file depends on can be set by yourself
    // I put the files here in the same level as the Stubs directory
    protected function getStub()
    {
        return __DIR__.'/Stubs/CreateService.stub';
    }

    // Namespaces to be used in the template
    protected function getDefaultNamespace($rootNamespace)
    {
        return $rootNamespace.'\Services';
    }
}

3. Create stubs\createservice Stub file

<?php

namespace {{ namespace }};

class {{ class }}
{
  // You can add the required code yourself      
}

4. Testing

// Check if the command
php artisan list

// Create Test
php artisan make:service TestService

5. Other

In the lower version, the class needs to be registered in the commands attribute of commands \ kernel.

protected $commands = [
  ServicesCommand::class,      
];

[Solved] Vue Error: Error in render: “TypeError: Cannot read property ‘length‘ of undefined“

Vue reports error in render: “typeerror: cannot read property ‘length’ of undefined“

Reason: there is undefined in the (list) attribute of El table, and all columns can be judged by adding a V-IF

<el-table-column label="数据库" width="500px">
                    <template slot="header">
                      <el-button
                        @click="counterElection('主键', 'sqlOpt')"
                        size="small"
                        type="default"
                        >主键
                      </el-button>
                      <el-button
                        @click="counterElection('非空', 'sqlOpt')"
                        size="small"
                        type="default"
                        >非空
                      </el-button>
                      <el-button
                        @click="counterElection('唯一', 'sqlOpt')"
                        size="small"
                        type="default"
                        >唯一
                      </el-button>
                      <el-button
                        @click="counterElection('索引', 'sqlOpt')"
                        size="small"
                        type="default"
                        >索引
                      </el-button>
                      <el-button
                        @click="counterElection('忽略', 'sqlOpt')"
                        size="small"
                        type="default"
                        >忽略
                      </el-button>
                      <el-button
                        @click="counterElection('自增', 'sqlOpt')"
                        size="small"
                        type="default"
                        >自增
                      </el-button>
                    </template>
                    <template slot-scope="scope">
                      <el-checkbox-group
                        v-if="
                          scope.row !== undefined &&
                          scope.row.sqlOpt !== undefined
                        "
                        v-model="scope.row.sqlOpt"
                      >
                        <el-checkbox label="主键"></el-checkbox>
                        <el-checkbox label="非空"></el-checkbox>
                        <el-checkbox label="唯一"></el-checkbox>
                        <el-checkbox label="索引"></el-checkbox>
                        <el-checkbox label="忽略"></el-checkbox>
                        <el-checkbox label="自增"></el-checkbox>
                      </el-checkbox-group>
                    </template>
                  </el-table-column>

[Solved] Error creating bean with name ‘xxxxController’: Unsatisfied dependency expressed through field ‘xxxxService’;

Error message:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'passportController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'usersMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersMapper' defined in file [D:\__study\web\imooc\foodie-dev - 副本\foodie-dev-mapper\target\classes\com\imooc\mapper\UsersMapper.class]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map 'com.imooc.mapper.CategoryMapperCustom.' referenced from 'com.imooc.mapper.CategoryMapperCustom.getSubCatList'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.7.jar:5.3.7]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.7.jar:5.3.7]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.0.jar:2.5.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.5.0.jar:2.5.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) [spring-boot-2.5.0.jar:2.5.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:337) [spring-boot-2.5.0.jar:2.5.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) [spring-boot-2.5.0.jar:2.5.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) [spring-boot-2.5.0.jar:2.5.0]
    at com.imooc.Application.main(Application.java:22) [classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'usersMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersMapper' defined in file [D:\__study\web\imooc\foodie-dev - 副本\foodie-dev-mapper\target\classes\com\imooc\mapper\UsersMapper.class]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map 'com.imooc.mapper.CategoryMapperCustom.' referenced from 'com.imooc.mapper.CategoryMapperCustom.getSubCatList'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.3.7.jar:5.3.7]
    ... 20 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersMapper' defined in file [D:\__study\web\imooc\foodie-dev - 副本\foodie-dev-mapper\target\classes\com\imooc\mapper\UsersMapper.class]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map 'com.imooc.mapper.CategoryMapperCustom.' referenced from 'com.imooc.mapper.CategoryMapperCustom.getSubCatList'
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.3.7.jar:5.3.7]
    ... 34 common frames omitted
Caused by: org.apache.ibatis.builder.IncompleteElementException: Could not find result map 'com.imooc.mapper.CategoryMapperCustom.' referenced from 'com.imooc.mapper.CategoryMapperCustom.getSubCatList'
    at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:396) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:285) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:113) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.session.Configuration.lambda$buildAllStatements$2(Configuration.java:860) ~[mybatis-3.5.5.jar:3.5.5]
    at java.util.Collection.removeIf(Collection.java:414) ~[na:1.8.0_201]
    at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:859) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.session.Configuration.getMappedStatements(Configuration.java:755) ~[mybatis-3.5.5.jar:3.5.5]
    at tk.mybatis.mapper.mapperhelper.MapperHelper.processConfiguration(MapperHelper.java:279) ~[mapper-core-1.1.5.jar:na]
    at tk.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:93) ~[mapper-spring-1.1.5.jar:na]
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) ~[spring-tx-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.7.jar:5.3.7]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.7.jar:5.3.7]
    ... 44 common frames omitted
Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.imooc.mapper.CategoryMapperCustom.
    at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:1009) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:718) ~[mybatis-3.5.5.jar:3.5.5]
    at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:394) ~[mybatis-3.5.5.jar:3.5.5]
    ... 55 common frames omitted

Error reason: the method in mybatis does not write resultmap. In fact, the error report has given the problem:

Could not find result map 'com.imooc.mapper.CategoryMapperCustom.' referenced from 'com.imooc.mapper.CategoryMapperCustom.getSubCatList'。

C# WinForm: How to Generate two bit random number

Just copy it directly
#region Generate a 2-digit random number
public double NextDouble(Random ran, double minValue, double maxValue, int decimalPlace)
{
double randNum = ran.NextDouble() * (maxValue – minValue) + minValue;
return Convert.ToDouble(randNum.ToString(“f” + decimalPlace));
}
#endregion

Example: Take a random number directly from 70-90 each time
Random ran = new Random();
NextDouble(ran,70,90,2);

How to Solve Disk Unmount Error: device is busy

# umount /dev/sda2

umount: /: target is busy.

perhaps

umount: /dev/sda2: device is busy

This is because some users are using files on the current disk. There are two solutions:

① Force uninstall (not recommended)

umount -l /dev/sda2

② After confirming with the user, close the processes related to these open files

see:

lsof /dev/sda2

Kill program:

lsof /dev/sda2 | awk ‘{print $2}’ | xargs kill -9

Uninstall:

umount /dev/sda2

[Solved] Transparent background PNG Convert to JPG with Balck Background Issue

You can just draw the bitmap onto a new bitmap.
This will also handle the cases of partial transparency, and also not need thousands of p/invokes with the Get/SetPixel (this is very, very slow).

var original = SKBitmap.Decode(inputStream);

// create a new bitmap with the same dimensions
// also avoids the first copy if the color type is index8
var copy = new SKBitmap(original.Width, original.Height);

// we need a canvas to draw
var canvas = new SKCanvas(copy);

// clear the bitmap with the desired color for transparency
canvas.Clear(SKColors.White);

// draw the bitmap on top
canvas.DrawBitmap(original, 0, 0);

[Solved] Linux: file name is garbled and cannot be deleted

Phenomenon:

As shown in the figure, use ls to view the files in the directory. It is found that the file name has garbled codes and strange symbols, which cannot be deleted by RM command;

Solution:

At this time, the file can be deleted through the inode of the file

Operation process:

Use LS – Il to view the file inode

Use the command find- Inum XXXX – delete delete delete file

End