智慧保安后台管理-外网项目备份
Administrator
2021-09-25 7870a37ab0ab0fdc09ba91b1ac209c91a18c0bc8
用户注册校验修改,用户curd 修改
11 files modified
158 ■■■■ changed files
src/main/java/org/springblade/modules/information/controller/InformationController.java 9 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java 45 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IUserService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 30 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/zc/controller/ZcController.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/zc/mapper/ZcMapper.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/zc/mapper/ZcMapper.xml 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/zc/service/IZcService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/zc/service/impl/ZcServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/controller/InformationController.java
@@ -185,6 +185,7 @@
        }
        informationService.save(information);
        String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(information.getEstablishtime());
        Integer isDeleted = 0;
        //Integer id = information.getId();
        String s = "insert into sys_information(id,creditCode,enterpriseName,representative,establishTime," +
            "registeredCapital,organizationCode,registrationNumber, enterprises, address," +
@@ -195,8 +196,12 @@
            information.getRegion() + "'" + "," + "'" + information.getRegistration() + "'" + "," + "'" + information.getIndustry() + "'" + "," + "'" + information.getDepartmentid() + "'" + "," +
            "'" + information.getStats() + "'" + "," + "'" + information.getJurisdiction() + "'" + "," + "'" + information.getRepresentativecell() + "'" + "," +
            "'" + information.getContacts() + "'" + "," + "'" + information.getContactscell() + "'" + ");" +
            "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category) values(" + "'" + information.getDepartmentid() + "'" + "," + "'" + dept.getParentId() + "'" + ","
            + "'" + dept.getTenantId() + "'" + "," + "'" + information.getEnterprisename() + "'" + "," + "'" + dept.getAncestors() + "'" + "," + "'" + dept.getDeptCategory() + "'" + ")";
            "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category,is_deleted) values(" + "'" + information.getDepartmentid() + "'" + "," + "'" + dept.getParentId() + "'" + ","
            + "'" + dept.getTenantId() + "'" +
            "," + "'" + information.getEnterprisename() + "'" +
            "," + "'" + dept.getAncestors() + "'" +
            "," + "'" + dept.getDeptCategory() + "'" +
            "," + "'" + isDeleted + "'" + ")";
        FtpUtil.sqlFileUpload(s);
        return R.success("成功");
    }
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -64,6 +64,7 @@
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.vo.UserVO;
import org.springblade.modules.system.wrapper.UserWrapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
@@ -71,10 +72,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
@@ -231,6 +229,8 @@
    @ApiOperation(value = "修改", notes = "传入User")
    public R update(@Valid @RequestBody User user) {
        CacheUtil.clear(USER_CACHE);
        User user1 = userService.getById(user.getId());
        user.setPassword(user1.getPassword());
        userService.updateById(user);
        Date birthday1 = user.getBirthday();
        String birthday;
@@ -285,6 +285,12 @@
    //@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
    public R remove(@RequestParam String ids) {
        CacheUtil.clear(USER_CACHE);
        List<String> list = Arrays.asList(ids.split(","));
        list.forEach(id -> {
            //内网同步
            String s1 = "update blade_user set is_deleted = 1 where id = " + "'" + id + "'";
            FtpUtil.sqlFileUpload(s1);
        });
        return R.status(userService.removeUser(ids));
    }
@@ -565,6 +571,7 @@
     * 保安员新增
     */
    @PostMapping("/securitySave")
    @Transactional(rollbackFor = Exception.class)
    public R securitySave(@Valid @RequestBody Map<String, Object> userMap) {
        //获取user
        User user = JSON.parseObject(JSON.toJSONString(userMap.get("user")), User.class);
@@ -578,6 +585,7 @@
        Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
        user.setRoleId(oneRole.getId().toString());
        user.setDispatch("1");
        user.setExaminationType("0");
        Integer userCount = userService.selectCount(user.getAccount());
        if (userCount > 0 && Func.isEmpty(user.getId())) {
@@ -614,26 +622,19 @@
        } else {
            rtime = new SimpleDateFormat("yyyy-MM-dd").format(user.getRtime());
        }
        String urla = "";
        String[] split = user.getAvatar().split(",");
        for (int i = 0; i < split.length; i++) {
            String s = split[i].substring(26, split[i].length());
            urla += FtpConfig.ip + s + ",";
        }
        String substring = urla.substring(0, urla.length() - 1);
        user.setAvatar(substring);
        String urlf = "";
        String[] splits = user.getFingerprint().split(",");
        for (int i = 0; i < splits.length; i++) {
            String s = splits[i].substring(26, splits[i].length());
            urlf += FtpConfig.ip + s + ",";
        //头像
        if (null!=user.getAvatar() && !user.getAvatar().equals("")) {
            user.setAvatar(FtpConfig.ip + user.getAvatar().substring(26));
        }
        String substrings = urla.substring(0, urlf.length() - 1);
        user.setFingerprint(substrings);
        //指纹
        if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) {
            user.setFingerprint(FtpConfig.ip + user.getFingerprint().substring(26));
        }
        String s = "insert into blade_user(id,tenant_id,account,password,name,real_name,avatar,email,phone,sex,role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," +
            "politicaloutlook,healstats,height,address,registered,rtime,securitynumber,hold,jurisdiction,status,is_deleted,dispatch) " +
            "politicaloutlook,healstats,height,address,registered,rtime,securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch) " +
            "values(" + "'" + user.getId() + "'" + "," + "'" + user.getTenantId() + "'" + "," + "'" + user.getAccount() + "'" + "," +
            "'" + user.getPassword() + "'" + "," + "'" + user.getName() + "'" + "," + "'" + user.getRealName() + "'" + "," + "'" + user.getAvatar() + "'" + "," +
            "'" + user.getEmail() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" +
@@ -648,9 +649,11 @@
            + "," + "'" + user.getHeight() + "'" +
            "," + "'" + user.getAddress() + "'" +
            "," + "'" + user.getRegistered() + "'" + "," +
            "'" + rtime + "'" + "," + "'" + user.getSecuritynumber() + "'" +
            "'" + rtime + "'" +
            "," + "'" + user.getSecuritynumber() + "'" +
            "," + "'" + user.getHold() + "'" +
            "," + "'" + user.getJurisdiction() + "'" +
            "," + "'" + user.getExaminationType() + "'" +
            "," + "'" + user.getStatus() + "'" +
            "," + "'" + user.getIsDeleted() + "'" +
            "," + "'" + user.getDispatch() + "'" + ")";
src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -192,4 +192,11 @@
     */
    @SqlParser(filter = true)
    List<String> getDeptName(@Param("deptId") String deptId);
    /**
     * 查询用户表中未删除,未离职的用户信息
     * @param username
     * @return
     */
    User getUserInfo(@Param("account") String username);
}
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -521,4 +521,12 @@
            select dept_name from blade_dept where id =  (select parent_id from blade_dept where id= #{deptId} and 1=1)
        )
    </select>
    <!--查询用户表中未删除,未离职的用户信息-->
    <select id="getUserInfo" resultType="org.springblade.modules.system.entity.User">
        select id,account from blade_user
        where account = #{account}
        and is_deleted = 0
        and status = 1
    </select>
</mapper>
src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -29,6 +29,7 @@
import org.springblade.modules.system.excel.UserExcel;
import org.springblade.modules.system.node.TreeNode;
import org.springblade.modules.system.vo.UserVO;
import org.springblade.modules.zc.entity.Zc;
import java.util.List;
import java.util.Map;
@@ -306,4 +307,11 @@
     * @return
     */
    Integer selectCount(String account);
    /**
     * 查询用户表中未删除,未离职的用户信息
     * @param username
     * @return
     */
    User getUserInfo(String username);
}
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -143,16 +143,16 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateUser(User user) {
        String tenantId = user.getTenantId();
        Integer userCount = baseMapper.selectCount(
            Wrappers.<User>query().lambda()
                .eq(User::getTenantId, tenantId)
                .eq(User::getAccount, user.getAccount())
                .notIn(User::getId, user.getId())
        );
        if (userCount > 0) {
            throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
        }
//        String tenantId = user.getTenantId();
//        Integer userCount = baseMapper.selectCount(
//            Wrappers.<User>query().lambda()
//                .eq(User::getTenantId, tenantId)
//                .eq(User::getAccount, user.getAccount())
//                .notIn(User::getId, user.getId())
//        );
//        if (userCount > 0) {
//            throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
//        }
        return updateUserInfo(user) && submitUserDept(user);
    }
