main
杜函宇 2 months ago
parent 9e87d92a68
commit 368c71aaa8

@ -3,6 +3,9 @@ package com.ruoyi.tc.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.tc.entity.Unit;
import com.ruoyi.tc.entity.request.UnitRequest;
import com.ruoyi.common.enums.BusinessType;
@ -44,6 +47,9 @@ public class UnitController {
@Resource
private ExamineInfoService examineInfoService;
@Resource
private ISysUserService iSysUserService;
/**
*
*/
@ -130,10 +136,8 @@ public class UnitController {
@PutMapping
@Transactional(rollbackFor = Exception.class)
public AjaxResult edit(@RequestBody Unit x) {
Unit byId = unitService.getById(x.getId());
if (!byId.getUserName().equals(x.getUserName()) || !byId.getNickName().equals(x.getNickName())) {
throw new ServiceException("不允许修改单位名称和统一信用代码!");
}
//查询用户表是否存在该用户
unitService.validUser(x);
unitService.updateById(x);
if(!x.getOtherConcat().isEmpty()){
x.getOtherConcat().forEach(y->{
@ -159,7 +163,13 @@ public class UnitController {
public AjaxResult remove(@PathVariable Long id) {
List<String> userNames = unitService.selectByIds(id);
//逻辑删除单位和用户
unitService.deleteUsers(userNames);
if(!userNames.isEmpty()){
for (String it : userNames) {
if(it!=null){
unitService.deleteUsers(it);
}
}
}
unitService.deleteUnits(id);
unitOtherConcatService.deleteByUnitIds(id);
examineInfoService.deleteByUnitIds(id);

@ -44,7 +44,7 @@ public interface UnitMapper extends BaseMapper<Unit> {
/**
*
*/
void deleteUsers(List<String> userNames);
void deleteUsers(@Param("userNames") String userNames);
/**
* id

@ -50,7 +50,7 @@ public interface UnitService extends IService<Unit> {
/**
*
*/
void deleteUsers(List<String> userNames);
void deleteUsers(String userNames);
/**
*
*/

@ -35,8 +35,6 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
*/
@Override
public Page<Unit> page(Page<Unit> page, UnitRequest unit) {
return baseMapper.selectUnitList(page,unit);
}
@ -61,10 +59,11 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
/**
*
*
*/
@Override
public void validUser(Unit x) {
if(x.getUserName()!=null && x.getUserName().length()>6){
SysUser user = new SysUser();
user.setUserName(x.getUserName());
user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6)));
@ -75,7 +74,9 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
Long[] roles = new Long[]{100L};
userService.insertUserAuth(user.getUserId(), roles);
}else {
throw new ServiceException(x.getUserName() + "'已存在单位!");
//只修改用户账号,密码,单位名称
userService.updateUserProfile(user);
}
}
}
@ -90,7 +91,7 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
*
*/
@Override
public void deleteUsers(List<String> userNames) {
public void deleteUsers(String userNames) {
baseMapper.deleteUsers(userNames);
}

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.tc.mapper.ExamineInfoMapper">
<update id="deleteByUnitIds">
update asset_examine_info set del_flag = '2' where unit_id = #{id}
update unit_examine_info set del_flag = '2' where unit_id = #{id}
</update>
</mapper>

@ -133,9 +133,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update unit_info set del_flag = '2' where id = #{id}
</update>
<update id="deleteUsers">
update sys_user set del_flag = '2' where user_name in
<foreach collection="array" item="userNames" open="(" separator="," close=")">
#{userNames}
</foreach>
update sys_user set del_flag = '2' where user_name = #{userNames}
</update>
</mapper>

@ -5,9 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.tc.mapper.UnitOtherConcatMapper">
<update id="deleteByUnitIds">
update asset_supply_chain set del_flag = '2' where unit_id = #{id}
update unit_other_contact set del_flag = '2' where unit_id = #{id}
</update>
<update id="deleteByAssetIds">
update asset_supply_chain set del_flag = '2' where asset_id = #{id}
update unit_other_contact set del_flag = '2' where asset_id = #{id}
</update>
</mapper>
Loading…
Cancel
Save