userResource提交

master
赵嘉伟 3 years ago
parent abed5edf44
commit 1f3e67c8b0

@ -19,8 +19,8 @@ import java.util.Map;
/**
*
* @author robert
* @since 2021-06-24
* @author zjw
* @since 2021-08-18
*/
@RestController
@RequestMapping("/Z-USER-RESOURCE")
@ -32,7 +32,6 @@ public class UserResourceController {
@Autowired
public UserService userService;
/**
* id
*
@ -86,6 +85,7 @@ public class UserResourceController {
.or().like(UserResource::getStatus, frontPage.getGlobalQuery())
.or().like(UserResource::getCreatedUser, frontPage.getGlobalQuery())
.or().like(UserResource::getModifiedUser, frontPage.getGlobalQuery())
.or().like(UserResource::getExistUser, frontPage.getGlobalQuery())
);
}
result = userResourceService.page(frontPage.getPagePlus(), queryWrapper);

@ -14,8 +14,8 @@ import java.util.List;
* Mapper
* </p>
*
* @author robert
* @since 2021-06-24
* @author zjw
* @since 2021-08-18
*/
@Repository
public interface UserResourceMapper extends BaseMapper<UserResource> {
@ -27,4 +27,6 @@ public interface UserResourceMapper extends BaseMapper<UserResource> {
List<UserResourceDto> findAll(@Param("site") String site, @Param("resource") String resource, @Param("userId") String userId);
void deleteByUserAndResource(@Param("user")String user,@Param("resource")String resource);
}

@ -14,8 +14,8 @@ import java.time.LocalDateTime;
*
* </p>
*
* @author robert
* @since 2021-06-24
* @author zjw
* @since 2021-08-18
*/
@TableName("Z_USER_RESOURCE")
@ -89,6 +89,11 @@ public class UserResource extends Model<UserResource> {
*/
@TableField("MODIFIED_DATE_TIME")
private LocalDateTime modifiedDateTime;
/**
*
*/
@TableField("EXIST_USER")
private String existUser;
public String getHandle() {
@ -195,6 +200,14 @@ public class UserResource extends Model<UserResource> {
this.modifiedDateTime = modifiedDateTime;
}
public String getExistUser() {
return existUser;
}
public void setExistUser(String existUser) {
this.existUser = existUser;
}
public static final String HANDLE = "HANDLE";
public static final String SITE = "SITE";
@ -221,6 +234,8 @@ public static final String MODIFIED_USER = "MODIFIED_USER";
public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME";
public static final String EXIST_USER = "EXIST_USER";
@Override
protected Serializable pkVal() {
@ -243,6 +258,7 @@ public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME";
", createdDateTime = " + createdDateTime +
", modifiedUser = " + modifiedUser +
", modifiedDateTime = " + modifiedDateTime +
", existUser = " + existUser +
"}";
}
}

@ -15,11 +15,20 @@ import java.util.List;
*
* </p>
*
* @author robert
* @since 2021-06-24
* @author zjw
* @since 2021-08-18
*/
public interface UserResourceService extends IService<UserResource> {
/**
*
* @param frontPage
* @return
*/
IPage<UserResource> selectPage(FrontPage<UserResource> frontPage, UserResource userResource);
List<UserResource> selectList(UserResource userResource);
List<NwaUser> findEmployeeList(String site, String resourceType);
List<UserResource> findEnableList(String site, String resource, String user);
@ -28,5 +37,4 @@ public interface UserResourceService extends IService<UserResource> {
void saveAll(List<UserResourceDto> userResourceDtoList,String resource,String user);
}

@ -1,5 +1,7 @@
package com.foreverwin.mesnac.dispatch.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.dto.UsrDto;
import com.foreverwin.mesnac.common.enums.HandleEnum;
@ -9,10 +11,10 @@ import com.foreverwin.mesnac.dispatch.mapper.UserResourceMapper;
import com.foreverwin.mesnac.dispatch.model.UserResource;
import com.foreverwin.mesnac.dispatch.service.UserResourceService;
import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,8 +28,8 @@ import java.util.List;
*
* </p>
*
* @author robert
* @since 2021-06-24
* @author zjw
* @since 2021-08-18
*/
@Service
@Transactional(rollbackFor = Exception.class)
@ -37,7 +39,6 @@ public class UserResourceServiceImpl extends ServiceImpl<UserResourceMapper, Use
@Autowired
private UserResourceMapper userResourceMapper;
@Autowired
private ResrceService resrceService;
@ -45,6 +46,21 @@ public class UserResourceServiceImpl extends ServiceImpl<UserResourceMapper, Use
@Autowired
private UserService userService;
@Override
public IPage<UserResource> selectPage(FrontPage<UserResource> frontPage, UserResource userResource) {
QueryWrapper<UserResource> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(userResource);
return super.page(frontPage.getPagePlus(), queryWrapper);
}
@Override
public List<UserResource> selectList(UserResource userResource) {
QueryWrapper<UserResource> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(userResource);
return super.list(queryWrapper);
}
@Override
public List<NwaUser> findEmployeeList(String site, String resourceType) {
return userResourceMapper.findEmployeeList(site, resourceType);
@ -62,7 +78,7 @@ public class UserResourceServiceImpl extends ServiceImpl<UserResourceMapper, Use
String userId = userResourceDto.getUserId();
HashMap<String, Object> hashMap = new HashMap<>();;
// List<NwaUser> nwaUserList = nwaUserService.selectList(null);
// List<NwaUser> nwaUserList = nwaUserService.selectList(null);
List<UsrDto> nwaUserList = userService.findList(null);
List<UserResourceDto> userResourceList = userResourceMapper.findAll(site, resource, userId);
@ -93,7 +109,7 @@ public class UserResourceServiceImpl extends ServiceImpl<UserResourceMapper, Use
//NwaUser userByUserName = nwaUserService.findUserByUserName(userResource.getUserId());
List<UsrDto> userByUserName = userService.findList(userResource.getUserId());
if("false".equals(userResource.getTemporaryUser()) &&
userByUserName.size() <= 0){
userByUserName.size() <= 0){
throw BusinessException.build("第"+(i+1)+"行的用户不存在,必须为临时用户");
}else if(userByUserName != null && userByUserName.size() > 0){
//userByUserName.setFullName(userResource.getUserDescription());
@ -117,4 +133,8 @@ public class UserResourceServiceImpl extends ServiceImpl<UserResourceMapper, Use
}
}
}

@ -17,17 +17,18 @@
<result column="CREATED_DATE_TIME" property="createdDateTime" />
<result column="MODIFIED_USER" property="modifiedUser" />
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
<result column="EXIST_USER" property="existUser" />
</resultMap>
<resultMap id="UserResourceDto" type="com.foreverwin.mesnac.dispatch.dto.UserResourceDto" extends="BaseResultMap">
<result column="SEQ" property="seq"/>
<result column="RESOURCE_DESCRIPTION" property="resrceDescription"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, SITE, RESOURCE_BO, RESRCE, RESRCE_DESCRIPTION, USER_ID, USER_DESCRIPTION, TEMPORARY_USER, STATUS, CREATED_USER, CREATED_DATE_TIME, MODIFIED_USER, MODIFIED_DATE_TIME
HANDLE, SITE, RESOURCE_BO, RESRCE, RESRCE_DESCRIPTION, USER_ID, USER_DESCRIPTION, TEMPORARY_USER, STATUS, CREATED_USER, CREATED_DATE_TIME, MODIFIED_USER, MODIFIED_DATE_TIME, EXIST_USER
</sql>
<!-- BaseMapper标准查询/修改/删除 -->
@ -74,6 +75,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</where>
</select>
@ -97,6 +99,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -128,6 +131,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -159,6 +163,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -190,6 +195,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -221,6 +227,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -252,6 +259,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -279,6 +287,7 @@
<if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
<if test="modifiedUser!=null">MODIFIED_USER,</if>
<if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
<if test="existUser!=null">EXIST_USER,</if>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
@ -294,6 +303,7 @@
<if test="createdDateTime!=null">#{createdDateTime},</if>
<if test="modifiedUser!=null">#{modifiedUser},</if>
<if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
<if test="existUser!=null">#{existUser},</if>
</trim>
</insert>
@ -316,6 +326,7 @@
#{createdDateTime},
#{modifiedUser},
#{modifiedDateTime},
#{existUser},
</trim>
</insert>
@ -334,6 +345,7 @@
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
<if test="et.existUser!=null">EXIST_USER=#{et.existUser},</if>
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
@ -352,6 +364,7 @@
CREATED_DATE_TIME=#{et.createdDateTime},
MODIFIED_USER=#{et.modifiedUser},
MODIFIED_DATE_TIME=#{et.modifiedDateTime},
EXIST_USER=#{et.existUser},
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
@ -370,6 +383,7 @@
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.modifiedUser!=null">MODIFIED_USER=#{et.modifiedUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
<if test="et.existUser!=null">EXIST_USER=#{et.existUser},</if>
</trim>
<where>
<if test="ew!=null">
@ -387,6 +401,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -435,6 +450,7 @@
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedUser!=null"> AND MODIFIED_USER=#{ew.entity.modifiedUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.existUser!=null"> AND EXIST_USER=#{ew.entity.existUser}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -452,6 +468,7 @@
</foreach>)
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="findEnableList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM Z_USER_RESOURCE
@ -467,9 +484,9 @@
<select id="findEmployeeList" resultType="com.foreverwin.mesnac.meapi.model.NwaUser">
SELECT DISTINCT A.SITE, A.USER_ID USER_NAME, B.FIRST_NAME, B.LAST_NAME, NVL(B.FULL_NAME, A.USER_DESCRIPTION) FULL_NAME
FROM Z_USER_RESOURCE A
INNER JOIN RESOURCE_TYPE_RESOURCE WM ON WM.RESOURCE_BO = A.RESOURCE_BO
INNER JOIN RESOURCE_TYPE RT ON RT.HANDLE = WM.RESOURCE_TYPE_BO
LEFT JOIN Z_NWA_USER B ON A.SITE = B.SITE AND A.USER_ID = B.USER_NAME
INNER JOIN RESOURCE_TYPE_RESOURCE WM ON WM.RESOURCE_BO = A.RESOURCE_BO
INNER JOIN RESOURCE_TYPE RT ON RT.HANDLE = WM.RESOURCE_TYPE_BO
LEFT JOIN Z_NWA_USER B ON A.SITE = B.SITE AND A.USER_ID = B.USER_NAME
WHERE A.SITE = #{site} AND RT.RESOURCE_TYPE = #{resourceType}
</select>
@ -493,10 +510,11 @@
<if test="user != null and user != ''">
USER_ID LIKE '%${user}%'
</if>
<if test="resource != null and resource != ''">
<if test="resource != null and resource != ''">
AND RESRCE LIKE '%${resource}%'
</if>
</if>
</where>
</select>
</mapper>

Loading…
Cancel
Save