@@ -757,4 +757,14 @@
    public Integer selectCount(String account) {
        return baseMapper.selectCountAccount(account);
    }
    /**
     * 查询用户表中未删除,未离职的用户信息
     * @param username
     * @return
     */
    @Override
    public User getUserInfo(String username) {
        return baseMapper.getUserInfo(username);
    }
}
src/main/java/org/springblade/modules/zc/controller/ZcController.java
@@ -164,12 +164,13 @@
            user.setHold("2");
            user.setDispatch("1");
            user.setStatus(1);
            user.setExaminationType("0");
            user.setIsDeleted(0);
            iUserService.save(user);
            //内网数据同步
            String rtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
            String s = "insert into blade_user(id,tenant_id,account,password,real_name,role_id,dept_id,create_time,status,is_deleted,cardid,hold,dispatch) " +
            String s = "insert into blade_user(id,tenant_id,account,password,real_name,role_id,dept_id,create_time,status,is_deleted,cardid,hold,examination_type,dispatch) " +
                "values(" + "'" + user.getId() + "'" +
                "," + "'" + user.getTenantId() + "'" +
                "," + "'" + user.getAccount() + "'" +
@@ -182,6 +183,7 @@
                "," + "'" + user.getIsDeleted() + "'" +
                "," + "'" + user.getCardid() + "'" +
                "," + "'" + user.getHold() + "'" +
                "," + "'" + user.getExaminationType() + "'" +
                "," + "'" + user.getDispatch() + "'" + ")";
            FtpUtil.sqlFileUpload(s);
