增加demo-api示例

This commit is contained in:
yaoyn
2025-04-28 17:25:35 +08:00
parent de240cba3e
commit db33dbaa8b
31 changed files with 164 additions and 2 deletions

105
demo/demo-api/pom.xml Normal file
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.geg</groupId>
<artifactId>demo</artifactId>
<version>${revision}</version>
</parent>
<artifactId>demo-api</artifactId>
<name>demo-api</name>
<description>demo-api</description>
<properties>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.geg</groupId>
<artifactId>itc-ms-common-api</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.vm</include>
<include>**/*.ftl</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,22 @@
package com.xjrsoft.module.prdManage.client;
import com.xjrsoft.common.constant.GlobalConstant;
import com.xjrsoft.module.prdManage.dto.DemoAppliancePageDto;
import com.xjrsoft.module.prdManage.vo.DemoApplianceVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author: yjw
* @since: 2025/3/4
*/
@FeignClient(value = "demo-service",
path = GlobalConstant.CLIENT_API_PRE + "prdManage/demoAppliance")
public interface IDemoApplianceClient {
@PostMapping("/getListByQuery")
List<DemoApplianceVo> getListByQuery(@RequestBody DemoAppliancePageDto dto);
}

View File

@ -0,0 +1,67 @@
package com.xjrsoft.module.prdManage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: 示例-家电管理
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
public class AddDemoApplianceDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime purchaseDate;
/**
*
*/
@ApiModelProperty("")
private Integer warrantyPeriod;
/**
*
*/
@ApiModelProperty("")
private Integer powerRating;
/**
*
*/
@ApiModelProperty("")
private String brand;
/**
*
*/
@ApiModelProperty("")
private Double sellingPrice;
/**
*
*/
@ApiModelProperty("")
private String status;
}

View File

@ -0,0 +1,35 @@
package com.xjrsoft.module.prdManage.dto;
import com.xjrsoft.common.page.PageInput;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @title: 分页查询入参
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DemoAppliancePageDto extends PageInput {
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
}

View File

@ -0,0 +1,72 @@
package com.xjrsoft.module.prdManage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: 示例-家电管理
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
public class UpdateDemoApplianceDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
private Integer id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime purchaseDate;
/**
*
*/
@ApiModelProperty("")
private Integer warrantyPeriod;
/**
*
*/
@ApiModelProperty("")
private Integer powerRating;
/**
*
*/
@ApiModelProperty("")
private String brand;
/**
*
*/
@ApiModelProperty("")
private Double sellingPrice;
/**
*
*/
@ApiModelProperty("")
private String status;
}

View File

@ -0,0 +1,68 @@
package com.xjrsoft.module.prdManage.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @title: 分页列表出参
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
public class DemoAppliancePageVo {
/**
*
*/
@ApiModelProperty("")
private String id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime purchaseDate;
/**
*
*/
@ApiModelProperty("")
private Integer warrantyPeriod;
/**
*
*/
@ApiModelProperty("")
private Integer powerRating;
/**
*
*/
@ApiModelProperty("")
private String brand;
/**
*
*/
@ApiModelProperty("")
private Double sellingPrice;
/**
*
*/
@ApiModelProperty("")
private String status;
}

View File

@ -0,0 +1,70 @@
package com.xjrsoft.module.prdManage.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @title: 表单出参
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
public class DemoApplianceVo {
/**
*
*/
@ApiModelProperty("")
private Integer id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime purchaseDate;
/**
*
*/
@ApiModelProperty("")
private Integer warrantyPeriod;
/**
*
*/
@ApiModelProperty("")
private Integer powerRating;
/**
*
*/
@ApiModelProperty("")
private String brand;
/**
*
*/
@ApiModelProperty("")
private Double sellingPrice;
/**
*
*/
@ApiModelProperty("")
private String status;
}

View File

@ -0,0 +1,57 @@
package com.xjrsoft.module.relationManage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: demo_客户管理
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
public class AddDemoCustomerDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
/**
*
*/
@ApiModelProperty("")
private String address;
/**
*
*/
@ApiModelProperty("")
private String company;
/**
*
*/
@ApiModelProperty("")
private String position;
}

View File

@ -0,0 +1,40 @@
package com.xjrsoft.module.relationManage.dto;
import com.xjrsoft.common.page.PageInput;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @title: 分页查询入参
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class DemoCustomerPageDto extends PageInput {
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
}

