偌衣学习系统: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 />
</select>

 

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

public int deleteConfigByIds(String[] configIds);
<delete >
#{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;

相关文章:

  • 2021-12-24
  • 2022-12-23
  • 2021-08-08
  • 2021-09-24
  • 2021-07-22
  • 2021-08-30
  • 2021-08-14
  • 2021-06-11
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2022-01-25
  • 2021-12-22
  • 2021-09-23
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案