@@ -216,6 +218,17 @@
    @PostMapping("/inster")
    @ApiOperation(value = "新增", notes = "传入zc")
    public R inster(@Valid @RequestBody Zc zc) {
        //获取用户名,判断该用户名是否已注册,或已有用户
        //查询注册表中是否有相同的注册信息
        Zc zc1 = zcService.getAuditSuccessInfo(zc.getUsername());
        if (null!=zc1){
            throw new com.aliyun.oss.ServiceException(StringUtil.format("当前用户名 [{}] 已被注册!", zc.getUsername()));
        }
        //查询用户表中未删除,未离职的用户信息
        User user = iUserService.getUserInfo(zc.getUsername());
        if (null!=user){
            throw new com.aliyun.oss.ServiceException(StringUtil.format("当前用户名 [{}] 已被注册!", zc.getUsername()));
        }
        //当前时间
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String times = df.format(new Date());
src/main/java/org/springblade/modules/zc/mapper/ZcMapper.java
@@ -41,6 +41,18 @@
    List<ZcVO> selectZcPage(IPage page, ZcVO zc);
    void inster(Zc zc);
    /**
     * 根据用户名查询带审核和审核未通过的用户注册信息
     * @param username
     * @return
     */
    String selectType(String username);
    /**
     * 查询注册审核通过的用户信息
     * @param username
     * @return
     */
    Zc getAuditSuccessInfo(String username);
}
src/main/java/org/springblade/modules/zc/mapper/ZcMapper.xml
@@ -48,10 +48,17 @@
        values (#{username}, #{password}, #{sname}, #{cardid}, #{zctime}, #{deptid})
    </insert>
    <!--根据用户名用户注册信息-->
    <select id="selectType" resultType="String">
        select type
        from act_zc
        where username = #{param1}
    </select>
    <!--根据用户名查询注册用户注册信息-->
    <select id="getAuditSuccessInfo" resultType="org.springblade.modules.zc.entity.Zc">
        select * from act_zc
        where username = #{param1}
    </select>
</mapper>
src/main/java/org/springblade/modules/zc/service/IZcService.java
@@ -38,5 +38,13 @@
     */
    IPage<ZcVO> selectZcPage(IPage<ZcVO> page, ZcVO zc);
    void inster(Zc zc);
    String selectType(String username);
    /**
     * 查询注册审核通过的用户信息
     * @param username
     * @return
     */
    Zc getAuditSuccessInfo(String username);
}
src/main/java/org/springblade/modules/zc/service/impl/ZcServiceImpl.java
@@ -49,4 +49,13 @@
        return baseMapper.selectType(username);
    }
    /**
     * 查询注册审核通过的用户信息
     * @param username
     * @return
     */
    @Override
    public Zc getAuditSuccessInfo(String username) {
        return baseMapper.getAuditSuccessInfo(username);
    }
}