View File

@ -0,0 +1,61 @@
package com.xjrsoft.module.relationManage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: demo_客户管理
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
public class UpdateDemoCustomerDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
private Long id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
/**
*
*/
@ApiModelProperty("")
private String address;
/**
*
*/
@ApiModelProperty("")
private String company;
/**
*
*/
@ApiModelProperty("")
private String position;
}

View File

@ -0,0 +1,56 @@
package com.xjrsoft.module.relationManage.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @title: 分页列表出参
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
public class DemoCustomerPageVo {
/**
*
*/
@ApiModelProperty("")
private String id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
/**
*
*/
@ApiModelProperty("")
private String address;
/**
*
*/
@ApiModelProperty("")
private String company;
/**
*
*/
@ApiModelProperty("")
private String position;
}

View File

@ -0,0 +1,74 @@
package com.xjrsoft.module.relationManage.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @title: 表单出参
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
public class DemoCustomerVo {
/**
*
*/
@ApiModelProperty("")
private Long id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
/**
*
*/
@ApiModelProperty("")
private String address;
/**
*
*/
@ApiModelProperty("")
private String company;
/**
*
*/
@ApiModelProperty("")
private String position;
@ApiModelProperty("")
private LocalDateTime createDate;
/**
*
*/
@ApiModelProperty("")
private Long createUserId;
/**
*
*/
@ApiModelProperty("")
private Long deptId;
}

220
demo/demo-service/pom.xml Normal file
View File

@ -0,0 +1,220 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.geg</groupId>
<artifactId>demo</artifactId>
<version>${revision}</version>
</parent>
<artifactId>demo-service</artifactId>
<name>demo-service</name>
<description>demo-service</description>
<properties>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.geg</groupId>
<artifactId>itc-ms-common-service</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>com.geg</groupId>
<artifactId>demo-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- springCloud 整合的openFeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!--引入nacos依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--引入spring-cloud-alibaba-nacos-config依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--引入spring-cloud-alibaba-nacos-config bootstrap依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!--引入sentinel依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<!-- mybatis-plus 多表关联 -->
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join</artifactId>
</dependency>
<dependency>
<groupId>com.cloud.govern</groupId>
<artifactId>service-invoke-sdk</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.unfbx</groupId>
<artifactId>chatgpt-java</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>tech.powerjob</groupId>
<artifactId>powerjob-worker-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-authz-client</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.ews-java-api</groupId>
<artifactId>ews-java-api</artifactId>
</dependency>
<dependency>
<groupId>tech.powerjob</groupId>
<artifactId>powerjob-official-processors</artifactId>
</dependency>
<dependency>
<groupId>tech.powerjob</groupId>
<artifactId>powerjob-worker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.vm</include>
<include>**/*.ftl</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,25 @@
package com.xjrsoft;
import com.xjrsoft.common.annotation.UniqueNameGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* @author Zexy
*/
@SpringBootApplication
@EnableAspectJAutoProxy(exposeProxy = true)
@ComponentScan(nameGenerator = UniqueNameGenerator.class)
@EnableFeignClients
@EnableDiscoveryClient
public class ITCDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ITCDemoApplication.class, args);
}
}

View File

@ -0,0 +1,28 @@
package com.xjrsoft.common.schedule;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@RequiredArgsConstructor
@Component
@ConditionalOnProperty(name = {"schedule.enabled","schedule.sync-xx.enabled"}, havingValue = "true")
@Slf4j
@EnableScheduling
public class DemoSysncTask {
@Scheduled(cron = "${schedule.sync-xx.cron:0 0/60 * * * *}") //60分钟跑一次
public void sync(){
log.info("同步XX数据 => " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
try{
//todo 任务具体实现
} catch (Exception e){
log.error("同步XX数据失败" + e);
}
}
}

View File

@ -0,0 +1,28 @@
package com.xjrsoft.common.util;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContextUtil.context = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return context;
}
public static <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
public static Object getBean(String beanName) {
return context.getBean(beanName);
}
}

View File

