Ver Fonte

add:设备号解除功能

yonge há 4 anos atrás
pai
commit
42cc1fb092

+ 10 - 0
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysUserDevice.java

@@ -22,6 +22,8 @@ public class SysUserDevice {
 	/** 设备类型 */
 	private String deviceType;
 	
+	private SysUser user;
+	
 	public void setId(Integer id){
 		this.id = id;
 	}
@@ -62,6 +64,14 @@ public class SysUserDevice {
 		return this.deviceType;
 	}
 			
+	public SysUser getUser() {
+		return user;
+	}
+
+	public void setUser(SysUser user) {
+		this.user = user;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 5 - 0
mec-auth/mec-auth-server/pom.xml

@@ -74,6 +74,11 @@
 			<groupId>com.ym</groupId>
 			<artifactId>mec-client-api</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>com.yonge.log</groupId>
+			<artifactId>audit-log</artifactId>
+		</dependency>
 
 		<dependency>
 			<groupId>org.apache.commons</groupId>

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/AuthServerApplication.java

@@ -18,7 +18,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @EnableDiscoveryClient
 @EnableFeignClients({"com.ym.mec"})
 @MapperScan("com.ym.mec.auth.dal.dao")
-@ComponentScan(basePackages="com.ym.mec")
+@ComponentScan(basePackages={"com.ym.mec", "com.yonge.log"})
 @Configuration
 @EnableSwagger2Doc
 @EnableAsync

+ 33 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/interceptor/OperationLogInterceptor.java

@@ -0,0 +1,33 @@
+package com.ym.mec.auth.interceptor;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.yonge.log.interceptor.AuditLogInterceptor;
+
+@Component
+public class OperationLogInterceptor extends AuditLogInterceptor {
+
+	@Autowired
+	@Lazy
+	private SysUserFeignService sysUserFeignService;
+
+	@Override
+	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException, IOException {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser != null) {
+			setUsername(sysUser.getRealName(),sysUser.getId());
+		}
+		return true;
+	}
+
+}

+ 42 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserDeviceController.java

@@ -0,0 +1,42 @@
+package com.ym.mec.auth.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.auth.service.SysUserDeviceService;
+import com.ym.mec.auth.service.SysUserService;
+import com.ym.mec.auth.web.controller.queryInfo.SysUserDeviceQueryInfo;
+import com.ym.mec.common.controller.BaseController;
+import com.yonge.log.model.AuditLogAnnotation;
+
+@RestController()
+@RequestMapping("userDevice")
+@Api(tags = "会员设备服务")
+public class UserDeviceController extends BaseController {
+
+	@Autowired
+	private SysUserService sysUserService;
+	
+	@Autowired
+	private SysUserDeviceService sysUserDeviceService;
+
+	@ApiOperation(value = "分页查询用户信息")
+	@GetMapping(value = "/queryPage")
+	public Object queryPage(SysUserDeviceQueryInfo queryInfo) {
+		return succeed(sysUserDeviceService.queryPage(queryInfo));
+	}
+
+	@ApiOperation(value = "分页查询用户信息")
+	@PostMapping(value = "/unbind")
+	@AuditLogAnnotation(operateName = "帮助中心内容删除",interfaceURL = "helpCenterContent/delete")
+	public Object unbind(Integer id) {
+		return succeed(sysUserDeviceService.delete(id));
+	}
+
+}

+ 38 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/queryInfo/SysUserDeviceQueryInfo.java

@@ -0,0 +1,38 @@
+package com.ym.mec.auth.web.controller.queryInfo;
+
+import java.util.Date;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class SysUserDeviceQueryInfo extends QueryInfo {
+
+	private String deviceNum;
+
+	private Date bindStartTime;
+
+	private Date bindEndTime;
+
+	public String getDeviceNum() {
+		return deviceNum;
+	}
+
+	public void setDeviceNum(String deviceNum) {
+		this.deviceNum = deviceNum;
+	}
+
+	public Date getBindStartTime() {
+		return bindStartTime;
+	}
+
+	public void setBindStartTime(Date bindStartTime) {
+		this.bindStartTime = bindStartTime;
+	}
+
+	public Date getBindEndTime() {
+		return bindEndTime;
+	}
+
+	public void setBindEndTime(Date bindEndTime) {
+		this.bindEndTime = bindEndTime;
+	}
+}

+ 33 - 2
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysUserDeviceMapper.xml

@@ -9,6 +9,8 @@
 		<result column="device_num_" property="deviceNum" />
 		<result column="bind_time_" property="bindTime" />
 		<result column="device_type_" property="deviceType" />
+		<result column="phone_" property="user.phone" />
+		<result column="real_name_" property="user.realName" />
 	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
@@ -63,13 +65,42 @@
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="SysUserDevice" parameterType="map">
-		SELECT * FROM sys_user_device ORDER BY id_
+		SELECT ud.*,u.phone_,u.real_name_ FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_ 
+		<where>
+			<if test="search != null and search != ''">
+				and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
+			</if>
+			<if test="deviceNum != null">
+				and device_num_ = #{deviceNum}
+			</if>
+			<if test="bindStartTime != null">
+				and bind_time_ &gt;= #{bindStartTime}
+			</if>
+			<if test="bindEndTime != null">
+				and bind_time_ &lt;= #{bindEndTime}
+			</if>
+		</where>
+		ORDER BY id_
 		<include refid="global.limit" />
 	</select>
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_user_device
+		SELECT COUNT(ud.user_id_) FROM sys_user_device ud left join sys_user u on ud.user_id_ = u.id_
+		<where>
+			<if test="search != null and search != ''">
+				and (u.real_name_ LIKE CONCAT('%',#{search},'%') OR u.phone_ LIKE CONCAT('%',#{search},'%') OR u.id_ like CONCAT('%',#{search},'%'))
+			</if>
+			<if test="deviceNum != null">
+				and device_num_ = #{deviceNum}
+			</if>
+			<if test="bindStartTime != null">
+				and bind_time_ &gt;= #{bindStartTime}
+			</if>
+			<if test="bindEndTime != null">
+				and bind_time_ &lt;= #{bindEndTime}
+			</if>
+		</where>
 	</select>
 	
 	<select id="queryByUserId" resultMap="SysUserDevice">