This commit is contained in:
13405411873 2023-10-11 18:37:04 +08:00
parent af2b03dd44
commit c963066385
32 changed files with 425 additions and 146 deletions

View File

@ -3,11 +3,11 @@ package com.fuint.business.store.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.store.entity.ChainStoreInfo;
import com.fuint.business.store.service.ChainStoreInfoService;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -22,7 +22,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("chainStoreInfo")
public class ChainStoreInfoController extends ApiController {
public class ChainStoreInfoController extends BaseController {
/**
* 服务对象
*/
@ -37,8 +37,8 @@ public class ChainStoreInfoController extends ApiController {
* @return 所有数据
*/
@GetMapping
public R selectAll(Page<ChainStoreInfo> page, ChainStoreInfo chainStoreInfo) {
return success(this.chainStoreInfoService.page(page, new QueryWrapper<>(chainStoreInfo)));
public ResponseObject selectAll(Page<ChainStoreInfo> page, ChainStoreInfo chainStoreInfo) {
return getSuccessResult(this.chainStoreInfoService.page(page, new QueryWrapper<>(chainStoreInfo)));
}
/**
@ -48,8 +48,8 @@ public class ChainStoreInfoController extends ApiController {
* @return 单条数据
*/
@GetMapping("{id}")
public R selectOne(@PathVariable Serializable id) {
return success(this.chainStoreInfoService.getById(id));
public ResponseObject selectOne(@PathVariable Serializable id) {
return getSuccessResult(this.chainStoreInfoService.getById(id));
}
/**
@ -59,8 +59,8 @@ public class ChainStoreInfoController extends ApiController {
* @return 新增结果
*/
@PostMapping
public R insert(@RequestBody ChainStoreInfo chainStoreInfo) {
return success(this.chainStoreInfoService.save(chainStoreInfo));
public ResponseObject insert(@RequestBody ChainStoreInfo chainStoreInfo) {
return getSuccessResult(this.chainStoreInfoService.save(chainStoreInfo));
}
/**
@ -70,8 +70,8 @@ public class ChainStoreInfoController extends ApiController {
* @return 修改结果
*/
@PutMapping
public R update(@RequestBody ChainStoreInfo chainStoreInfo) {
return success(this.chainStoreInfoService.updateById(chainStoreInfo));
public ResponseObject update(@RequestBody ChainStoreInfo chainStoreInfo) {
return getSuccessResult(this.chainStoreInfoService.updateById(chainStoreInfo));
}
/**
@ -81,8 +81,8 @@ public class ChainStoreInfoController extends ApiController {
* @return 删除结果
*/
@DeleteMapping
public R delete(@RequestParam("idList") List<Long> idList) {
return success(this.chainStoreInfoService.removeByIds(idList));
public ResponseObject delete(@RequestParam("idList") List<Long> idList) {
return getSuccessResult(this.chainStoreInfoService.removeByIds(idList));
}
}

View File

@ -0,0 +1,202 @@
package com.fuint.common.config;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import com.fuint.repository.model.TAccount;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.MapperMethod.ParamMap;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.plugin.*;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.*;
/**
* mybatis拦截器自动注入创建人创建时间修改人修改时间
*
* @Author wxz
* @Date 2023-5-5
*/
@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
@Component
@Slf4j
public class AutoInjectBaseFieldInterceptor implements Interceptor {
/**
* 用户字段,如果有其他命名的字段,就添加进来
*/
private List<String> createUserFieldList() {
List<String> createUserList = new ArrayList<>();
createUserList.add("createUser");
createUserList.add("createBy");
return createUserList;
}
private List<String> updateUserFieldList() {
List<String> createUserList = new ArrayList<>();
createUserList.add("updateUser");
createUserList.add("updateBy");
return createUserList;
}
private List<String> idFieldList() {
return Collections.singletonList("id");
}
private List<String> createTimeFieldList() {
List<String> createTimeList = new ArrayList<>();
createTimeList.add("createTime");
createTimeList.add("createDate");
return createTimeList;
}
private List<String> createDepartFieldList() {
List<String> createDepartList = new ArrayList<>();
createDepartList.add("deptId");
createDepartList.add("departId");
return createDepartList;
}
private List<String> updateTimeFieldList() {
List<String> createTimeList = new ArrayList<>();
createTimeList.add("updateTime");
createTimeList.add("updateDate");
return createTimeList;
}
@Override
public Object intercept(Invocation invocation) throws Throwable {
if (invocation.getArgs().length == 1) {
return invocation.proceed();
}
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
Object parameter = invocation.getArgs()[1];
if (parameter == null) {
return invocation.proceed();
}
if (SqlCommandType.INSERT == sqlCommandType) {
Field[] fields = ReflectUtil.getFields(parameter.getClass());
for (Field field : fields) {
try {
String fieldName = field.getName();
//获取属性名前,先开启反射可访问,否则,无法获取到字段名,因为字段名是私有属性
field.setAccessible(true);
Object localCreateBy = field.get(parameter);
// 注入id
if (this.idFieldList().contains(fieldName)) {
if (localCreateBy == null || "".equals(localCreateBy)) {
field.set(parameter, IdUtil.fastSimpleUUID());
}
}
//注入创建时间
if (this.createTimeFieldList().contains(fieldName)) {
if (localCreateBy == null || "".equals(localCreateBy)) {
field.set(parameter, new Date());
}
}
//注入创建人
if (this.createUserFieldList().contains(fieldName)) {
if (localCreateBy == null || "".equals(localCreateBy)) {
setUserName(field, parameter);
}
}
//注入部门
if (this.createDepartFieldList().contains(fieldName)) {
if (localCreateBy == null || "".equals(localCreateBy)) {
setDepart(field, parameter);
}
}
field.setAccessible(false);
}
catch (Exception ignored) {
}
}
}
if (SqlCommandType.UPDATE == sqlCommandType) {
Field[] fields = null;
if (parameter instanceof ParamMap) {
ParamMap<?> p = (ParamMap<?>) parameter;
if (p.containsKey("et")) {
parameter = p.get("et");
} else {
parameter = p.get("param1");
}
if (parameter == null) {
return invocation.proceed();
}
}
fields = ReflectUtil.getFields(parameter.getClass());
for (Field field : fields) {
try {
String fieldName = field.getName();
field.setAccessible(true);
Object localUpdateBy = field.get(parameter);
if (this.updateUserFieldList().contains(fieldName)) {
if (localUpdateBy == null || "".equals(localUpdateBy)) {
setUserName(field, parameter);
}
}
if (this.updateTimeFieldList().contains(fieldName)) {
if (localUpdateBy == null || "".equals(localUpdateBy)) {
field.set(parameter, new Date());
}
}
field.setAccessible(false);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
return invocation.proceed();
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
private void setUserName(Field field, Object parameter) {
AccountInfo sysUser = null;
//获取登录用户信息
try {
sysUser = TokenUtil.getNowAccountInfo();
if (ObjectUtil.isNotEmpty(sysUser)) {
field.setAccessible(true);
field.set(parameter, sysUser.getId() + "");
field.setAccessible(false);
}
}
catch (Exception ignored) {
}
}
private void setDepart(Field field, Object parameter) {
AccountInfo sysUser = null;
//获取登录用户信息
try {
sysUser = TokenUtil.getNowAccountInfo();
if (ObjectUtil.isNotEmpty(sysUser)) {
field.setAccessible(true);
field.set(parameter, sysUser.getDeptId());
field.setAccessible(false);
}
}
catch (Exception ignored) {
}
}
}

View File

@ -1,5 +1,6 @@
package com.fuint.common.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
@ -48,4 +49,6 @@ public class MybatisPlusConfig {
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
}
}

View File

@ -25,6 +25,7 @@ import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -61,6 +62,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
* 员工接口
*/
@Autowired
@Lazy
private StaffService staffService;
@Autowired
private ISysDeptService deptService;

View File

@ -23,6 +23,7 @@ import com.ijpay.alipay.AliPayApiConfigKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@ -40,6 +41,7 @@ public class AlipayServiceImpl implements AlipayService {
private static final Logger logger = LoggerFactory.getLogger(WeixinServiceImpl.class);
@Autowired
@Lazy
private OrderService orderService;
@Autowired

View File

@ -23,6 +23,7 @@ import com.fuint.repository.model.MtUser;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -48,6 +49,7 @@ public class BalanceServiceImpl extends ServiceImpl<MtBalanceMapper, MtBalance>
private MtUserMapper mtUserMapper;
@Resource
@Lazy
private WeixinService weixinService;
@Resource

View File

@ -28,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
@ -73,6 +74,7 @@ public class CouponGroupServiceImpl extends ServiceImpl<MtCouponGroupMapper, MtC
private UserCouponService userCouponService;
@Resource
@Lazy
private MemberService memberService;
@Resource

View File

@ -26,6 +26,7 @@ import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -64,6 +65,7 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
private MtCouponGoodsMapper mtCouponGoodsMapper;
@Autowired
@Lazy
private UserCouponService userCouponService;
@Autowired
@ -73,6 +75,7 @@ public class CouponServiceImpl extends ServiceImpl<MtCouponMapper, MtCoupon> imp
private SendSmsService sendSmsService;
@Autowired
@Lazy
private ConfirmLogService confirmLogService;
@Autowired

View File

@ -27,6 +27,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -64,24 +65,28 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
* 会员等级接口
* */
@Resource
@Lazy
private UserGradeService userGradeService;
/**
* 会员等级接口
* */
@Resource
@Lazy
private OpenGiftService openGiftService;
/**
* 后台账户服务接口
*/
@Resource
@Lazy
private AccountService accountService;
/**
* 员工接口
*/
@Resource
@Lazy
private StaffService staffService;
/**

View File

@ -23,6 +23,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -48,9 +49,11 @@ public class OpenGiftServiceImpl extends ServiceImpl<MtOpenGiftMapper, MtOpenGif
private MtUserMapper mtUserMapper;
@Autowired
@Lazy
private CouponService couponService;
@Autowired
@Lazy
private UserCouponService userCouponService;
@Autowired

View File

@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -79,18 +80,22 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
private SettingService settingService;
@Autowired
@Lazy
private CouponService couponService;
@Autowired
@Lazy
private UserCouponService userCouponService;
@Autowired
private AddressService addressService;
@Autowired
@Lazy
private MemberService memberService;
@Autowired
@Lazy
private PointService pointService;
@Autowired
@ -106,12 +111,15 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
UserGradeService userGradeService;
@Autowired
@Lazy
private RefundService refundService;
@Autowired
@Lazy
private WeixinService weixinService;
@Autowired
@Lazy
private AlipayService alipayService;
@Autowired

View File

@ -13,6 +13,7 @@ import com.fuint.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@ -40,6 +41,7 @@ public class PaymentServiceImpl implements PaymentService {
* 微信服务接口
* */
@Autowired
@Lazy
private WeixinService weixinService;
/**

View File

@ -23,6 +23,7 @@ import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.Page;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -47,9 +48,11 @@ public class PointServiceImpl extends ServiceImpl<MtPointMapper, MtPoint> implem
private MtUserMapper mtUserMapper;
@Autowired
@Lazy
private MemberService memberService;
@Autowired
@Lazy
private WeixinService weixinService;
/**

View File

@ -23,6 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -79,6 +80,7 @@ public class RefundServiceImpl extends ServiceImpl<MtRefundMapper, MtRefund> imp
* 订单服务接口
* */
@Autowired
@Lazy
private OrderService orderService;
/**

View File

@ -20,6 +20,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -43,6 +44,7 @@ public class StaffServiceImpl extends ServiceImpl<MtStaffMapper, MtStaff> implem
* 会员服务接口
*/
@Autowired
@Lazy
private MemberService memberService;
/**

View File

@ -23,6 +23,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@ -45,18 +46,23 @@ public class UserCouponServiceImpl extends ServiceImpl<MtUserCouponMapper, MtUse
private MtUserCouponMapper mtUserCouponMapper;
@Autowired
@Lazy
private CouponService couponService;
@Autowired
@Lazy
private CouponGroupService couponGroupService;
@Autowired
@Lazy
private MemberService memberService;
@Autowired
@Lazy
private PointService pointService;
@Autowired
@Lazy
private ConfirmLogService confirmLogService;
@Autowired
@ -66,6 +72,7 @@ public class UserCouponServiceImpl extends ServiceImpl<MtUserCouponMapper, MtUse
private SettingService settingService;
@Autowired
@Lazy
private OrderService orderService;
/**

View File

@ -28,6 +28,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.core.env.Environment;
@ -57,6 +58,7 @@ public class WeixinServiceImpl implements WeixinService {
private static final Logger logger = LoggerFactory.getLogger(WeixinServiceImpl.class);
@Autowired
@Lazy
private OrderService orderService;
@Autowired
@ -69,6 +71,7 @@ public class WeixinServiceImpl implements WeixinService {
private StoreService storeService;
@Autowired
@Lazy
private PaymentService paymentService;
@Autowired

View File

@ -19,6 +19,9 @@ import com.fuint.repository.model.TSource;
import com.fuint.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.*;
import com.fuint.common.domain.TreeNode;
import javax.annotation.Resource;
@ -85,23 +88,22 @@ public class BackendLoginController extends BaseController {
if (accountInfo == null) {
return getFailureResult(Constants.HTTP_RESPONSE_CODE_USER_LOGIN_ERROR);
}
TAccount tAccount = accountService.getAccountInfoById(accountInfo.getId());
String myPassword = tAccount.getPassword();
String inputPassword = accountService.getEntryptPassword(password, tAccount.getSalt());
if (!myPassword.equals(inputPassword) || !tAccount.getAccountStatus().toString().equals("1")) {
return getFailureResult(201, "账号或密码有误");
}
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken info = new UsernamePasswordToken(accountInfo.getAccountName(), tAccount.getPassword());
subject.login(info);
String token = TokenUtil.generateToken(userAgent, accountInfo.getId());
accountInfo.setToken(token);
TokenUtil.saveAccountToken(accountInfo);
LoginResponse response = new LoginResponse();
response.setLogin(true);
response.setToken(token);
response.setTokenCreatedTime(new Date());
return getSuccessResult(response);
}
}

View File

@ -29,8 +29,8 @@ import java.util.*;
* Created by FSQ
* CopyRight https://www.fuint.cn
*/
@EnableScheduling
@Component("couponExpireJob")
//@EnableScheduling
//@Component("couponExpireJob")
public class CouponExpireJob {
private Logger logger = LoggerFactory.getLogger(CouponExpireJob.class);

View File

@ -22,8 +22,8 @@ import java.util.List;
* Created by FSQ
* CopyRight https://www.fuint.cn
*/
@EnableScheduling
@Component("messageJob")
//@EnableScheduling
//@Component("messageJob")
public class MessageJob {
private Logger logger = LoggerFactory.getLogger(MessageJob.class);

View File

@ -26,8 +26,8 @@ import java.util.Map;
* Created by FSQ
* CopyRight https://www.fuint.cn
*/
@EnableScheduling
@Component("orderCancelJob")
//@EnableScheduling
//@Component("orderCancelJob")
public class OrderCancelJob {
private Logger logger = LoggerFactory.getLogger(OrderCancelJob.class);

View File

@ -1,5 +1,8 @@
package com.fuint.system.dept.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fuint.framework.entity.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -23,6 +26,7 @@ public class SysDept extends BaseEntity
private static final long serialVersionUID = 1L;
/** 部门ID */
@TableId(type = IdType.AUTO)
private Long deptId;
/** 父部门ID */
@ -58,6 +62,7 @@ public class SysDept extends BaseEntity
private String parentName;
/** 子部门 */
@TableField(exist = false)
private List<SysDept> children = new ArrayList<SysDept>();

View File

@ -79,21 +79,6 @@ public interface SysDeptMapper extends BaseMapper<SysDept>
*/
public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
/**
* 新增部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int insertDept(SysDept dept);
/**
* 修改部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int updateDept(SysDept dept);
/**
* 修改所在部门正常状态

View File

@ -69,49 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_dept
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<insert id="insertDept">
insert into sys_dept(
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept">
update sys_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors =

View File

@ -184,7 +184,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> imple
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
}
return baseMapper.insertDept(dept);
return baseMapper.insert(dept);
}
/**
@ -205,7 +205,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> imple
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = baseMapper.updateDept(dept);
int result = baseMapper.updateById(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors()))
{

View File

@ -15,6 +15,7 @@ public class SysDictData extends BaseEntity
private static final long serialVersionUID = 1L;
/** 字典编码 */
private Long dictCode;
/** 字典排序 */

View File

@ -20,6 +20,7 @@ spring.servlet.multipart.max-request-size=10MB
# mybatis\u914D\u7F6E
mybatis-plus.mapper-locations = classpath*:/mapper/*Mapper.xml,classpath*:com/fuint/**/xml/*Mapper.xml
# 配置自定义拦截器
mybatis-plus.configuration.intercepts=com.example.MyInterceptor
# \u9ED8\u8BA4\u65F6\u95F4\u683C\u5F0F
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss

View File

@ -40,8 +40,15 @@
<artifactId>javassist</artifactId>
<version>3.24.0-GA</version>
</dependency>
<!--shiro和springboot整合的依赖-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-starter</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@ -15,6 +16,7 @@ import java.util.Map;
*
* @author ruoyi
*/
@Data
public class BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
@ -47,66 +49,6 @@ public class BaseEntity implements Serializable
@TableField(exist = false)
private Map<String, Object> params;
public String getSearchValue()
{
return searchValue;
}
public void setSearchValue(String searchValue)
{
this.searchValue = searchValue;
}
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public Date getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(Date updateTime)
{
this.updateTime = updateTime;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
public Map<String, Object> getParams()
{
if (params == null)

View File

@ -0,0 +1,72 @@
package com.fuint.framework.shiroConfig;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.util.ThreadContext;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 描述
*
* @author caojing
* @create 2020-4-28
*/
@Configuration
public class ShiroConfig {
//Filter工厂设置对应的过滤条件和跳转条件
@Bean
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean filter=new ShiroFilterFactoryBean();
filter.setSecurityManager(securityManager);
//设置shiro的拦截规则
//anon 匿名用户可访问 authc 认证用户可访问
//user 使用RemeberMe的用户可访问 perms 对应权限可访问
//role 对应的角色可访问
LinkedHashMap<String,String> filterMap=new LinkedHashMap<>();
filterMap.put("/backendApi/login/doLogin","anon");
filterMap.put("/clientApi/captcha/getCode","anon");
filterMap.put("/static/**","anon");
filterMap.put("/**","authc");
filter.setFilterChainDefinitionMap(filterMap);
return filter;
}
@Bean
public UserRealm getRealm(){
UserRealm userRealm = new UserRealm();
return userRealm;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(@Qualifier("securityManager") SecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
advisor.setSecurityManager(securityManager);
return advisor;
}
@Bean(name = "securityManager")
public DefaultWebSecurityManager securityManager(UserRealm userRealm)
{
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 设置realm.
securityManager.setRealm(userRealm);
ThreadContext.bind(securityManager);//加上这句代码手动绑定
// session管理器
//securityManager.setSessionManager(sessionManager());
// 记住我
//securityManager.setRememberMeManager(rememberMe ? rememberMeManager() : null);
// 缓存管理器;
//securityManager.setCacheManager(getEhCacheManager());
return securityManager;
}
}

View File

@ -0,0 +1,54 @@
package com.fuint.framework.shiroConfig;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fuint.repository.mapper.TAccountMapper;
import com.fuint.repository.model.TAccount;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 描述
*
* @author caojing
* @create 2020-04-28
*/
public class UserRealm extends AuthorizingRealm {
@Autowired
TAccountMapper accountMapper;
//doGetAuthorizationInfo 权限认证即登录过后每个身份不一定对应的所能看的页面也不一样
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
//添加角色和权限
return null;
}
/**
* 这里可以注入userService,为了方便演示我就写死了帐号了密码
* private UserService userService;
* <p>
* 获取即将需要认证的信息
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
System.out.println("-------身份认证方法--------");
String accountName= (String) authenticationToken.getPrincipal();
String password = new String((char[]) authenticationToken.getCredentials());
//根据用户名去数据库查询用户信息
LambdaQueryWrapper<TAccount> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.eq(TAccount::getAccountName,accountName);
TAccount tAccount = accountMapper.selectOne(queryWrapper);
if (tAccount == null) {
throw new AccountException("用户名不正确");
} else if (!tAccount.getPassword().equals(password )) {
throw new AccountException("密码不正确");
}
return new SimpleAuthenticationInfo(accountName, password,getName());
}
}

View File

@ -14,8 +14,8 @@
AND ta.dept_id = #{accountInfo.deptId}
</if>
<!-- 数据范围过滤 -->
<if test="ownDeptStr != null and ownDeptStr!=''">
AND sd.ancestors like concat (#{ownDeptStr},'%')
<if test="ancestors != null and ancestors!=''">
AND sd.ancestors like concat (#{ancestors},'%')
</if>
order by create_time desc