@ -0,0 +1,98 @@
package com.xjrsoft.module.prdManage.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.prdManage.dto.AddDemoApplianceDto;
import com.xjrsoft.module.prdManage.dto.DemoAppliancePageDto;
import com.xjrsoft.module.prdManage.dto.UpdateDemoApplianceDto;
import com.xjrsoft.module.prdManage.entity.DemoAppliance;
import com.xjrsoft.module.prdManage.service.IDemoApplianceService;
import com.xjrsoft.module.prdManage.vo.DemoAppliancePageVo;
import com.xjrsoft.module.prdManage.vo.DemoApplianceVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @title: 示例-家电管理
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@RestController
@RequestMapping("/prdManage" + "/demoAppliance")
@Api(value = "/prdManage" + "/demoAppliance",tags = "示例-家电管理代码")
@AllArgsConstructor
public class DemoApplianceController {
private final IDemoApplianceService demoApplianceService;
@GetMapping(value = "/page")
@ApiOperation(value="DemoAppliance列表(分页)")
@SaCheckPermission("demoAppliance:list")
public R page(@Valid DemoAppliancePageDto dto){
LambdaQueryWrapper<DemoAppliance> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.like(StrUtil.isNotBlank(dto.getName()),DemoAppliance::getName,dto.getName())
.like(StrUtil.isNotBlank(dto.getSerialNumber()),DemoAppliance::getSerialNumber,dto.getSerialNumber())
.like(StrUtil.isNotBlank(dto.getCategory()),DemoAppliance::getCategory,dto.getCategory())
.orderByDesc(DemoAppliance::getId)
.select(DemoAppliance.class,x -> VoToColumnUtil.fieldsToColumns(DemoAppliancePageVo.class).contains(x.getProperty()));
IPage<DemoAppliance> page = demoApplianceService.page(ConventPage.getPage(dto), queryWrapper);
PageOutput<DemoAppliancePageVo> pageOutput = ConventPage.getPageOutput(page, DemoAppliancePageVo.class);
return R.ok(pageOutput);
}
@GetMapping(value = "/info")
@ApiOperation(value="根据id查询DemoAppliance信息")
@SaCheckPermission("demoAppliance:detail")
public R info(@RequestParam Integer id){
DemoAppliance demoAppliance = demoApplianceService.getById(id);
if (demoAppliance == null) {
return R.error("找不到此数据!");
}
return R.ok(BeanUtil.toBean(demoAppliance, DemoApplianceVo.class));
}
@PostMapping
@ApiOperation(value = "新增DemoAppliance")
@SaCheckPermission("demoAppliance:add")
public R add(@Valid @RequestBody AddDemoApplianceDto dto){
DemoAppliance demoAppliance = BeanUtil.toBean(dto, DemoAppliance.class);
boolean isSuccess = demoApplianceService.save(demoAppliance);
return R.ok(demoAppliance.getId());
}
@PutMapping
@ApiOperation(value = "修改DemoAppliance")
@SaCheckPermission("demoAppliance:edit")
public R update(@Valid @RequestBody UpdateDemoApplianceDto dto){
DemoAppliance demoAppliance = BeanUtil.toBean(dto, DemoAppliance.class);
return R.ok(demoApplianceService.updateById(demoAppliance));
}
@DeleteMapping
@ApiOperation(value = "删除")
@SaCheckPermission("demoAppliance:delete")
public R delete(@Valid @RequestBody List<Integer> ids){
return R.ok(demoApplianceService.removeBatchByIds(ids));
}
}

View File

@ -0,0 +1,79 @@
package com.xjrsoft.module.prdManage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: 示例-家电管理
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Data
@TableName("demo_appliance")
@ApiModel(value = "示例-家电管理对象", description = "示例-家电管理")
public class DemoAppliance implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
@TableId
private Integer id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String serialNumber;
/**
*
*/
@ApiModelProperty("")
private String category;
/**
*
*/
@ApiModelProperty("")
private LocalDateTime purchaseDate;
/**
*
*/
@ApiModelProperty("")
private Integer warrantyPeriod;
/**
*
*/
@ApiModelProperty("")
private Integer powerRating;
/**
*
*/
@ApiModelProperty("")
private String brand;
/**
*
*/
@ApiModelProperty("")
private Double sellingPrice;
/**
*
*/
@ApiModelProperty("")
private String status;
}

View File

