重构项目
parent
10341472e9
commit
3477a3921d
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -85,6 +85,12 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
|
||||
/**
|
||||
* 用户类型(00 系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
|
@ -301,6 +307,8 @@ public class SysUser extends BaseEntity {
|
|||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
@ -323,6 +331,7 @@ public class SysUser extends BaseEntity {
|
|||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("dept", getDept())
|
||||
.append("userType",userType)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
@ -28,12 +28,12 @@ spring:
|
|||
eager: true
|
||||
transport:
|
||||
# 控制台地址
|
||||
dashboard: 127.0.0.1:8718
|
||||
dashboard: 175.24.138.82:8718
|
||||
# nacos配置持久化
|
||||
datasource:
|
||||
ds1:
|
||||
nacos:
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
dataId: sentinel-muyu-gateway
|
||||
groupId: DEFAULT_GROUP
|
||||
data-type: json
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-service</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-system</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.business;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* qidong XiaoHuangBusinessApplication
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/3
|
||||
*/
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class XiaoHuangBusinessApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(XiaoHuangBusinessApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.Business;
|
||||
import com.muyu.business.service.BusinessService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业的 BusinessController
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/business")
|
||||
public class BusinessController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private BusinessService businessService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询企业列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Business>> list(Business business){
|
||||
startPage();
|
||||
List<Business> list = businessService.selectBusinessList(business);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出企业列表
|
||||
*/
|
||||
@Log(title = "企业", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Business business){
|
||||
List<Business> list = businessService.selectBusinessList(business);
|
||||
ExcelUtil<Business> util = new ExcelUtil<>(Business.class);
|
||||
util.exportExcel(response,list,"企业数据");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取企业详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id){
|
||||
return success(businessService.selectBusinessById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增企业
|
||||
*/
|
||||
@Log(title = "企业",businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody Business business){
|
||||
return toAjax(businessService.insertBusiness(business));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@Log(title = "企业",businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody Business business){
|
||||
return toAjax(businessService.updateBusiness(business));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@Log(title = "企业",businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public Result remove(@PathVariable Long[] ids){
|
||||
return toAjax(businessService.deleteBusinessByIds(ids));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权角色返回结果集 AuthRoleResp
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthRoleResp {
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
private SysUser user;
|
||||
|
||||
|
||||
/**
|
||||
* 角色集合
|
||||
*/
|
||||
private List<SysRole> roles;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 企业对象 Business
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("business")
|
||||
public class Business extends BaseEntity {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 企业主键
|
||||
*/
|
||||
@Excel(name = "企业主键")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@Excel(name = "企业名称")
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* 企业法定代表人
|
||||
*/
|
||||
@Excel(name = "企业法定代表人")
|
||||
private String businessPerson;
|
||||
|
||||
|
||||
/**
|
||||
* 营业编码
|
||||
*/
|
||||
@Excel(name = "营业编码")
|
||||
private String businessLincenseNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 企业创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "企业创建时间",width = 30,dateFormat = "yyyy-MM-dd")
|
||||
private Date businessCreateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 企业电话
|
||||
*/
|
||||
@Excel(name = "企业电话")
|
||||
private String businessPhone;
|
||||
|
||||
|
||||
/**
|
||||
* 企业邮箱
|
||||
*/
|
||||
@Excel(name = "企业邮箱")
|
||||
private String businessEmail;
|
||||
|
||||
|
||||
/**
|
||||
* 企业状态
|
||||
*/
|
||||
@Excel(name = "企业状态")
|
||||
private String businessStates;
|
||||
|
||||
|
||||
/**
|
||||
* 入驻车联网平台时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "入驻车联网平台时间",width = 30,dateFormat = "yyyy-MM-dd")
|
||||
private Date businessRegistrationDate;
|
||||
|
||||
|
||||
/**
|
||||
* 服务等级
|
||||
*/
|
||||
@Excel(name = "服务等级0/1/2")
|
||||
private String serviceLevel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 认证等级0/1
|
||||
*/
|
||||
@Excel(name = "认证等级0/1")
|
||||
private String authentication;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.Business;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** BusinessMapper
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/public interface BusinessMapper extends BaseMapper<Business> {
|
||||
|
||||
/**
|
||||
* 查询企业
|
||||
*
|
||||
* @param id 企业主键
|
||||
* @return 企业
|
||||
*/
|
||||
public Business selectBusinessById(Long id);
|
||||
|
||||
/**
|
||||
* 查询企业列表
|
||||
*
|
||||
* @param business 企业
|
||||
* @return 企业集合
|
||||
*/
|
||||
public List<Business> selectBusinessList(Business business);
|
||||
|
||||
/**
|
||||
* 新增企业
|
||||
*
|
||||
* @param business 企业
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBusiness(Business business);
|
||||
|
||||
/**
|
||||
* 修改企业
|
||||
*
|
||||
* @param business 企业
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBusiness(Business business);
|
||||
|
||||
/**
|
||||
* 删除企业
|
||||
*
|
||||
* @param id 企业主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBusinessById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除企业
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBusinessByIds(Long[] ids);
|
||||
|
||||
|
||||
Result<LoginUser> info(@Param("userId") Long userId);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.business.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* RemoteUserLoginFactory
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
@FeignClient("muyu-system")
|
||||
public interface RemoteUserLoginFactory {
|
||||
|
||||
@Log(title = "用户管理",businessType = BusinessType.IMPORT)
|
||||
|
||||
@PostMapping("/user")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Business;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业 BusinessService
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
public interface BusinessService extends IService<Business> {
|
||||
|
||||
/**
|
||||
* 查询企业
|
||||
*/
|
||||
public Business selectBusinessById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 查询企业列表
|
||||
*/
|
||||
public List<Business> selectBusinessList(Business business);
|
||||
|
||||
|
||||
/**
|
||||
* 新增企业
|
||||
*/
|
||||
public int insertBusiness(Business business);
|
||||
|
||||
|
||||
/**
|
||||
* 修改企业
|
||||
*/
|
||||
public int updateBusiness(Business business);
|
||||
|
||||
/**
|
||||
* 批量删除企业
|
||||
*
|
||||
* @param ids 需要删除的企业主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBusinessByIds(Long[] ids);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除企业信息
|
||||
*/
|
||||
public int deleteBusinessById(Long id);
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.business.domain.Business;
|
||||
import com.muyu.business.service.BusinessService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Aa
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
@RestController
|
||||
public class Aa {
|
||||
@Autowired
|
||||
private BusinessService businessService;
|
||||
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.Business;
|
||||
import com.muyu.business.mapper.BusinessMapper;
|
||||
import com.muyu.business.service.BusinessService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业 BusinessServiceImpl
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/4
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> implements BusinessService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private BusinessMapper businessMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Business selectBusinessById(Long id) {
|
||||
return businessMapper.selectBusinessById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Business> selectBusinessList(Business business) {
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser user = remoteUserService.selectByUserId(loginUser.getUserid());
|
||||
if (user.getUserType().equals("00")){
|
||||
return businessMapper.selectBusinessList(business);
|
||||
}
|
||||
business.setId(Long.valueOf(user.getUserType()));
|
||||
return businessMapper.selectBusinessList(business);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBusiness(Business business) {
|
||||
|
||||
business.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
int i = businessMapper.insertBusiness(business);
|
||||
System.out.println(business);
|
||||
|
||||
SysUser sysUser = SysUser.builder()
|
||||
.userName(business.getName() + business.getId())
|
||||
.password("admin123")
|
||||
.nickName(business.getName())
|
||||
.email(business.getBusinessEmail())
|
||||
.phonenumber(business.getBusinessPhone())
|
||||
.loginIp("175.24.138.82")
|
||||
.userType(String.valueOf(business.getId()))
|
||||
.build();
|
||||
|
||||
Result add = remoteUserService.add(sysUser);
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateBusiness(Business business) {
|
||||
|
||||
business.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @ 判断redis是否存在端口号
|
||||
* @return
|
||||
*/
|
||||
public void httpConnectMysql(Business business){
|
||||
if (business.getBusinessStates().equals(2) ) {
|
||||
if (!redisTemplate.hasKey(business.getId()+business.getName())){
|
||||
redisTemplate.opsForValue()
|
||||
.set(business.getId()+
|
||||
business.getName()
|
||||
,String.valueOf(3306+business.getId()));
|
||||
extracted(business);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void extracted(Business business) {
|
||||
String postUrl="http://122.51.111.225:10006/webhook/%E6%96%B0%E5%BB%BA%E4%BC%81%E4%B8%9A%E6%95%B0%E6%8D%AE%E6%BA%90";
|
||||
HashMap<String, String> hashMap = new HashMap<>();
|
||||
hashMap.put("businessId", business.getId()+ business.getName());
|
||||
hashMap.put("mysqlPort",String.valueOf(3306+ business.getId()));
|
||||
String json = JSON.toJSONString(hashMap);
|
||||
// 3.创建连接与设置连接参数
|
||||
URL urlObj = null;
|
||||
try {
|
||||
urlObj = new URL(postUrl);
|
||||
HttpURLConnection httpConn = (HttpURLConnection) urlObj.openConnection();
|
||||
httpConn.setRequestMethod("POST");
|
||||
httpConn.setRequestProperty("Charset", "UTF-8");
|
||||
// POST请求且JSON数据,必须设置
|
||||
httpConn.setRequestProperty("Content-Type", "application/json");
|
||||
// 打开输出流,默认是false
|
||||
httpConn.setDoOutput(true);
|
||||
// // 打开输入流,默认是true,可省略
|
||||
// httpConn.setDoInput(true);
|
||||
// 4.从HttpURLConnection获取输出流和写数据
|
||||
OutputStream oStream = httpConn.getOutputStream();
|
||||
oStream.write(json.getBytes());
|
||||
oStream.flush();
|
||||
// 5.发起http调用(getInputStream触发http请求)
|
||||
if (httpConn.getResponseCode() != 200) {
|
||||
throw new Exception("调用服务端异常.");
|
||||
}
|
||||
// 6.从HttpURLConnection获取输入流和读数据
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(httpConn.getInputStream()));
|
||||
String resultData = br.readLine();
|
||||
System.out.println("从服务端返回结果: " + resultData);
|
||||
// 7.关闭HttpURLConnection连接
|
||||
httpConn.disconnect();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteBusinessByIds(Long[] ids) {
|
||||
return businessMapper.deleteBusinessByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBusinessById(Long id) {
|
||||
return businessMapper.deleteBusinessById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,32 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9211
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-business
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 命名空间
|
||||
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 命名空间
|
||||
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.zhiLian.business.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/zhiLian-data-business"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.zhiLian" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,125 @@
|
|||
<?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.muyu.business.mapper.BusinessMapper">
|
||||
|
||||
<resultMap type="com.muyu.business.domain.Business" id="BusinessResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="businessPerson" column="business_person" />
|
||||
<result property="businessLincenseNumber" column="business_lincense_number" />
|
||||
<result property="businessCreateTime" column="business_create_time" />
|
||||
<result property="businessPhone" column="business_phone" />
|
||||
<result property="businessEmail" column="business_email" />
|
||||
<result property="businessStates" column="business_states" />
|
||||
<result property="businessRegistrationDate" column="business_registration_date" />
|
||||
<result property="serviceLevel" column="service_level" />
|
||||
<result property="authentication" column="authentication" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBusinessVo">
|
||||
select id, name, business_person, business_lincense_number, business_create_time, business_phone, business_email, business_states, business_registration_date, service_level, authentication, remark, create_by, create_time, update_by, update_time from business
|
||||
</sql>
|
||||
|
||||
<select id="selectBusinessList" parameterType="com.muyu.business.domain.Business" resultMap="BusinessResult">
|
||||
<include refid="selectBusinessVo"/>
|
||||
<where>
|
||||
<if test="id != null and id != ''"> and id = #{id}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="businessPerson != null and businessPerson != ''"> and business_person = #{businessPerson}</if>
|
||||
<if test="businessLincenseNumber != null and businessLincenseNumber != ''"> and business_lincense_number = #{businessLincenseNumber}</if>
|
||||
<if test="businessCreateTime != null "> and business_create_time = #{businessCreateTime}</if>
|
||||
<if test="businessPhone != null and businessPhone != ''"> and business_phone = #{businessPhone}</if>
|
||||
<if test="businessEmail != null and businessEmail != ''"> and business_email = #{businessEmail}</if>
|
||||
<if test="businessStates != null and businessStates != ''"> and business_states = #{businessStates}</if>
|
||||
<if test="businessRegistrationDate != null "> and business_registration_date = #{businessRegistrationDate}</if>
|
||||
<if test="serviceLevel != null and serviceLevel != ''"> and service_level = #{serviceLevel}</if>
|
||||
<if test="authentication != null and authentication != ''"> and authentication = #{authentication}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBusinessById" parameterType="Long" resultMap="BusinessResult">
|
||||
<include refid="selectBusinessVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="info" resultType="com.muyu.common.system.domain.LoginUser">
|
||||
select * from sys_user where id=#{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertBusiness" parameterType="com.muyu.business.domain.Business" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into business
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="businessPerson != null">business_person,</if>
|
||||
<if test="businessLincenseNumber != null">business_lincense_number,</if>
|
||||
<if test="businessCreateTime != null">business_create_time,</if>
|
||||
<if test="businessPhone != null">business_phone,</if>
|
||||
<if test="businessEmail != null">business_email,</if>
|
||||
<if test="businessStates != null">business_states,</if>
|
||||
<if test="businessRegistrationDate != null">business_registration_date,</if>
|
||||
<if test="serviceLevel != null">service_level,</if>
|
||||
<if test="authentication != null">authentication,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="businessPerson != null">#{businessPerson},</if>
|
||||
<if test="businessLincenseNumber != null">#{businessLincenseNumber},</if>
|
||||
<if test="businessCreateTime != null">#{businessCreateTime},</if>
|
||||
<if test="businessPhone != null">#{businessPhone},</if>
|
||||
<if test="businessEmail != null">#{businessEmail},</if>
|
||||
<if test="businessStates != null">#{businessStates},</if>
|
||||
<if test="businessRegistrationDate != null">#{businessRegistrationDate},</if>
|
||||
<if test="serviceLevel != null">#{serviceLevel},</if>
|
||||
<if test="authentication != null">#{authentication},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBusiness" parameterType="com.muyu.business.domain.Business">
|
||||
update business
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="businessPerson != null">business_person = #{businessPerson},</if>
|
||||
<if test="businessLincenseNumber != null">business_lincense_number = #{businessLincenseNumber},</if>
|
||||
<if test="businessCreateTime != null">business_create_time = #{businessCreateTime},</if>
|
||||
<if test="businessPhone != null">business_phone = #{businessPhone},</if>
|
||||
<if test="businessEmail != null">business_email = #{businessEmail},</if>
|
||||
<if test="businessStates != null">business_states = #{businessStates},</if>
|
||||
<if test="businessRegistrationDate != null">business_registration_date = #{businessRegistrationDate},</if>
|
||||
<if test="serviceLevel != null">service_level = #{serviceLevel},</if>
|
||||
<if test="authentication != null">authentication = #{authentication},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBusinessById" parameterType="Long">
|
||||
delete from business where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBusinessByIds" parameterType="String">
|
||||
delete from business where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,113 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-business</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-system</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZhiLian Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 175.24.138.82:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue