feat:更新业务平台车辆录入
parent
2332d433c6
commit
b619c0341c
|
@ -0,0 +1,33 @@
|
|||
package com.zhiLian.business.domain;
|
||||
|
||||
|
||||
import com.zhiLian.common.system.domain.SysRole;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 授权角色返回结果集
|
||||
* @Date 2023-6-19 下午 02:50
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthRoleResp {
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private SysUser user;
|
||||
|
||||
/**
|
||||
* 角色集合
|
||||
*/
|
||||
private List<SysRole> roles;
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.zhiLian.business.domain;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
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.zhiLian.common.core.annotation.Excel;
|
||||
|
@ -32,6 +34,7 @@ public class Business extends BaseEntity
|
|||
|
||||
/** 企业主键 */
|
||||
@Excel(name = "企业主键")
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 企业名称 */
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.zhiLian.business.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.system.domain.LoginUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -60,4 +63,6 @@ public interface BusinessMapper extends BaseMapper<Business>
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteBusinessByIds(Long[] ids);
|
||||
|
||||
Result<LoginUser> info(@Param("userId") Long userId);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package com.zhiLian.business.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhiLian.business.domain.AuthRoleResp;
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.business.mapper.BusinessMapper;
|
||||
import com.zhiLian.business.remote.factory.RemoteUserLoginFactory;
|
||||
import com.zhiLian.business.service.IBusinessService;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.core.utils.DateUtils;
|
||||
import com.zhiLian.common.security.utils.SecurityUtils;
|
||||
import com.zhiLian.common.system.domain.LoginUser;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import com.zhiLian.common.system.remote.RemoteUserService;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -43,6 +48,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
return businessMapper.selectBusinessById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询企业列表
|
||||
*
|
||||
|
@ -52,6 +58,15 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
@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()));
|
||||
// List<Business> businesses = this.selectBusinessList(business);
|
||||
// System.out.println(businesses);
|
||||
return businessMapper.selectBusinessList(business);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.zhiLian.business.text; /**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName text
|
||||
* @Date 2024/05/29 10:31
|
||||
*/
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DatabaseInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 数据库连接URL,格式为:jdbc:子协议:子名称
|
||||
String jdbcUrl = "jdbc:mysql://122.51.111.225:3306/day1?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false";
|
||||
String username = "root";
|
||||
String password = "hbr@123";
|
||||
|
||||
Connection connection = null;
|
||||
|
||||
try {
|
||||
// 加载数据库驱动类(对于大多数数据库,这一步不是必需的,因为驱动会在第一次连接时自动加载)
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
|
||||
// 建立数据库连接
|
||||
connection = DriverManager.getConnection(jdbcUrl, username, password);
|
||||
|
||||
// 连接成功,可以在此执行SQL操作
|
||||
System.out.println("数据库连接成功!");
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println("数据库驱动未找到!");
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
System.out.println("数据库连接失败!");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 确保在结束时关闭连接
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectBusinessList" parameterType="com.zhiLian.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>
|
||||
|
@ -47,6 +48,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectBusinessVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="info" resultType="com.zhiLian.common.system.domain.LoginUser">
|
||||
select * from sys_user where id=#{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertBusiness" parameterType="com.zhiLian.business.domain.Business" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into business
|
||||
|
|
|
@ -28,7 +28,6 @@ public interface RemoteUserService {
|
|||
*/
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
|
@ -42,4 +41,13 @@ public interface RemoteUserService {
|
|||
|
||||
@PostMapping("/user")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> info (@PathVariable("username") String username);
|
||||
|
||||
@GetMapping("/user/authRole/{userId}")
|
||||
public Result authRole (@PathVariable("userId") Long userId);
|
||||
|
||||
@GetMapping("/user/selectByUserId/{userId}")
|
||||
public SysUser selectByUserId (@PathVariable("userId") Long userId);
|
||||
}
|
||||
|
|
|
@ -31,13 +31,26 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
//好像写有 添加用户 远程调用是这个?不知道启动一下吧应该没问题OK 你先学 我自己再看看
|
||||
|
||||
@Override
|
||||
public Result add(SysUser user) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<LoginUser> info(String username) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result authRole(Long userId) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectByUserId(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
@InnerAuth
|
||||
// @InnerAuth
|
||||
@GetMapping("/info/{username}")
|
||||
public Result<LoginUser> info (@PathVariable("username") String username) {
|
||||
SysUser sysUser = userService.selectUserByUserName(username);
|
||||
|
@ -257,7 +257,7 @@ public class SysUserController extends BaseController {
|
|||
/**
|
||||
* 根据用户编号获取授权角色
|
||||
*/
|
||||
@RequiresPermissions("system:user:query")
|
||||
// @RequiresPermissions("system:user:query")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public Result authRole (@PathVariable("userId") Long userId) {
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
|
@ -269,6 +269,11 @@ public class SysUserController extends BaseController {
|
|||
.build()
|
||||
);
|
||||
}
|
||||
@GetMapping("/selectByUserId/{userId}")
|
||||
public SysUser selectByUserId (@PathVariable("userId") Long userId) {
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
|
|
|
@ -3,6 +3,10 @@ package com.zhiLian.vehicle.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhiLian.common.core.utils.DateUtils;
|
||||
import com.zhiLian.common.security.utils.SecurityUtils;
|
||||
import com.zhiLian.common.system.domain.LoginUser;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import com.zhiLian.common.system.remote.RemoteUserService;
|
||||
import com.zhiLian.vehicle.domain.Vehicle;
|
||||
import com.zhiLian.vehicle.mapper.VehicleMapper;
|
||||
import com.zhiLian.vehicle.service.IVehicleService;
|
||||
|
@ -35,6 +39,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
|
|||
{
|
||||
return vehicleMapper.selectVehicleById(id);
|
||||
}
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 查询车辆录入列表
|
||||
|
@ -45,6 +51,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
|
|||
@Override
|
||||
public List<Vehicle> selectVehicleList(Vehicle vehicle)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser user = remoteUserService.selectByUserId(loginUser.getUserid());
|
||||
if (user.getUserType().equals("00")) {
|
||||
return vehicleMapper.selectVehicleList(vehicle);
|
||||
}
|
||||
vehicle.setId(Long.valueOf(user.getUserType()));
|
||||
return vehicleMapper.selectVehicleList(vehicle);
|
||||
}
|
||||
|
||||
|
@ -97,4 +109,5 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
|
|||
{
|
||||
return vehicleMapper.deleteVehicleById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectVehicleList" parameterType="com.zhiLian.vehicle.domain.Vehicle" resultMap="VehicleResult">
|
||||
<include refid="selectVehicleVo"/>
|
||||
<where>
|
||||
<if test="id != null "> and id = #{id}</if>
|
||||
<if test="number != null "> and number = #{number}</if>
|
||||
<if test="typeId != null "> and type_id = #{typeId}</if>
|
||||
<if test="electonicId != null "> and electonic_id = #{electonicId}</if>
|
||||
|
|
Loading…
Reference in New Issue