@ -0,0 +1,16 @@
package com.xjrsoft.module.prdManage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.module.prdManage.entity.DemoAppliance;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Mapper
public interface DemoApplianceMapper extends BaseMapper<DemoAppliance> {
}

View File

@ -0,0 +1,14 @@
package com.xjrsoft.module.prdManage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjrsoft.module.prdManage.entity.DemoAppliance;
/**
* @title: service
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
public interface IDemoApplianceService extends IService<DemoAppliance> {
}

View File

@ -0,0 +1,19 @@
package com.xjrsoft.module.prdManage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.module.prdManage.entity.DemoAppliance;
import com.xjrsoft.module.prdManage.mapper.DemoApplianceMapper;
import com.xjrsoft.module.prdManage.service.IDemoApplianceService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
* @title: service
* @Author 管理员
* @Date: 2025-03-12
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class DemoApplianceServiceImpl extends ServiceImpl<DemoApplianceMapper, DemoAppliance> implements IDemoApplianceService {
}

View File

@ -0,0 +1,99 @@
package com.xjrsoft.module.relationManage.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.relationManage.dto.AddDemoCustomerDto;
import com.xjrsoft.module.relationManage.dto.DemoCustomerPageDto;
import com.xjrsoft.module.relationManage.dto.UpdateDemoCustomerDto;
import com.xjrsoft.module.relationManage.entity.DemoCustomer;
import com.xjrsoft.module.relationManage.service.IDemoCustomerManageService;
import com.xjrsoft.module.relationManage.vo.DemoCustomerPageVo;
import com.xjrsoft.module.relationManage.vo.DemoCustomerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @title: demo_客户管理
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@RestController
@RequestMapping("/relationManage" + "/demoCustomerManage")
@Api(value = "/relationManage" + "/demoCustomerManage",tags = "demo_客户管理代码")
@AllArgsConstructor
public class DemoCustomerManageController {
private final IDemoCustomerManageService demoCustomerManageService;
@GetMapping(value = "/page")
@ApiOperation(value="DemoCustomer列表(分页)")
@SaCheckPermission("demoCustomerManage:list")
public R page(@Valid DemoCustomerPageDto dto){
LambdaQueryWrapper<DemoCustomer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.like(StrUtil.isNotBlank(dto.getName()),DemoCustomer::getName,dto.getName())
.like(StrUtil.isNotBlank(dto.getGender()),DemoCustomer::getGender,dto.getGender())
.like(StrUtil.isNotBlank(dto.getPhone()),DemoCustomer::getPhone,dto.getPhone())
.like(StrUtil.isNotBlank(dto.getEmail()),DemoCustomer::getEmail,dto.getEmail())
.orderByDesc(DemoCustomer::getId)
.select(DemoCustomer.class,x -> VoToColumnUtil.fieldsToColumns(DemoCustomerPageVo.class).contains(x.getProperty()));
IPage<DemoCustomer> page = demoCustomerManageService.page(ConventPage.getPage(dto), queryWrapper);
PageOutput<DemoCustomerPageVo> pageOutput = ConventPage.getPageOutput(page, DemoCustomerPageVo.class);
return R.ok(pageOutput);
}
@GetMapping(value = "/info")
@ApiOperation(value="根据id查询DemoCustomer信息")
@SaCheckPermission("demoCustomerManage:detail")
public R info(@RequestParam Long id){
DemoCustomer demoCustomer = demoCustomerManageService.getById(id);
if (demoCustomer == null) {
return R.error("找不到此数据!");
}
return R.ok(BeanUtil.toBean(demoCustomer, DemoCustomerVo.class));
}
@PostMapping
@ApiOperation(value = "新增DemoCustomer")
@SaCheckPermission("demoCustomerManage:add")
public R add(@Valid @RequestBody AddDemoCustomerDto dto){
DemoCustomer demoCustomer = BeanUtil.toBean(dto, DemoCustomer.class);
boolean isSuccess = demoCustomerManageService.save(demoCustomer);
return R.ok(demoCustomer.getId());
}
@PutMapping
@ApiOperation(value = "修改DemoCustomer")
@SaCheckPermission("demoCustomerManage:edit")
public R update(@Valid @RequestBody UpdateDemoCustomerDto dto){
DemoCustomer demoCustomer = BeanUtil.toBean(dto, DemoCustomer.class);
return R.ok(demoCustomerManageService.updateById(demoCustomer));
}
@DeleteMapping
@ApiOperation(value = "删除")
@SaCheckPermission("demoCustomerManage:delete")
public R delete(@Valid @RequestBody List<Long> ids){
return R.ok(demoCustomerManageService.removeBatchByIds(ids));
}
}

View File

@ -0,0 +1,90 @@
package com.xjrsoft.module.relationManage.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: demo_客户管理
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Data
@TableName("demo_customer")
@ApiModel(value = "demo_客户管理对象", description = "demo_客户管理")
public class DemoCustomer implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("")
@TableId
private Long id;
/**
*
*/
@ApiModelProperty("")
private String name;
/**
*
*/
@ApiModelProperty("")
private String gender;
/**
*
*/
@ApiModelProperty("")
private String phone;
/**
*
*/
@ApiModelProperty("")
private String email;
/**
*
*/
@ApiModelProperty("")
private String address;
/**
*
*/
@ApiModelProperty("")
private String company;
/**
*
*/
@ApiModelProperty("")
private String position;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
*
*/
@ApiModelProperty("")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
}

