1
0

WEB:客户管理

This commit is contained in:
2025-07-03 14:17:53 +08:00
parent b06e071196
commit 5bc56ca36d
5 changed files with 20 additions and 19 deletions

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.customer.controller; package com.fuyuanshen.customer.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.crypto.digest.BCrypt;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.core.domain.ResponseVO; import com.fuyuanshen.common.core.domain.ResponseVO;
import com.fuyuanshen.common.core.utils.StringUtils; import com.fuyuanshen.common.core.utils.StringUtils;
@ -63,6 +64,7 @@ public class CustomerController {
if (StringUtils.isBlank(customer.getPassword())) { if (StringUtils.isBlank(customer.getPassword())) {
throw new BadRequestException("账号密码不能为空"); throw new BadRequestException("账号密码不能为空");
} }
customer.setPassword(BCrypt.hashpw(customer.getPassword()));
customerService.addCustomer(customer); customerService.addCustomer(customer);
return ResponseVO.success("新增客户成功!!!"); return ResponseVO.success("新增客户成功!!!");
} }

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.customer.domain.vo; package com.fuyuanshen.customer.domain.vo;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -16,11 +17,10 @@ import java.util.Objects;
*/ */
@Getter @Getter
@Setter @Setter
public class ConsumerVo implements Serializable { public class ConsumerVo extends TenantEntity {
@Schema(name = "ID", hidden = true) @Schema(name = "ID", hidden = true)
private Long id; private Long customerId;
@Schema(hidden = true) @Schema(hidden = true)
private Long deptId; private Long deptId;
@ -31,9 +31,8 @@ public class ConsumerVo implements Serializable {
@Schema(hidden = true) @Schema(hidden = true)
private Byte userLevel; private Byte userLevel;
@Schema(name = "账号") @Schema(name = "账号")
private String username; private String userName;
@Schema(name = "用户昵称") @Schema(name = "用户昵称")
private String nickName; private String nickName;
@ -65,15 +64,9 @@ public class ConsumerVo implements Serializable {
@Schema(name = "最后修改密码的时间", hidden = true) @Schema(name = "最后修改密码的时间", hidden = true)
private Date pwdResetTime; private Date pwdResetTime;
/**
* 租户ID
*/
@Schema(hidden = true)
private Long tenantId;
private List<ConsumerVo> children; private List<ConsumerVo> children;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@ -83,13 +76,13 @@ public class ConsumerVo implements Serializable {
return false; return false;
} }
ConsumerVo consumer = (ConsumerVo) o; ConsumerVo consumer = (ConsumerVo) o;
return Objects.equals(id, consumer.id) && Objects.equals(username, consumer.username); return Objects.equals(customerId, consumer.customerId) && Objects.equals(userName, consumer.userName);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, username); return Objects.hash(customerId, userName);
} }

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?> <?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" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.fuyuanshen.fyscustomer.mapper.CustomerMapper"> <mapper namespace="com.fuyuanshen.customer.mapper.CustomerMapper">
<resultMap id="BaseResultMap" type="com.fuyuanshen.customer.domain.Customer"> <resultMap id="BaseResultMap" type="com.fuyuanshen.customer.domain.Customer">
<id column="user_user_id" property="userId"/> <id column="user_user_id" property="customerId"/>
<result column="user_dept_id" property="deptId"/> <result column="user_dept_id" property="deptId"/>
<result column="user_user_name" property="userName"/> <result column="user_user_name" property="userName"/>
<result column="user_nick_name" property="nickName"/> <result column="user_nick_name" property="nickName"/>
@ -94,7 +94,7 @@
<!-- 分页查询客户 --> <!-- 分页查询客户 -->
<select id="findCustomers" resultType="com.fuyuanshen.customer.domain.Customer"> <select id="findCustomers" resultType="com.fuyuanshen.customer.domain.Customer">
select select
u.user_id as id, u.nick_name , u.user_name, u.enabled, u.create_time u.user_id as customerId, u.nick_name , u.user_name, u.enabled, u.create_time
from sys_user u from sys_user u
<where> <where>
<if test="criteria.ids != null and !criteria.ids.isEmpty()"> <if test="criteria.ids != null and !criteria.ids.isEmpty()">
@ -180,7 +180,7 @@
from sys_user u from sys_user u
<where> <where>
<if test="criteria.customerName != null and criteria.customerName.trim() != ''"> <if test="criteria.customerName != null and criteria.customerName.trim() != ''">
and u.user_name = concat('%', TRIM(#{criteria.customerName}), '%') and u.user_name = TRIM(#{criteria.customerName})
</if> </if>
</where> </where>
</select> </select>

View File

@ -120,7 +120,7 @@ public class DeviceController {
// @Log("撤回设备") // @Log("撤回设备")
@Operation(summary = "撤回设备") @Operation(summary = "撤回分配设备")
@PostMapping(value = "/withdraw") @PostMapping(value = "/withdraw")
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) { public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
try { try {

View File

@ -253,6 +253,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
device.setId( null); device.setId( null);
device.setCurrentOwnerId(customerId); device.setCurrentOwnerId(customerId);
deviceMapper.insert( device); deviceMapper.insert( device);
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
deviceType.setId( null);
device.setCurrentOwnerId(customerId);
deviceTypeMapper.insert( deviceType);
}); });
} }