Commit d17f06df authored by cq990612's avatar cq990612

优化代码结构

parent e352c138
......@@ -43,4 +43,6 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
List<WorkRole> getUserRole(Integer id);
int updateStatusById(Integer userId, Integer status);
}
......@@ -99,6 +99,11 @@
set <include refid="updateCondition"/>
where id = #{id}
</update>
<update id="updateStatusById">
update <include refid="table"/>
set status = #{status}
where id = #{userId}
</update>
<resultMap id="UserRoleMap" type="cn.wisenergy.model.dto.UserRoleDto">
......
......@@ -57,7 +57,7 @@ public interface WorkUserService {
AllRoleAndUserRoleDto getUserRoleDto(Integer userId,Integer page, Integer pageSize,Integer status);
Boolean modifyRole(Integer userId, List<Integer> roleIds);
Boolean modifyRole(Integer userId, List<Integer> roleIds,Integer status);
}
......@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
......@@ -183,14 +184,11 @@ public class WorkCollectServiceImpl implements WorkCollectService {
return true;
}
@Transactional
@Override
public Boolean updateByWorkTimeOrder(List<WorkTimeOrder> workTimeOrders) {
Integer userId;
Date workDay;
log.info("WorkCollectServiceImpl[]updateByWorkTimeOrder[]input.param.workTimeOrders:{}, " + workTimeOrders);
for (WorkTimeOrder workTimeOrder : workTimeOrders) {
userId = workTimeOrder.getUserId();
workDay = workTimeOrder.getWorkDay();
List<WorkTimeOrder> byDay = workTimeOrderMapper.getByDay(workTimeOrder.getUserId(), workTimeOrder.getWorkDay());
int total_time = 0;
for (WorkTimeOrder timeOrder : byDay) {
......
......@@ -883,7 +883,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
int pageSize = null == managerOrderVo.getPageSize() ? 10 : managerOrderVo.getPageSize();
PageHelper.startPage(page, pageSize);
return null;
}
......
......@@ -188,8 +188,8 @@ public class WorkUserServiceImpl implements WorkUserService {
@Transactional
@Override
public Boolean modifyRole(Integer userId, List<Integer> roleIds) {
log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{}" + userId, roleIds);
public Boolean modifyRole(Integer userId, List<Integer> roleIds,Integer status) {
log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{},status:{}" + userId, roleIds,status);
PageHelper.clearPage();
WorkUser workUser = workUserMapper.selectById(userId);
if (null == workUser) {
......@@ -247,7 +247,10 @@ public class WorkUserServiceImpl implements WorkUserService {
workCentreService.updateById(centre);
}
}
int i = workUserMapper.updateStatusById(userId, status);
if (i == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_DATA_FAIL);
}
workUserRoleMapper.insertBatch(userId, roleIds);
return true;
}
......
......@@ -102,18 +102,19 @@ public class SystemController extends BaseController {
@ApiOperation(value = "设置角色", notes = "设置角色", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId",value = "用户id",dataType = "int",required = true),
@ApiImplicitParam(name = "roleIds", value = "角色ids", dataType = "String", required = true)
@ApiImplicitParam(name = "roleIds", value = "角色ids", dataType = "String", required = true),
@ApiImplicitParam(name = "status",value = "用户状态",dataType = "int",required = true)
})
@PostMapping("/modifyRole")
public Result<Boolean> modifyRole(Integer userId,String roleIds) {
log.info("SystemController[]modifyRole[]input.param.userId:{},roleIds:{}" + userId, roleIds);
if (null == userId || StringUtils.isBlank(roleIds)) {
public Result<Boolean> modifyRole(Integer userId,String roleIds,Integer status) {
log.info("SystemController[]modifyRole[]input.param.userId:{},roleIds:{},status:{}" + userId, roleIds,status);
if (null == userId || StringUtils.isBlank(roleIds) || null == status) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
String[] split = roleIds.split("\\,");
Integer[] newIds = (Integer[]) ConvertUtils.convert(split, Integer.class);
List<Integer> lists = new ArrayList<>(Arrays.asList(newIds));
Boolean aBoolean = workUserService.modifyRole(userId, lists);
Boolean aBoolean = workUserService.modifyRole(userId, lists,status);
return getResult(aBoolean);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment