代码生成
This commit is contained in:
parent
6812088c63
commit
9747306aeb
@ -0,0 +1,112 @@
|
|||||||
|
package com.ruoyi.base.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.base.domain.BaseTimeZone;
|
||||||
|
import com.ruoyi.base.service.IBaseTimeZoneService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时区Controller
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/base/zone")
|
||||||
|
public class BaseTimeZoneController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IBaseTimeZoneService baseTimeZoneService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询时区列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult list(BaseTimeZone baseTimeZone,
|
||||||
|
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||||
|
{
|
||||||
|
Page<BaseTimeZone> page = new Page<>(pageNum, pageSize);
|
||||||
|
IPage<BaseTimeZone> list = baseTimeZoneService.queryListPage(baseTimeZone,page);
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出时区列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:export')")
|
||||||
|
@Log(title = "时区", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, BaseTimeZone baseTimeZone)
|
||||||
|
{
|
||||||
|
List<BaseTimeZone> list = baseTimeZoneService.list();
|
||||||
|
ExcelUtil<BaseTimeZone> util = new ExcelUtil<BaseTimeZone>(BaseTimeZone.class);
|
||||||
|
util.exportExcel(response, list, "时区数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取时区详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||||
|
{
|
||||||
|
return success(baseTimeZoneService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增时区
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:add')")
|
||||||
|
@Log(title = "时区", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody BaseTimeZone baseTimeZone)
|
||||||
|
{
|
||||||
|
return toAjax(baseTimeZoneService.save(baseTimeZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时区
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:edit')")
|
||||||
|
@Log(title = "时区", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody BaseTimeZone baseTimeZone)
|
||||||
|
{
|
||||||
|
return toAjax(baseTimeZoneService.updateById(baseTimeZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除时区
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('base:zone:remove')")
|
||||||
|
@Log(title = "时区", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable String[] ids)
|
||||||
|
{
|
||||||
|
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||||
|
return toAjax(baseTimeZoneService.removeByIds(list));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.ruoyi.base.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时区对象 base_time_zone
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
@TableName("base_time_zone")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BaseTimeZone extends DlBaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/** 时区标准名称(如 “Asia/Shanghai”,遵循 IANA 时区数据库命名规范) */
|
||||||
|
@Excel(name = "时区标准名称", readConverterExp = "如=,“=Asia/Shanghai”,遵循,I=ANA,时=区数据库命名规范")
|
||||||
|
private String zoneName;
|
||||||
|
|
||||||
|
/** UTC 偏移量(如 “+08:00”“-05:00”“+03:30”) */
|
||||||
|
@Excel(name = "UTC 偏移量", readConverterExp = "如=,“=+08:00”“-05:00”“+03:30”")
|
||||||
|
private String utcOffset;
|
||||||
|
|
||||||
|
/** 时区缩写(如 “CST” 代表中国标准时间,“EST” 代表美国东部标准时间) */
|
||||||
|
@Excel(name = "时区缩写", readConverterExp = "如=,“=CST”,代=表中国标准时间,“EST”,代=表美国东部标准时间")
|
||||||
|
private String abbreviation;
|
||||||
|
|
||||||
|
/** 是否使用夏令时(1 = 是,0 = 否) */
|
||||||
|
@Excel(name = "是否使用夏令时", readConverterExp = "1=,==,是=,0,==,否=")
|
||||||
|
private Integer usesDst;
|
||||||
|
|
||||||
|
/** 夏令时偏移量(如 “+09:00”,不使用则为 NULL) */
|
||||||
|
@Excel(name = "夏令时偏移量", readConverterExp = "如=,“=+09:00”,不使用则为,N=ULL")
|
||||||
|
private String dstOffset;
|
||||||
|
|
||||||
|
/** 时区描述(如 “中国标准时间,覆盖中国全境”) */
|
||||||
|
@Excel(name = "时区描述", readConverterExp = "如=,“=中国标准时间,覆盖中国全境”")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.base.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.base.domain.BaseTimeZone;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时区Mapper接口
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface BaseTimeZoneMapper extends BaseMapper<BaseTimeZone>
|
||||||
|
{
|
||||||
|
IPage<BaseTimeZone> queryListPage(@Param("entity") BaseTimeZone entity, Page<BaseTimeZone> page);
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.base.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.base.domain.BaseTimeZone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时区Service接口
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
public interface IBaseTimeZoneService extends IService<BaseTimeZone>
|
||||||
|
{
|
||||||
|
IPage<BaseTimeZone> queryListPage(BaseTimeZone pageReqVO, Page<BaseTimeZone> page);
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.ruoyi.base.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.base.mapper.BaseTimeZoneMapper;
|
||||||
|
import com.ruoyi.base.domain.BaseTimeZone;
|
||||||
|
import com.ruoyi.base.service.IBaseTimeZoneService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时区Service业务层处理
|
||||||
|
*
|
||||||
|
* @author pqz
|
||||||
|
* @date 2025-10-31
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BaseTimeZoneServiceImpl extends ServiceImpl<BaseTimeZoneMapper,BaseTimeZone> implements IBaseTimeZoneService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private BaseTimeZoneMapper baseTimeZoneMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<BaseTimeZone> queryListPage(BaseTimeZone pageReqVO, Page<BaseTimeZone> page) {
|
||||||
|
return baseTimeZoneMapper.queryListPage(pageReqVO, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.base.mapper.BaseTimeZoneMapper">
|
||||||
|
|
||||||
|
<resultMap type="BaseTimeZone" id="BaseTimeZoneResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="zoneName" column="zone_name" />
|
||||||
|
<result property="utcOffset" column="utc_offset" />
|
||||||
|
<result property="abbreviation" column="abbreviation" />
|
||||||
|
<result property="usesDst" column="uses_dst" />
|
||||||
|
<result property="dstOffset" column="dst_offset" />
|
||||||
|
<result property="description" column="description" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectBaseTimeZoneVo">
|
||||||
|
select id, zone_name, utc_offset, abbreviation, uses_dst, dst_offset, description from base_time_zone
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="queryListPage" parameterType="BaseTimeZone" resultMap="BaseTimeZoneResult">
|
||||||
|
<include refid="selectBaseTimeZoneVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="entity.zoneName != null and entity.zoneName != ''"> and zone_name like concat('%', #{entity.zoneName}, '%')</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user