| | |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.basic.service.ISupplierService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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.bind.annotation.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/system/supplier") |
| | |
| | | @Autowired |
| | | private ISupplierService supplierService; |
| | | |
| | | /** |
| | | * ä¾åºåæ°å¢ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public void add(@RequestBody SupplierManage supplierManage) { |
| | | public AjaxResult add(@RequestBody SupplierManage supplierManage) { |
| | | supplierService.saveSupplier(supplierManage); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºåå é¤ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/del") |
| | | public AjaxResult delSupplier(Integer id) { |
| | | supplierService.delSupplier(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºå详æ
|
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/info") |
| | | public AjaxResult supplierDetail(Integer id) { |
| | | return AjaxResult.success(supplierService.supplierDetail(id)); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºåä¿®æ¹ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public AjaxResult update(@RequestBody SupplierManage supplierManage) { |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºå管çå页æ¥è¯¢ |
| | | * @param page |
| | | * @param supplierManageDto |
| | | * @return |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public AjaxResult supplierListPage(Page page, SupplierManageDto supplierManageDto) { |
| | | return AjaxResult.success(supplierService.supplierListPage(page, supplierManageDto)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.dto; |
| | | |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SupplierManageDto extends SupplierManage { |
| | | } |
| | |
| | | package com.ruoyi.basic.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | @Mapper |
| | | public interface SupplierManageMapper extends BaseMapper<SupplierManage> { |
| | | |
| | | IPage<SupplierManage> supplierListPage(Page page, @Param("supplierManageDto") SupplierManageDto supplierManageDto); |
| | | } |
| | |
| | | package com.ruoyi.basic.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | |
| | | private LocalDateTime maintainTime; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "ä¿®æ¹ç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer tenantId; |
| | | } |
| | |
| | | package com.ruoyi.basic.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | |
| | | public interface ISupplierService { |
| | | |
| | | /** |
| | | * ä¾åºåæ°å¢ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | void saveSupplier(SupplierManage supplierManage); |
| | | |
| | | /** |
| | | * ä¾åºåå é¤ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | int delSupplier(Integer id); |
| | | |
| | | /** |
| | | * ä¾åºå详æ
|
| | | * @param id |
| | | * @return |
| | | */ |
| | | SupplierManage supplierDetail(Integer id); |
| | | |
| | | /** |
| | | * ä¾åºåä¿®æ¹ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | int supplierManage(SupplierManage supplierManage); |
| | | |
| | | /** |
| | | * ä¾åºåå页æ¥è¯¢ |
| | | * @param page |
| | | * @param supplierManageDto |
| | | * @return |
| | | */ |
| | | IPage<SupplierManage> supplierListPage(Page page, SupplierManageDto supplierManageDto); |
| | | } |
| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.mapper.SupplierManageMapper; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.basic.service.ISupplierService; |
| | |
| | | @Autowired |
| | | private SupplierManageMapper supplierMapper; |
| | | |
| | | /** |
| | | * ä¾åºåæ°å¢ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void saveSupplier(SupplierManage supplierManage) { |
| | | supplierMapper.insert(supplierManage); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºåå é¤ |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int delSupplier(Integer id) { |
| | | return supplierMapper.deleteById(id); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºå详æ
|
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public SupplierManage supplierDetail(Integer id) { |
| | | return supplierMapper.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºåä¿®æ¹ |
| | | * @param supplierManage |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int supplierManage(SupplierManage supplierManage) { |
| | | return supplierMapper.updateById(supplierManage); |
| | | } |
| | | |
| | | /** |
| | | * ä¾åºåå页æ¥è¯¢ |
| | | * @param page |
| | | * @param supplierManageDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<SupplierManage> supplierListPage(Page page, SupplierManageDto supplierManageDto) { |
| | | return supplierMapper.supplierListPage(page,supplierManageDto); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | public class IgnoreTableConfig { |
| | | |
| | | public static final Set<String> IGNORE_TABLES = new HashSet<>(); |
| | | |
| | | static { |
| | | IGNORE_TABLES.add("sys_config"); |
| | | IGNORE_TABLES.add("sys_user"); |
| | | IGNORE_TABLES.add("sys_dept"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Component |
| | | public class MybatisHandler implements MetaObjectHandler { |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | Integer userId = null; |
| | | Integer tenantId = null; |
| | | try { |
| | | userId = SecurityUtils.getUserId().intValue(); |
| | | tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | } catch (Exception ignored) { |
| | | } |
| | | System.out.println("æ§è¡æå
¥å¡«å
..."); |
| | | this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "createUser", Integer.class, userId); |
| | | this.strictInsertFill(metaObject, "updateUser", Integer.class, userId); |
| | | this.strictInsertFill(metaObject, "tenantId", Integer.class, tenantId); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | Integer userId = null; |
| | | try { |
| | | userId = SecurityUtils.getUserId().intValue(); |
| | | } catch (Exception ignored) { |
| | | } |
| | | this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è) |
| | | this.strictUpdateFill(metaObject, "updateUser", Integer.class, userId); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.handler; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; |
| | | import com.ruoyi.common.config.IgnoreTableConfig; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.expression.LongValue; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Set; |
| | | |
| | | @Component |
| | | public class CustomTenantLineHandler implements TenantLineHandler { |
| | | |
| | | @Override |
| | | public Expression getTenantId() { |
| | | Integer tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | return new LongValue(tenantId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean ignoreTable(String tableName) { |
| | | // æå®ä¸éè¦æ·»å è¿æ»¤æ¡ä»¶ç表 |
| | | Set<String> ignoreTables = IgnoreTableConfig.IGNORE_TABLES; |
| | | return ignoreTables.contains(tableName); |
| | | } |
| | | |
| | | @Override |
| | | public String getTenantIdColumn() { |
| | | // æå®ç§æ· ID åæ®µåç§°ï¼æ¯å¦ "station_id" |
| | | return "tenant_id"; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; |
| | | import com.ruoyi.common.handler.CustomTenantLineHandler; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() |
| | | { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | // ç§æ·æä»¶ |
| | | TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor(new CustomTenantLineHandler()); |
| | | interceptor.addInnerInterceptor(tenantLineInnerInterceptor); |
| | | // å页æä»¶ |
| | | interceptor.addInnerInterceptor(paginationInnerInterceptor()); |
| | | // ä¹è§éæä»¶ |
| | |
| | | public String login(String username, String password, String code, String uuid)
|
| | | {
|
| | | // éªè¯ç æ ¡éª
|
| | | validateCaptcha(username, code, uuid);
|
| | | // validateCaptcha(username, code, uuid);
|
| | | // ç»å½åç½®æ ¡éª
|
| | | loginPreCheck(username, password);
|
| | | // ç¨æ·éªè¯
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.basic.mapper.SupplierManageMapper"> |
| | | |
| | | <select id="supplierListPage" resultType="com.ruoyi.basic.dto.SupplierManageDto"> |
| | | SELECT |
| | | T1.id, |
| | | T1.supplier_name, |
| | | T1.taxpayer_identification_num, |
| | | T1.company_address, |
| | | T1.company_phone, |
| | | T1.bank_account_name, |
| | | T1.bank_account_num, |
| | | T1.contact_user_name, |
| | | T1.contact_user_phone, |
| | | T1.maintain_user_id, |
| | | T1.maintain_time, |
| | | T1.create_time, |
| | | T1.create_user, |
| | | T1.update_time, |
| | | T1.update_user, |
| | | T1.tenant_id |
| | | FROM supplier_manage T1 |
| | | LEFT JOIN sys_user T2 ON T1.maintain_user_id = T2.user_id |
| | | <where> |
| | | <if test="supplierManageDto.supplierName != null and supplierManageDto.supplierName != '' "> |
| | | AND supplier_name = #{supplierManageDto.supplierName} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |