杜函宇 2 months ago
parent 79c5b7cc52
commit 644e4719fa

@ -129,17 +129,17 @@
</dependency>
<!-- Swagger3依赖 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-boot-starter</artifactId>-->
<!-- <version>${swagger.version}</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>io.swagger</groupId>-->
<!-- <artifactId>swagger-models</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- io常用工具类 -->
<dependency>

@ -16,7 +16,20 @@
</description>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.23</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -25,17 +38,17 @@
</dependency>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-boot-starter</artifactId>-->
<!-- </dependency>-->
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.swagger</groupId>-->
<!-- <artifactId>swagger-models</artifactId>-->
<!-- <version>1.6.2</version>-->
<!-- </dependency>-->
<!-- Mysql驱动包 -->
<dependency>

@ -3,6 +3,11 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
*
@ -14,17 +19,21 @@ public class RuoYiApplication
{
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args);
Environment env = application.getEnvironment();
String ip;
try {
ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
path = path.isEmpty() ? "" : path;
System.out.println("\n----------------------------------------------------------\n\t"
+ "Application is running! Access URLs:\n\t"
+ "swagger-ui: http://localhost:" + port + path + "doc.html\n\t"
+ "swagger-ui: http://" + ip + ":" + port + path + "doc.html\n\t"
+ "----------------------------------------------------------");
}
}

@ -0,0 +1,104 @@
package com.ruoyi.tc.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tc.domain.UnitOtherConcat;
import com.ruoyi.tc.service.UnitOtherConcatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
/**
* (unit_other_contact)
* @author du
* @since 2024/11/13 14:50
*/
@RestController
@RequestMapping("/unit/otherConcat")
@Api(tags = "单位其他联系人控制层")
public class UnitOtherConcatController extends BaseController {
/**
*
*/
@Resource
private UnitOtherConcatService unitOtherConcatService;
/**
* unit_id
*
* @param unitId unit_id
* @return
*/
// @PreAuthorize("@ss.hasAnyRoles('admin')")
@ApiOperation(value = "根据unit_id查询该单位所有数据", response = UnitOtherConcat.class)
@GetMapping("/selectAll/{unitId}")
public AjaxResult selectAll(@PathVariable Long unitId) {
return success(unitOtherConcatService.lambdaQuery().eq(UnitOtherConcat::getUnitId,unitId).list());
}
/**
*
*
* @param id
* @return
*/
@ApiOperation(value = "通过主键查询单条数据", response = UnitOtherConcat.class)
@GetMapping("/{id}")
public AjaxResult selectOne(@PathVariable Serializable id) {
return success(unitOtherConcatService.getById(id));
}
/**
*
*
* @param u
* @return
*/
// @PreAuthorize("@ss.hasAnyRoles('admin')")
@ApiOperation(value = "新增数据")
@PostMapping
public AjaxResult insert(@Valid @RequestBody UnitOtherConcat u) {
return success(unitOtherConcatService.save(u));
}
/**
*
*
* @param u
* @return
*/
// @PreAuthorize("@ss.hasAnyRoles('admin')")
@ApiOperation(value = "修改数据")
@PostMapping("/edit")
public AjaxResult update(@RequestBody UnitOtherConcat u) {
return success(unitOtherConcatService.updateById(u));
}
/**
*
*
* @param ids
* @return
*/
// @PreAuthorize("@ss.hasAnyRoles('admin')")
@ApiOperation(value = "删除数据")
@PostMapping("/ids")
public AjaxResult delete(Long[] ids) {
return success(unitOtherConcatService.removeBatchByIds(Arrays.asList(ids)));
}
}

@ -0,0 +1,77 @@
package com.ruoyi.tc.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* (unit_other_contact)
* @author du
* @since 2024/11/13 14:44
*/
@Data
@ApiModel("单位其他联系人")
@TableName(value = "unit_other_contact")
public class UnitOtherConcat implements Serializable {
@TableId(type = IdType.AUTO,value = "id")
private Long id;
@ApiModelProperty("单位id")
@NotNull
private Long unitId;
@ApiModelProperty("其他联系人姓名")
private String qtlxrxm;
@ApiModelProperty("其他联系人联系方式")
private String qtlxrlxfs;
@ApiModelProperty("其他联系人邮箱")
private String qtlxryx;
@ApiModelProperty("其他联系人职务职称")
private String qtlxrzwzc;
/**
*
*/
@ApiModelProperty("创建者")
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@ApiModelProperty("创建时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@ApiModelProperty("更新者")
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
/**
*
*/
@ApiModelProperty("更新时间")
@TableField(fill = FieldFill.UPDATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private String remark;
}

@ -0,0 +1,16 @@
package com.ruoyi.tc.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.tc.domain.UnitOtherConcat;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (unit_other_contact)
* @author ruoyi
*/
public interface UnitOtherConcatMapper extends BaseMapper<UnitOtherConcat>
{
}

@ -0,0 +1,13 @@
package com.ruoyi.tc.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.tc.domain.UnitOtherConcat;
/**
* (unit_other_contact)
* @author du
* @since 2024/11/13 14:55
*/
public interface UnitOtherConcatService extends IService<UnitOtherConcat> {
}

@ -0,0 +1,16 @@
package com.ruoyi.tc.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.tc.domain.UnitOtherConcat;
import com.ruoyi.tc.mapper.UnitOtherConcatMapper;
import com.ruoyi.tc.service.UnitOtherConcatService;
import org.springframework.stereotype.Service;
/**
* (unit_other_contact)
* @author du
* @since 2024/11/13 14:58
*/
@Service
public class UnitOtherConcatServiceImpl extends ServiceImpl<UnitOtherConcatMapper, UnitOtherConcat> implements UnitOtherConcatService {
}

@ -62,17 +62,17 @@ public class SysProfileController extends BaseController
LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
{
return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
{
return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
}
// currentUser.setEmail(user.getEmail());
// currentUser.setPhonenumber(user.getPhonenumber());
// currentUser.setSex(user.getSex());
// if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
// {
// return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
// }
// if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
// {
// return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
// }
if (userService.updateUserProfile(currentUser) > 0)
{
// 更新缓存用户信息

@ -1,36 +1,31 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.Unit;
import com.ruoyi.common.core.domain.request.UnitRequest;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@ -39,8 +34,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
public class SysUserController extends BaseController {
@Autowired
private ISysUserService userService;
@ -53,44 +47,62 @@ public class SysUserController extends BaseController
@Autowired
private ISysPostService postService;
@Resource
private UnitService unitService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user)
{
public TableDataInfo list(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@Log(title = "用户单位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
public void export(HttpServletResponse response, UnitRequest unit) {
// List<SysUser> list = userService.selectUserList(user);
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
// util.exportExcel(response, list, "用户数据");
List<Unit> list = unitService.selectUnitList(unit);
ExcelUtil<Unit> util = new ExcelUtil<>(Unit.class);
util.exportExcel(response, list, "单位数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@Log(title = "用户单位管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return success(message);
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
// List<SysUser> userList = util.importExcel(file.getInputStream());
// String operName = getUsername();
// String message = userService.importUser(userList, updateSupport, operName);
ExcelUtil<Unit> util = new ExcelUtil<>(Unit.class);
List<Unit> list = util.importExcel(file.getInputStream());
unitService.saveBatch(list);
for (Unit x : list) {
SysUser user = new SysUser();
user.setUserName(x.getUserName());
user.setPassword(SecurityUtils.encryptPassword(x.getUserName().substring(x.getUserName().length() - 6)));
user.setNickName(x.getNickName());
SysUser u = userService.selectUserByUserName(x.getUserName());
if (StringUtils.isNull(u)) {
userService.insertUser(user);
Long[] roles = new Long[]{100L};
userService.insertUserAuth(user.getUserId(), roles);
}
//未做修改
}
return success();
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
public void importTemplate(HttpServletResponse response) {
ExcelUtil<Unit> util = new ExcelUtil<>(Unit.class);
util.importTemplateExcel(response, "用户数据");
}
@ -98,21 +110,21 @@ public class SysUserController extends BaseController
*
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
@GetMapping(value = {"/", "/{userId}"})
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
AjaxResult ajax = AjaxResult.success();
if (StringUtils.isNotNull(userId))
{
if (StringUtils.isNotNull(userId)) {
userService.checkUserDataScope(userId);
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
ajax.put("unit", unitService.lambdaQuery().eq(Unit::getUserName,sysUser.getUserName()).one());
}
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
ajax.put("posts", postService.selectPostAll());
return ajax;
}
@ -122,23 +134,26 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user)
{
public AjaxResult add(@Validated @RequestBody SysUser user) {
deptService.checkDeptDataScope(user.getDeptId());
roleService.checkRoleDataScope(user.getRoleIds());
if (!userService.checkUserNameUnique(user))
{
if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
if (!unitService.lambdaQuery().eq(Unit::getUserName, user.getUserName()).list().isEmpty()) {
return error("新增用户'" + user.getUserName() + "'已存在单位!");
}
user.setCreateBy(getUsername());
//新增单位到单位信息表
unitService.save(user.getUnitInfo());
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
// }
// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
// }
// user.setCreateBy(getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
@ -149,25 +164,27 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user)
{
public AjaxResult edit(@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
deptService.checkDeptDataScope(user.getDeptId());
roleService.checkRoleDataScope(user.getRoleIds());
if (!userService.checkUserNameUnique(user))
{
if (!userService.checkUserNameUnique(user)) {
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
if (!unitService.lambdaQuery().eq(Unit::getUserName, user.getUserName()).list().isEmpty()) {
return error("修改用户'" + user.getUserName() + "'已存在单位!");
}
user.setUpdateBy(getUsername());
unitService.updateById(user.getUnitInfo());
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
// {
// return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
// }
// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
// {
// return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
// }
// user.setUpdateBy(getUsername());
return toAjax(userService.updateUser(user));
}
@ -177,10 +194,8 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds)
{
if (ArrayUtils.contains(userIds, getUserId()))
{
public AjaxResult remove(@PathVariable Long[] userIds) {
if (ArrayUtils.contains(userIds, getUserId())) {
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
@ -192,12 +207,11 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user)
{
public AjaxResult resetPwd(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(getUsername());
// user.setUpdateBy(getUsername());
return toAjax(userService.resetPwd(user));
}
@ -207,11 +221,10 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user)
{
public AjaxResult changeStatus(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUsername());
// user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
@ -220,8 +233,7 @@ public class SysUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
public AjaxResult authRole(@PathVariable("userId") Long userId) {
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
@ -236,8 +248,7 @@ public class SysUserController extends BaseController
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
userService.checkUserDataScope(userId);
roleService.checkRoleDataScope(roleIds);
userService.insertUserAuth(userId, roleIds);
@ -249,8 +260,7 @@ public class SysUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept)
{
public AjaxResult deptTree(SysDept dept) {
return success(deptService.selectDeptTreeList(dept));
}
}

@ -1,125 +1,125 @@
package com.ruoyi.web.core.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
/**
* Swagger2
*
* @author ruoyi
*/
@Configuration
public class SwaggerConfig
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/** 是否开启swagger */
@Value("${swagger.enabled}")
private boolean enabled;
/** 设置请求的统一前缀 */
@Value("${swagger.pathMapping}")
private String pathMapping;
/**
* API
*/
@Bean
public Docket createRestApi()
{
return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger
.enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示
.select()
// 扫描所有有注解的api用这种方式更灵活
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
/* 设置安全模式swagger可以设置访问token */
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
.pathMapping(pathMapping);
}
/**
* tokenAuthorization
*/
private List<SecurityScheme> securitySchemes()
{
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList;
}
/**
*
*/
private List<SecurityContext> securityContexts()
{
List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add(
SecurityContext.builder()
.securityReferences(defaultAuth())
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
.build());
return securityContexts;
}
/**
*
*/
private List<SecurityReference> defaultAuth()
{
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
List<SecurityReference> securityReferences = new ArrayList<>();
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
return securityReferences;
}
/**
*
*/
private ApiInfo apiInfo()
{
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
// 设置标题
.title("标题若依管理系统_接口文档")
// 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息
.contact(new Contact(ruoyiConfig.getName(), null, null))
// 版本
.version("版本号:" + ruoyiConfig.getVersion())
.build();
}
}
//package com.ruoyi.web.core.config;
//
//import java.util.ArrayList;
//import java.util.List;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import com.ruoyi.common.config.RuoYiConfig;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.models.auth.In;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.ApiKey;
//import springfox.documentation.service.AuthorizationScope;
//import springfox.documentation.service.Contact;
//import springfox.documentation.service.SecurityReference;
//import springfox.documentation.service.SecurityScheme;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//
///**
// * Swagger2的接口配置
// *
// * @author ruoyi
// */
//@Configuration
//public class SwaggerConfig
//{
// /** 系统基础配置 */
// @Autowired
// private RuoYiConfig ruoyiConfig;
//
// /** 是否开启swagger */
// @Value("${swagger.enabled}")
// private boolean enabled;
//
// /** 设置请求的统一前缀 */
// @Value("${swagger.pathMapping}")
// private String pathMapping;
//
// /**
// * 创建API
// */
// @Bean
// public Docket createRestApi()
// {
// return new Docket(DocumentationType.OAS_30)
// // 是否启用Swagger
// .enable(enabled)
// // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
// .apiInfo(apiInfo())
// // 设置哪些接口暴露给Swagger展示
// .select()
// // 扫描所有有注解的api用这种方式更灵活
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// // 扫描指定包中的swagger注解
// // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
// // 扫描所有 .apis(RequestHandlerSelectors.any())
// .paths(PathSelectors.any())
// .build()
// /* 设置安全模式swagger可以设置访问token */
// .securitySchemes(securitySchemes())
// .securityContexts(securityContexts())
// .pathMapping(pathMapping);
// }
//
// /**
// * 安全模式这里指定token通过Authorization头请求头传递
// */
// private List<SecurityScheme> securitySchemes()
// {
// List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
// apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
// return apiKeyList;
// }
//
// /**
// * 安全上下文
// */
// private List<SecurityContext> securityContexts()
// {
// List<SecurityContext> securityContexts = new ArrayList<>();
// securityContexts.add(
// SecurityContext.builder()
// .securityReferences(defaultAuth())
// .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
// .build());
// return securityContexts;
// }
//
// /**
// * 默认的安全上引用
// */
// private List<SecurityReference> defaultAuth()
// {
// AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
// AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
// authorizationScopes[0] = authorizationScope;
// List<SecurityReference> securityReferences = new ArrayList<>();
// securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
// return securityReferences;
// }
//
// /**
// * 添加摘要信息
// */
// private ApiInfo apiInfo()
// {
// // 用ApiInfoBuilder进行定制
// return new ApiInfoBuilder()
// // 设置标题
// .title("标题若依管理系统_接口文档")
// // 描述
// .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// // 作者信息
// .contact(new Contact(ruoyiConfig.getName(), null, null))
// // 版本
// .version("版本号:" + ruoyiConfig.getVersion())
// .build();
// }
//}

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://39.101.188.84:3307/tc-asset-verification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: password
password: Admin123@
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -1,7 +1,7 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
name: 太仓资产核查
# 版本
version: 3.8.8
# 版权年份
@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
port: 9015
servlet:
# 应用的访问路径
context-path: /
@ -64,7 +64,7 @@ spring:
devtools:
restart:
# 热部署开关
enabled: true
enabled: false
# redis 配置
redis:
# 地址
@ -98,7 +98,8 @@ token:
expireTime: 30
# MyBatis配置
mybatis:
# mybatis-plus配置
mybatis-plus:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
@ -113,11 +114,9 @@ pagehelper:
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
knife4j:
# production: true
enable: true
# 防止XSS攻击
xss:

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.tc.mapper.UnitOtherConcatMapper">
</mapper>

@ -16,6 +16,20 @@
</description>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<!-- Spring框架基本的核心工具 -->
<dependency>

@ -18,6 +18,12 @@ import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
@Target(ElementType.FIELD)
public @interface Excel
{
/**
* excel
*/
public boolean required() default false;
/**
* excel
*/

@ -37,17 +37,28 @@ public class SysUser extends BaseEntity
@Excel(name = "用户名称")
private String nickName;
/** 用户邮箱 */
@Excel(name = "用户邮箱")
private String email;
/** 手机号码 */
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
private String phonenumber;
public Unit getUnitInfo() {
return unitInfo;
}
public void setUnitInfo(Unit unitInfo) {
this.unitInfo = unitInfo;
}
/** 用户性别 */
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
private Unit unitInfo;
// /** 用户邮箱 */
// @Excel(name = "用户邮箱")
// private String email;
//
// /** 手机号码 */
// @Excel(name = "手机号码", cellType = ColumnType.TEXT)
// private String phonenumber;
// /** 用户性别 */
// @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
// private String sex;
/** 用户头像 */
private String avatar;
@ -154,38 +165,38 @@ public class SysUser extends BaseEntity
this.userName = userName;
}
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
public String getPhonenumber()
{
return phonenumber;
}
public void setPhonenumber(String phonenumber)
{
this.phonenumber = phonenumber;
}
public String getSex()
{
return sex;
}
public void setSex(String sex)
{
this.sex = sex;
}
// @Email(message = "邮箱格式不正确")
// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
// public String getEmail()
// {
// return email;
// }
//
// public void setEmail(String email)
// {
// this.email = email;
// }
//
// @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
// public String getPhonenumber()
// {
// return phonenumber;
// }
//
// public void setPhonenumber(String phonenumber)
// {
// this.phonenumber = phonenumber;
// }
// public String getSex()
// {
// return sex;
// }
//
// public void setSex(String sex)
// {
// this.sex = sex;
// }
public String getAvatar()
{
@ -304,20 +315,20 @@ public class SysUser extends BaseEntity
.append("deptId", getDeptId())
.append("userName", getUserName())
.append("nickName", getNickName())
.append("email", getEmail())
.append("phonenumber", getPhonenumber())
.append("sex", getSex())
// .append("email", getEmail())
// .append("phonenumber", getPhonenumber())
// .append("sex", getSex())
.append("avatar", getAvatar())
.append("password", getPassword())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("loginIp", getLoginIp())
.append("loginDate", getLoginDate())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
// .append("createBy", getCreateBy())
// .append("createTime", getCreateTime())
// .append("updateBy", getUpdateBy())
// .append("updateTime", getUpdateTime())
// .append("remark", getRemark())
.append("dept", getDept())
.toString();
}

@ -0,0 +1,205 @@
package com.ruoyi.common.core.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author du
* @since 2024/11/13 9:13
*/
@Data
@ApiModel("单位信息")
@TableName(value = "unit_info")
public class Unit implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO,value = "id")
private Long id;
@ApiModelProperty("单位名称/用户昵称")
@Excel(name = "单位名称*",required = true)
private String nickName;
@ApiModelProperty("单位简称")
@Excel(name = "单位简称")
private String dwjc;
@ApiModelProperty("所属区域-省")
@Excel(name = "所属区域-省*")
private String ssqyprovince;
@ApiModelProperty("所属区域-市")
@Excel(name = "所属区域-市")
private String ssqycity;
@ApiModelProperty("所属区域-县")
@Excel(name = "所属区域-区(县)")
private String ssqycounty;
@ApiModelProperty("所属监管单位")
private String ssjgdw;
@ApiModelProperty("上级单位")
@Excel(name = "上级单位")
private String sjdw;
@ApiModelProperty("单位详细地址")
@Excel(name = "单位详细地址")
private String dwxxdz;
@ApiModelProperty("所属行业")
@Excel(name = "所属行业",dictType="sshy",comboReadDict = true)
private Integer sshy;
@ApiModelProperty("单位类型")
@Excel(name = "单位类型",dictType="dwlx",comboReadDict = true )
private Integer dwlx;
@ApiModelProperty("单位标签(多个标签逗号隔开)")
@Excel(name = "单位标签(多个标签逗号隔开)")
private String dwbq;
@ApiModelProperty("单位角色")
@Excel(name = "单位角色",dictType="dwjs",comboReadDict = true)
private Integer dwjs;
@ApiModelProperty("统一社会信用代码/用户账号")
@Excel(name = "统一社会信用代码",required = true)
private String userName;
@ApiModelProperty("是否关基单位")
@Excel(name="是否关基单位",dictType="gjdw",comboReadDict = true)
private Integer gjdw;
@ApiModelProperty("日常运营负责部门")
private String rcyyfzbm;
@ApiModelProperty("单位负责人姓名")
@Excel(name="单位负责人")
private String dwfzrxm;
@ApiModelProperty("单位负责人联系方式")
@Excel(name="单位负责人联系方式")
private String dwfzrlxfs;
@ApiModelProperty("单位负责人邮箱")
@Excel(name="单位负责人邮箱")
private String dwfzryx;
@ApiModelProperty("单位负责人职务职称")
@Excel(name="单位负责人职务职称")
private String dwfzrzwzc;
@ApiModelProperty("分管负责人姓名")
@Excel(name="分管负责人")
private String fgfzrxm;
@ApiModelProperty("分管负责人联系方式")
@Excel(name="分管负责人联系方式")
private String fgfzrlxfs;
@ApiModelProperty("分管负责人邮箱")
@Excel(name="分管负责人邮箱")
private String fgfzryx;
@ApiModelProperty("分管负责人职务职称")
@Excel(name="分管负责人职务职称")
private String fgfzrzwzc;
@ApiModelProperty("部门负责人姓名")
@Excel(name="部门负责人")
private String bmfzrxm;
@ApiModelProperty("部门负责人联系方式")
@Excel(name="部门负责人联系方式")
private String bmfzrlxfs;
@ApiModelProperty("部门负责人邮箱")
@Excel(name="部门负责人邮箱")
private String bmfzryx;
@ApiModelProperty("部门负责人职务职称")
@Excel(name="部门负责人职务职称")
private String bmfzrzwzc;
@ApiModelProperty("第一联系人姓名")
@Excel(name="第一联系人")
private String dylxrxm;
@ApiModelProperty("第一联系人联系方式")
@Excel(name="第一联系人联系方式")
private String dylxrlxfs;
@ApiModelProperty("第一联系人邮箱")
@Excel(name="第一联系人邮箱")
private String dylxryx;
@ApiModelProperty("第一联系人职务职称")
@Excel(name="第一联系人职务职称")
private String dylxrzwzc;
@ApiModelProperty("检查信息")
private String jcxx;
@ApiModelProperty("官网")
@Excel(name = "官网")
private String gw;
@ApiModelProperty("地图位置-经度")
@Excel(name = "地图位置-经度")
private String dtjd;
@ApiModelProperty("地图位置-纬度")
@Excel(name = "地图位置-纬度")
private String dtwd;
@ApiModelProperty("单位直属性质")
@Excel(name = "单位直属性质", dictType="dwzsxz",comboReadDict = true)
private Integer dwzsxz;
/**
*
*/
@ApiModelProperty("创建者")
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@ApiModelProperty("创建时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@ApiModelProperty("更新者")
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
/**
*
*/
@ApiModelProperty("更新时间")
@TableField(fill = FieldFill.UPDATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
}

@ -0,0 +1,23 @@
package com.ruoyi.common.core.domain.request;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* @author du
* @since 2024/11/13 16:52
*/
@Data
public class UnitRequest {
@ApiModelProperty("统一社会信用代码")
private String userName;
@ApiModelProperty("单位名称")
private String nickName;
@ApiModelProperty("单位类型,传字典数字")
private Integer dwlx;
}

@ -24,6 +24,8 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.exception.ServiceException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
@ -415,6 +417,12 @@ public class ExcelUtil<T>
// 从map中得到对应列的field.
Field field = (Field) entry.getValue()[0];
Excel attr = (Excel) entry.getValue()[1];
boolean rq = attr.required();
if(rq){
if(StringUtils.isNull(val) || StringUtils.isEmpty(val.toString())) {
throw new ServiceException("第"+i+"行"+attr.name()+"单元格必填项未填写,请正确填写!");
}
}
// 取得类型,并根据对象类型设置值.
Class<?> fieldType = field.getType();
if (String.class == fieldType)

@ -6,6 +6,11 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import javax.sql.DataSource;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.io.VFS;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
@ -113,20 +118,27 @@ public class MyBatisConfig
return resources.toArray(new Resource[resources.size()]);
}
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
{
String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
String mapperLocations = env.getProperty("mybatis.mapperLocations");
String configLocation = env.getProperty("mybatis.configLocation");
typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
VFS.addImplClass(SpringBootVFS.class);
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
return sessionFactory.getObject();
}
// @Bean
// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
// {
// String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
// String mapperLocations = env.getProperty("mybatis.mapperLocations");
// String configLocation = env.getProperty("mybatis.configLocation");
// typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
// VFS.addImplClass(SpringBootVFS.class);
//
// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// sessionFactory.setDataSource(dataSource);
// sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
// sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
// sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
// return sessionFactory.getObject();
// }
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
}
}

@ -0,0 +1,62 @@
package com.ruoyi.framework.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Objects;
/**
*
*
* @author wu
* @since 2023/5/4 10:16
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
// 获取当前登录用户
String userName = null;
Long userId = null;
try {
LoginUser loginUser = SecurityUtils.getLoginUser();
userName = loginUser.getUser().getNickName();
userId = SecurityUtils.getUserId();
} catch (Exception ignored) {
}
if (!Objects.equals(userName, "")) {
this.strictInsertFill(metaObject, "createBy", String.class, userName);
}
if (userId != null) {
this.strictInsertFill(metaObject, "createId", Long.class, userId);
}
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
}
@Override
public void updateFill(MetaObject metaObject) {
// 获取当前登录用户
String userName = null;
Long userId = null;
try {
LoginUser loginUser = SecurityUtils.getLoginUser();
userName = loginUser.getUser().getNickName();
userId = SecurityUtils.getUserId();
} catch (Exception ignored) {
}
if (userId != null) {
this.strictUpdateFill(metaObject, "updateId", Long.class, userId);
}
if (!Objects.equals(userName, "")) {
this.strictUpdateFill(metaObject, "updateBy", String.class, userName);
}
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
}
}

@ -115,7 +115,8 @@ public class SecurityConfig
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.antMatchers("/system/user/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();
})
// 添加Logout filter

@ -109,19 +109,19 @@ public interface SysUserMapper
*/
public SysUser checkUserNameUnique(String userName);
/**
*
*
* @param phonenumber
* @return
*/
public SysUser checkPhoneUnique(String phonenumber);
/**
* email
*
* @param email
* @return
*/
public SysUser checkEmailUnique(String email);
// /**
// * 校验手机号码是否唯一
// *
// * @param phonenumber 手机号码
// * @return 结果
// */
// public SysUser checkPhoneUnique(String phonenumber);
//
// /**
// * 校验email是否唯一
// *
// * @param email 用户邮箱
// * @return 结果
// */
// public SysUser checkEmailUnique(String email);
}

@ -0,0 +1,24 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.entity.Unit;
import com.ruoyi.common.core.domain.request.UnitRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* unit_info
* @author du
* @since 2024/11/13 15:04
*/
public interface UnitMapper extends BaseMapper<Unit> {
/**
*
*
* @param a
* @return
*/
List<Unit> selectUnitList(@Param("req") UnitRequest a);
}

@ -74,21 +74,21 @@ public interface ISysUserService
*/
public boolean checkUserNameUnique(SysUser user);
/**
*
*
* @param user
* @return
*/
public boolean checkPhoneUnique(SysUser user);
/**
* email
*
* @param user
* @return
*/
public boolean checkEmailUnique(SysUser user);
// /**
// * 校验手机号码是否唯一
// *
// * @param user 用户信息
// * @return 结果
// */
// public boolean checkPhoneUnique(SysUser user);
//
// /**
// * 校验email是否唯一
// *
// * @param user 用户信息
// * @return 结果
// */
// public boolean checkEmailUnique(SysUser user);
/**
*

@ -0,0 +1,24 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.Unit;
import com.ruoyi.common.core.domain.request.UnitRequest;
import java.util.List;
/**
* unit_info
* @author du
* @since 2024/11/13 15:02
*/
public interface UnitService extends IService<Unit> {
/**
*
*
* @param unit
* @return
*/
List<Unit> selectUnitList(UnitRequest unit);
}

@ -180,41 +180,41 @@ public class SysUserServiceImpl implements ISysUserService
return UserConstants.UNIQUE;
}
/**
*
*
* @param user
* @return
*/
@Override
public boolean checkPhoneUnique(SysUser user)
{
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* email
*
* @param user
* @return
*/
@Override
public boolean checkEmailUnique(SysUser user)
{
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkEmailUnique(user.getEmail());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
// /**
// * 校验手机号码是否唯一
// *
// * @param user 用户信息
// * @return
// */
// @Override
// public boolean checkPhoneUnique(SysUser user)
// {
// Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
// SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
// if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
// {
// return UserConstants.NOT_UNIQUE;
// }
// return UserConstants.UNIQUE;
// }
//
// /**
// * 校验email是否唯一
// *
// * @param user 用户信息
// * @return
// */
// @Override
// public boolean checkEmailUnique(SysUser user)
// {
// Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
// SysUser info = userMapper.checkEmailUnique(user.getEmail());
// if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
// {
// return UserConstants.NOT_UNIQUE;
// }
// return UserConstants.UNIQUE;
// }
/**
*
@ -505,7 +505,7 @@ public class SysUserServiceImpl implements ISysUserService
deptService.checkDeptDataScope(user.getDeptId());
String password = configService.selectConfigByKey("sys.user.initPassword");
user.setPassword(SecurityUtils.encryptPassword(password));
user.setCreateBy(operName);
// user.setCreateBy(operName);
userMapper.insertUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
@ -517,7 +517,7 @@ public class SysUserServiceImpl implements ISysUserService
checkUserDataScope(u.getUserId());
deptService.checkDeptDataScope(user.getDeptId());
user.setUserId(u.getUserId());
user.setUpdateBy(operName);
// user.setUpdateBy(operName);
userMapper.updateUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");

@ -0,0 +1,31 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.Unit;
import com.ruoyi.common.core.domain.request.UnitRequest;
import com.ruoyi.system.mapper.UnitMapper;
import com.ruoyi.system.service.UnitService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* unit_info
* @author du
* @since 2024/11/13 15:02
*/
@Service
public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements UnitService {
/**
*
*
* @param unit
* @return
*/
@Override
public List<Unit> selectUnitList(UnitRequest unit) {
return baseMapper.selectUnitList(unit);
}
}

@ -9,9 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deptId" column="dept_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<!-- <result property="email" column="email" />-->
<!-- <result property="phonenumber" column="phonenumber" />-->
<!-- <result property="sex" column="sex" />-->
<result property="avatar" column="avatar" />
<result property="password" column="password" />
<result property="status" column="status" />
@ -23,10 +23,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<association property="unitInfo"
javaType="Unit"
column="user_name"
select="UnitList"/>
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
<select id="UnitList" parameterType="Unit" resultMap="com.ruoyi.system.mapper.UnitMapper.unitResult">
select * from unit_info where user_name = #{user_name}
</select>
<resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
@ -47,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.avatar, u.password, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@ -57,9 +65,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.avatar, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
left join unit_info c on u.user_name = c.user_name
where u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
</if>
@ -69,9 +78,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
@ -86,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -95,15 +101,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -113,9 +116,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
@ -134,13 +134,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
</select>
<!-- <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">-->
<!-- select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1-->
<!-- </select>-->
<!-- -->
<!-- <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">-->
<!-- select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1-->
<!-- </select>-->
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
@ -148,10 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -162,10 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
@ -180,9 +174,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.UnitMapper">
<resultMap id="unitResult" type="Unit">
<id property="id" column="id" />
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="dwjc" column="dwjc"/>
<result property="ssqyprovince" column="ssqyprovince"/>
<result property="ssqycity" column="ssqycity"/>
<result property="ssqycity" column="ssqycity"/>
<result property="dwxxdz" column="dwxxdz"/>
<result property="sshy" column="sshy"/>
<result property="dwlx" column="dwlx"/>
<result property="dwbq" column="dwbq"/>
<result property="ssjgdw" column="ssjgdw"/>
<result property="dwjs" column="dwjs"/>
<result property="dwzsxz" column="dwzsxz"/>
<result property="gjdw" column="gjdw"/>
<result property="rcyyfzbm" column="rcyyfzbm"/>
<result property="dwfzrxm" column="dwfzrxm"/>
<result property="dwfzrlxfs" column="dwfzrlxfs"/>
<result property="dwfzryx" column="dwfzryx"/>
<result property="dwfzrzwzc" column="dwfzrzwzc"/>
<result property="fgfzrxm" column="fgfzrxm"/>
<result property="fgfzrlxfs" column="fgfzrlxfs"/>
<result property="fgfzryx" column="fgfzryx"/>
<result property="fgfzrzwzc" column="fgfzrzwzc"/>
<result property="bmfzrxm" column="bmfzrxm"/>
<result property="bmfzrlxfs" column="bmfzrlxfs"/>
<result property="bmfzryx" column="bmfzryx"/>
<result property="bmfzrzwzc" column="bmfzrzwzc"/>
<result property="dylxrxm" column="dylxrxm"/>
<result property="dylxrlxfs" column="dylxrlxfs"/>
<result property="dylxryx" column="dylxryx"/>
<result property="dylxrzwzc" column="dylxrzwzc"/>
<result property="jcxx" column="jcxx"/>
<result property="gw" column="gw"/>
<result property="dtjd" column="dtjd"/>
<result property="dtwd" column="dtwd"/>
<result property="sjdw" column="sjdw"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<select id="selectUnitList" parameterType="unit" resultMap="unitResult">
select * from unit_info
<where>
<if test="req.nickName != null and req.nickName != '' ">
and nick_name like concat('%',#{req.nickName},'%')
</if>
<if test="req.dwlx != null">
and dwlx = #{req.dwlx}
</if>
<if test="req.userName != null and req.userName != '' ">
and user_name like concat('%',#{req.userName},'%')
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save