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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult; 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.Unit;
import com.ruoyi.tc.entity.request.UnitRequest; import com.ruoyi.tc.entity.request.UnitRequest;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
@ -44,6 +47,9 @@ public class UnitController {
@Resource @Resource
private ExamineInfoService examineInfoService; private ExamineInfoService examineInfoService;
@Resource
private ISysUserService iSysUserService;
/** /**
* *
*/ */
@ -130,10 +136,8 @@ public class UnitController {
@PutMapping @PutMapping
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult edit(@RequestBody Unit x) { public AjaxResult edit(@RequestBody Unit x) {
Unit byId = unitService.getById(x.getId()); //查询用户表是否存在该用户
if (!byId.getUserName().equals(x.getUserName()) || !byId.getNickName().equals(x.getNickName())) { unitService.validUser(x);
throw new ServiceException("不允许修改单位名称和统一信用代码!");
}
unitService.updateById(x); unitService.updateById(x);
if(!x.getOtherConcat().isEmpty()){ if(!x.getOtherConcat().isEmpty()){
x.getOtherConcat().forEach(y->{ x.getOtherConcat().forEach(y->{
@ -159,7 +163,13 @@ public class UnitController {
public AjaxResult remove(@PathVariable Long id) { public AjaxResult remove(@PathVariable Long id) {
List<String> userNames = unitService.selectByIds(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); unitService.deleteUnits(id);
unitOtherConcatService.deleteByUnitIds(id); unitOtherConcatService.deleteByUnitIds(id);
examineInfoService.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 * 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 @Override
public Page<Unit> page(Page<Unit> page, UnitRequest unit) { public Page<Unit> page(Page<Unit> page, UnitRequest unit) {
return baseMapper.selectUnitList(page,unit); return baseMapper.selectUnitList(page,unit);
} }
@ -61,21 +59,24 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
/** /**
* *
*/ */
@Override @Override
public void validUser(Unit x) { public void validUser(Unit x) {
SysUser user = new SysUser(); if(x.getUserName()!=null && x.getUserName().length()>6){
user.setUserName(x.getUserName()); SysUser user = new SysUser();
user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6))); user.setUserName(x.getUserName());
user.setNickName(x.getNickName()); user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6)));
SysUser u = userService.selectUserByUserName(x.getUserName()); user.setNickName(x.getNickName());
if (StringUtils.isNull(u)) { SysUser u = userService.selectUserByUserName(x.getUserName());
userService.insertUser(user); if (StringUtils.isNull(u)) {
Long[] roles = new Long[]{100L}; userService.insertUser(user);
userService.insertUserAuth(user.getUserId(), roles); Long[] roles = new Long[]{100L};
}else { userService.insertUserAuth(user.getUserId(), roles);
throw new ServiceException(x.getUserName() + "'已存在单位!"); }else {
//只修改用户账号,密码,单位名称
userService.updateUserProfile(user);
}
} }
} }
@ -90,7 +91,7 @@ public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements Un
* *
*/ */
@Override @Override
public void deleteUsers(List<String> userNames) { public void deleteUsers(String userNames) {
baseMapper.deleteUsers(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"> <!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"> <mapper namespace="com.ruoyi.tc.mapper.ExamineInfoMapper">
<update id="deleteByUnitIds"> <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> </update>
</mapper> </mapper>

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

@ -5,9 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.tc.mapper.UnitOtherConcatMapper"> <mapper namespace="com.ruoyi.tc.mapper.UnitOtherConcatMapper">
<update id="deleteByUnitIds"> <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>
<update id="deleteByAssetIds"> <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> </update>
</mapper> </mapper>
Loading…
Cancel
Save