View File

@ -0,0 +1,16 @@
package com.xjrsoft.module.relationManage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjrsoft.module.relationManage.entity.DemoCustomer;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Mapper
public interface DemoCustomerMapper extends BaseMapper<DemoCustomer> {
}

View File

@ -0,0 +1,14 @@
package com.xjrsoft.module.relationManage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjrsoft.module.relationManage.entity.DemoCustomer;
/**
* @title: service
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
public interface IDemoCustomerManageService extends IService<DemoCustomer> {
}

View File

@ -0,0 +1,19 @@
package com.xjrsoft.module.relationManage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.module.relationManage.entity.DemoCustomer;
import com.xjrsoft.module.relationManage.mapper.DemoCustomerMapper;
import com.xjrsoft.module.relationManage.service.IDemoCustomerManageService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
* @title: service
* @Author 管理员
* @Date: 2025-03-11
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class DemoCustomerManageServiceImpl extends ServiceImpl<DemoCustomerMapper, DemoCustomer> implements IDemoCustomerManageService {
}

View File

@ -0,0 +1,3 @@
spring:
profiles:
active: dev

View File

@ -0,0 +1,6 @@
██╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ███████╗████████╗
╚██╗██╔╝ ██║██╔══██╗██╔════╝██╔═══██╗██╔════╝╚══██╔══╝
╚███╔╝ ██║██████╔╝███████╗██║ ██║█████╗ ██║
██╔██╗ ██ ██║██╔══██╗╚════██║██║ ██║██╔══╝ ██║
██╔╝ ██╗╚█████╔╝██║ ██║███████║╚██████╔╝██║ ██║
╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝

View File

@ -0,0 +1,50 @@
server:
port: 9001
spring:
application:
name: demo-service
main:
allow-bean-definition-overriding: true
# autoconfigure:
# #自动化配置 例外处理
# exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
cloud:
nacos: #nacos监控
discovery:
server-addr: 10.0.252.1:8848
namespace: ITC-MS
group: DNE
username: nacos
password: ABcd1234@
config:
server-addr: 10.0.252.1:8848 # nacos 配置中心地址
namespace: ITC-MS
group: DNE
username: nacos
password: ABcd1234@
file-extension: yml # 默认配置 ${spring.application.name}-${spring.profiles.active}.${file-extension}
extension-configs:
- data-id: global-config.yml
refresh: true
group: DNE
- data-id: sa-token-client-config.yml
refresh: true
group: DNE
- data-id: redis-config.yml
refresh: true
group: DNE
- data-id: datasource-config.yml
refresh: true
group: DNE
- data-id: camunda-config.yml
refresh: true
group: DNE
- data-id: demo-config.yml
refresh: true
group: DNE
sentinel:
transport:
dashboard: localhost:8080 #sentinel dashboard 地址
port: 8719 #默认端口, 如果 被占用,会一直+1 直到未被占用为止

29
demo/pom.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.geg</groupId>
<artifactId>ms-demo</artifactId>
<version>${revision}</version>
</parent>
<artifactId>demo</artifactId>
<name>demo</name>
<description>demo</description>
<packaging>pom</packaging>
<modules>
<module>demo-api</module>
<module>demo-service</module>
</modules>
<properties>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>