ruoyi偌衣学习笔记

偌衣学习系统:1 使用 pojo目录使用 domain作为名字

2 使用validate 的方法:设置非空 和文字的长度,

设置自定义的 注解防晒

/** 系统内置(Y是 N否) */
@Excel(name = "系统内置", readConverterExp = "Y=是,N=否")
private String configType;


@NotBlank(message = "参数名称不能为空")
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
public String getConfigName()
{
return configName;
}3 正常情况下,字母项目编译mvn package是可以编辑打包的,不能的话是配置错了

4 只有pojo类被加入的方法才会真正的追加打印

public String toString() {
return new ToStringBuilder(this).append("ssn", ssn).append("year", year).append("lastName",
lastName).toString();
}
maven依赖是:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
5 通过创建实体类集成 serializable的方式来进行序列化
public class BaseEntity implements Serializable
然后其他类来集成他
同时通过JsonFormat来格式化
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;


使用JsonFormat 主要用于 后台到前台的转换, 可以用再get和属性名上
//设置时区为上海时区,时间格式自己据需求定。
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
private Date testTime;

需要依赖的包是


2.注解@DateTimeFormat

<!-- joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
2.在controller层我们使用spring mvc 表单自动封装映射对象时,我们在对应的接收前台数据的对象的属性上加@@DateTimeFormat

@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date symendtime;


注解@JsonFormat主要是后台到前台的时间格式的转换

注解@DataFormAT主要是前后到后台的时间格式的转换

5 自定义注解的方式

/**
* 自定义导出Excel数据注解
*
* @author ruoyi
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Excel
{
6 mybatis 使用公共的引用的方法:
定义两个sql,直接include 引入,同时 用refid来关联
<sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config
</sql>

<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
<if test="configId !=null">
and config_id = #{configId}
</if>
<if test="configKey !=null and configKey != ''">
and config_key = #{configKey}
</if>
</where>
</sql>

<select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>

7 使用mybatis 数组进行循环的方法

public int deleteConfigByIds(String[] configIds);
<delete id="deleteConfigByIds" parameterType="String">
delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
</foreach>
</delete>

8 有Long类型
9 循环的第二个方式
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.deptId}
</foreach>

10 定时任务 xxx

2 schedule 停止job的方法,删除,回复,立刻运行的方法
Long jobId = job.getJobId();
String jobGroup = job.getJobGroup();
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
int rows = jobMapper.updateJob(job);
if (rows > 0)
{
scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
}
scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup));
scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
立刻运行job的方法
String jobGroup = job.getJobGroup();
SysJob properties = selectJobById(job.getJobId());
// 参数
JobDataMap dataMap = new JobDataMap();
dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties);
scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap);
更新任务就是删除后新建任务的方法

/**
* 更新任务
*
* @param job 任务对象
* @param jobGroup 任务组名
*/
public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException
{
Long jobId = job.getJobId();
// 判断是否存在
JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup);
if (scheduler.checkExists(jobKey))
{
// 防止创建时存在数据问题 先移除,然后在执行创建操作
scheduler.deleteJob(jobKey);
}
ScheduleUtils.createScheduleJob(scheduler, job);

此时的schedule已经注入到了 spring
@Autowired
private Scheduler scheduler;

原文地址:https://www.cnblogs.com/genestart/p/11247530.html