
17 changed files with 312 additions and 1 deletions
@ -0,0 +1,2 @@ |
|||
|
|||
CREATE DATABASE `yxt_supervise_monitor` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */ |
@ -0,0 +1,31 @@ |
|||
|
|||
DROP TABLE IF EXISTS `demo_identity`; |
|||
CREATE TABLE `demo_identity` ( |
|||
`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID,唯一编号', |
|||
|
|||
`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间', |
|||
`remarks` VARCHAR(100) DEFAULT NULL COMMENT '备注说明', |
|||
|
|||
`name` VARCHAR(100) DEFAULT NULL COMMENT '名称', |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) ENGINE=InnoDB COMMENT='只有主键的表(关联表、字典表等)'; |
|||
|
|||
|
|||
DROP TABLE IF EXISTS `demo_baseentity`; |
|||
CREATE TABLE `demo_baseentity` ( |
|||
`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID,唯一编号', |
|||
`sid` VARCHAR(64) NOT NULL COMMENT 'sid', |
|||
`lockVersion` VARCHAR(2) NULL DEFAULT NULL COMMENT '记录版本,锁', |
|||
`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间', |
|||
`modifyTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录最后修改时间', |
|||
`state` INT(11) NOT NULL DEFAULT '1' COMMENT '记录状态值', |
|||
`isEnable` INT(32) NOT NULL DEFAULT '1' COMMENT '记录是否可用,1:可用,0:不可用', |
|||
`isDelete` INT(32) NOT NULL DEFAULT '0' COMMENT '记录是否被删除,0:未删除,1:已经删除', |
|||
`remarks` VARCHAR(255) NULL DEFAULT NULL COMMENT '备注信息', |
|||
`createBySid` VARCHAR(64) NULL DEFAULT NULL COMMENT '创建者', |
|||
`updateBySid` VARCHAR(64) NULL DEFAULT NULL COMMENT '更新者', |
|||
|
|||
`name` VARCHAR(100) DEFAULT NULL COMMENT '名称', |
|||
`passwd` VARCHAR(100) DEFAULT NULL COMMENT '密码', |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) ENGINE=InnoDB COMMENT='有公共字段的表(业务数据)'; |
@ -0,0 +1,21 @@ |
|||
package com.yxt.supervise.monitor.api.demobaseentity; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@ApiModel(value = "有公共字段的实体", description = "有公共字段的实体") |
|||
@TableName("demo_baseentity") |
|||
public class DemoBaseentity extends BaseEntity { |
|||
|
|||
// 公共字段从父类继承
|
|||
|
|||
@ApiModelProperty("名称") |
|||
private String name; // 名称
|
|||
@ApiModelProperty("密码") |
|||
private String passwd; // 密码
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.yxt.supervise.monitor.api.demobaseentity; |
|||
|
|||
import com.yxt.common.core.dto.Dto; |
|||
import com.yxt.common.core.vo.Vo; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class DemoBaseentityDto implements Dto { |
|||
private String id; |
|||
private String sid; |
|||
@ApiModelProperty("名称") |
|||
private String name; // 名称
|
|||
@ApiModelProperty("密码") |
|||
private String passwd; // 密码
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.yxt.supervise.monitor.api.demobaseentity; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import com.yxt.common.core.vo.Vo; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class DemoBaseentityQuery implements Query { |
|||
|
|||
@ApiModelProperty("名称") |
|||
private String name; // 名称
|
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.yxt.supervise.monitor.api.demobaseentity; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class DemoBaseentityVo implements Vo { |
|||
private String id; |
|||
private String sid; |
|||
@ApiModelProperty("名称") |
|||
private String name; // 名称
|
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.monitor.api.demoidentity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
@ApiModel(value = "有ID的实体", description = "有ID的实体") |
|||
@TableName("demo_identity") |
|||
public class DemoIdentity extends EntityWithId { |
|||
// `id`使用继承的
|
|||
|
|||
@ApiModelProperty("记录创建时间") |
|||
@JsonFormat( |
|||
pattern = "yyyy-MM-dd HH:mm:ss", |
|||
timezone = "GMT+8" |
|||
) |
|||
private Date createTime = new Date(); // 记录创建时间
|
|||
@ApiModelProperty("备注说明") |
|||
private String remarks; // 备注说明
|
|||
@ApiModelProperty("名称") |
|||
private String name; // 名称
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.yxt.supervise.monitor.biz.demobaseentity; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentity; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityVo; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
@Mapper |
|||
public interface DemoBaseentityMapper extends BaseMapper<DemoBaseentity> { |
|||
IPage<DemoBaseentityVo> selectPageVo(IPage<DemoBaseentity> page, @Param(Constants.WRAPPER) QueryWrapper<DemoBaseentity> qw); |
|||
} |
@ -0,0 +1,10 @@ |
|||
<?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.yxt.supervise.monitor.biz.demobaseentity.DemoBaseentityMapper"> |
|||
<select id="selectPageVo" resultType="com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityVo"> |
|||
SELECT * FROM demo_baseentity |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,71 @@ |
|||
package com.yxt.supervise.monitor.biz.demobaseentity; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentity; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityDto; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityQuery; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityVo; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Api(tags = "基础实体类") |
|||
@RestController("com.yxt.supervise.monitor.biz.demobaseentity.DemoBaseentityRest") |
|||
@RequestMapping("/demo/demobaseentity") |
|||
public class DemoBaseentityRest { |
|||
|
|||
@Autowired |
|||
private DemoBaseentityService demoBaseentityService; |
|||
|
|||
@ApiOperation("根据条件分页查询数据的列表") |
|||
@PostMapping("/listPage") |
|||
public ResultBean<PagerVo<DemoBaseentityVo>> listPage(@RequestBody PagerQuery<DemoBaseentityQuery> pq) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PagerVo<DemoBaseentityVo> pv = demoBaseentityService.listPageVo(pq); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
@ApiOperation("根据物料类型查询数据的列表") |
|||
@PostMapping("/list") |
|||
public ResultBean<PagerVo<DemoBaseentityVo>> typeList() { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<DemoBaseentityVo> pv = demoBaseentityService.listVo(); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
@ApiOperation("新增") |
|||
@PostMapping("/insert") |
|||
public ResultBean save(@RequestBody DemoBaseentityDto dto) { |
|||
return demoBaseentityService.saveInsert(dto); |
|||
} |
|||
|
|||
@ApiOperation("修改") |
|||
@PostMapping("/update") |
|||
public ResultBean update(@RequestBody DemoBaseentityDto dto) { |
|||
return demoBaseentityService.saveUpdate(dto); |
|||
} |
|||
|
|||
@ApiOperation("根据sid查询") |
|||
@GetMapping("/fetchVoBySid/{sid}") |
|||
public ResultBean<DemoBaseentityVo> fetchVoBySid(@PathVariable String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
DemoBaseentity entity = demoBaseentityService.fetchBySid(sid); |
|||
DemoBaseentityVo vo = new DemoBaseentityVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
return rb.success().setData(vo); |
|||
} |
|||
|
|||
@ApiOperation("删除") |
|||
@DeleteMapping("/deleteBySid/{sid}") |
|||
public ResultBean deleteBySid(@PathVariable String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
int i = demoBaseentityService.deleteBySid(sid); |
|||
return rb.success().setMsg("删除成功"); |
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.yxt.supervise.monitor.biz.demobaseentity; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentity; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityDto; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityQuery; |
|||
import com.yxt.supervise.monitor.api.demobaseentity.DemoBaseentityVo; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class DemoBaseentityService extends MybatisBaseService<DemoBaseentityMapper, DemoBaseentity> { |
|||
public PagerVo<DemoBaseentityVo> listPageVo(PagerQuery<DemoBaseentityQuery> pq) { |
|||
DemoBaseentityQuery query = pq.getParams(); |
|||
QueryWrapper<DemoBaseentity> qw = new QueryWrapper<>(); |
|||
if (StringUtils.isNotBlank(query.getName())) { |
|||
qw.like("name", query.getName()); |
|||
} |
|||
IPage<DemoBaseentity> page = PagerUtil.queryToPage(pq); |
|||
IPage<DemoBaseentityVo> pagging = baseMapper.selectPageVo(page, qw); |
|||
PagerVo<DemoBaseentityVo> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public List<DemoBaseentityVo> listVo() { |
|||
List<DemoBaseentityVo> res = new ArrayList<>(); |
|||
List<DemoBaseentity> list = super.list(); |
|||
list.forEach(entity -> { |
|||
DemoBaseentityVo vo = new DemoBaseentityVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
res.add(vo); |
|||
}); |
|||
return res; |
|||
} |
|||
|
|||
public ResultBean saveInsert(DemoBaseentityDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
DemoBaseentity entity = new DemoBaseentity(); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
baseMapper.insert(entity); |
|||
return rb.success().setMsg("新增成功"); |
|||
} |
|||
|
|||
public ResultBean saveUpdate(DemoBaseentityDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String dtoSid = dto.getSid(); |
|||
DemoBaseentity entity = fetchBySid(dtoSid); |
|||
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|||
baseMapper.updateById(entity); |
|||
return rb.success().setMsg("修改成功"); |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.yxt.supervise.monitor.biz.demoidentity; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.supervise.monitor.api.demoidentity.DemoIdentity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface DemoIdentityMapper extends BaseMapper<DemoIdentity> { |
|||
} |
@ -0,0 +1,4 @@ |
|||
<?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.yxt.supervise.monitor.biz.demoidentity.DemoIdentityMapper"> |
|||
</mapper> |
@ -0,0 +1,9 @@ |
|||
package com.yxt.supervise.monitor.biz.demoidentity; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.yxt.supervise.monitor.api.demoidentity.DemoIdentity; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class DemoIdentityService extends ServiceImpl<DemoIdentityMapper, DemoIdentity> { |
|||
} |
Loading…
Reference in new issue