Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add system config api #258

Merged
merged 7 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,33 @@
*/
package com.wansenai.api.system;

import org.springframework.web.bind.annotation.RequestMapping;

import com.wansenai.dto.system.SystemConfigDTO;
import com.wansenai.service.system.SysConfigService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.SystemConfigVO;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
* <p>
* 系统参数 前端控制器
* </p>
*
* @author James Zow
* @since 2023-09-05
*/
@RestController
@RequestMapping("/sys-config")
@RequestMapping("/sys/config")
public class SysConfigController {

private final SysConfigService sysConfigService;

public SysConfigController(SysConfigService sysConfigService) {
this.sysConfigService = sysConfigService;
}

@GetMapping("getCompanyInfo")
public Response<SystemConfigVO> getSystemConfigInfo() {
return sysConfigService.getSystemConfigInfo();
}

@PostMapping("addOrUpdate")
public Response<String> addOrUpdateCompanyInfo(@RequestBody SystemConfigDTO systemConfigDTO) {
return sysConfigService.addOrUpdateCompanyInfo(systemConfigDTO);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.dto.system;

import lombok.Data;

@Data
public class SystemConfigDTO {

private Long id;

private String companyName;

private String companyContact;

private String companyAddress;

private String companyPhone;

private String companyFax;

private String companyPostCode;

private String saleAgreement;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,27 @@ public class SysConfig implements Serializable {
/**
* 仓库启用标记,0未启用,1启用
*/
private Boolean warehouseStatus;
private Integer warehouseStatus;

/**
* 客户启用标记,0未启用,1启用
*/
private Boolean customerStatus;
private Integer customerStatus;

/**
* 负库存启用标记,0未启用,1启用
*/
private Boolean minusStockStatus;
private Integer minusStockStatus;

/**
* 以销定购启用标记,0未启用,1启用
*/
private Boolean purchaseBySaleStatus;
private Integer purchaseBySaleStatus;

/**
* 多级审核启用标记,0未启用,1启用
*/
private Boolean multiLevelApprovalStatus;
private Integer multiLevelApprovalStatus;

/**
* 流程类型,可多选
Expand All @@ -115,22 +115,22 @@ public class SysConfig implements Serializable {
/**
* 强审核启用标记,0未启用,1启用
*/
private Boolean forceApprovalStatus;
private Integer forceApprovalStatus;

/**
* 更新单价启用标记,0未启用,1启用
*/
private Boolean updateUnitPriceStatus;
private Integer updateUnitPriceStatus;

/**
* 超出关联单据启用标记,0未启用,1启用
*/
private Boolean overLinkBillStatus;
private Integer overLinkBillStatus;

/**
* 删除标记,0未删除,1删除
*/
private Boolean deleteFlag;
private Integer deleteFlag;


}
37 changes: 37 additions & 0 deletions core/domain/src/main/java/com/wansenai/vo/SystemConfigVO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

@Data
public class SystemConfigVO {

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;

private String companyName;

private String companyContact;

private String companyAddress;

private String companyPhone;

private String companyFax;

private String companyPostCode;

private String saleAgreement;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void addInterceptors(InterceptorRegistry registry) {
.excludePathPatterns("/user/mobileLogin")
.excludePathPatterns("/user/updatePassword")
.excludePathPatterns("/v2/common/sms/{type}/{phoneNumber}")
.excludePathPatterns("/v2/common/nextId/{type}");
.excludePathPatterns("/v2/common/nextId/{type}")
.excludePathPatterns("/sys/config/getCompanyInfo");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
*/
package com.wansenai.service.system;

import com.wansenai.dto.system.SystemConfigDTO;
import com.wansenai.entities.system.SysConfig;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.SystemConfigVO;

/**
* <p>
* 系统参数 服务类
* </p>
*/
public interface ISysConfigService extends IService<SysConfig> {
public interface SysConfigService extends IService<SysConfig> {

Response<SystemConfigVO> getSystemConfigInfo();

Response<String> addOrUpdateCompanyInfo(SystemConfigDTO systemConfigDTO);

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.wansenai.service.system.impl;

import com.wansenai.service.system.ISysConfigService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wansenai.dto.system.SystemConfigDTO;
import com.wansenai.service.system.SysConfigService;
import com.wansenai.entities.system.SysConfig;
import com.wansenai.mappers.system.SysConfigMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wansenai.service.user.ISysUserService;
import com.wansenai.utils.constants.CommonConstants;
import com.wansenai.utils.enums.BaseCodeEnum;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.SystemConfigVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
Expand All @@ -15,6 +23,37 @@
* @since 2023-09-05
*/
@Service
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {

private final SysConfigMapper configMapper;

public SysConfigServiceImpl(SysConfigMapper configMapper) {
this.configMapper = configMapper;
}

@Override
public Response<SystemConfigVO> getSystemConfigInfo() {
var wrapper = new QueryWrapper<SysConfig>();
wrapper.eq("delete_flag", CommonConstants.NOT_DELETED);
var configData = configMapper.selectOne(wrapper);
var systemConfigVO = new SystemConfigVO();
if (configData != null) {
BeanUtils.copyProperties(configData, systemConfigVO);
return Response.responseData(systemConfigVO);
}
return Response.responseData(systemConfigVO);
}

@Override
public Response<String> addOrUpdateCompanyInfo(SystemConfigDTO systemConfigDTO) {
var id = systemConfigDTO.getId();
var config = new SysConfig();
BeanUtils.copyProperties(systemConfigDTO, config);
if (id == null) {
configMapper.insert(config);
} else {
configMapper.updateById(config);
}
return Response.responseMsg(BaseCodeEnum.SUCCESS);
}
}
20 changes: 20 additions & 0 deletions web/src/api/sys/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defHttp } from '/@/utils/http/axios';
import {BaseDataResp, BaseResp} from "@/api/model/baseModel";
import {
AddOrUpdateSystemConfigModel,
GetSystemConfigModel,
} from '@/api/sys/model/configModel';

enum Api {
GetConfigInfo = '/sys/config/getCompanyInfo',
AddOrUpdateConfigInfo = '/sys/config/addOrUpdate',
}

export function getConfigInfo() {
return defHttp.get<BaseDataResp<GetSystemConfigModel>>({url: Api.GetConfigInfo})
}

export function addOrUpdateConfigInfo(params: AddOrUpdateSystemConfigModel) {
return defHttp.post<BaseResp>({url: Api.AddOrUpdateConfigInfo, params})
}

20 changes: 20 additions & 0 deletions web/src/api/sys/model/configModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface GetSystemConfigModel {
companyName: string;
companyContact: string;
companyAddress: string;
companyPhone: string;
companyFax: string;
companyPostCode: string;
companyLogo: string;
}

export interface AddOrUpdateSystemConfigModel {
id: number | string;
companyName: string;
companyContact: string;
companyAddress: string;
companyPhone: string;
companyFax: string;
companyPostCode: string;
companyLogo: string;
}
2 changes: 0 additions & 2 deletions web/src/api/sys/model/dpetModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {BasicFetchResult} from "@/api/model/baseModel";

export interface DeptListItem {
deptName: string;
}
Expand Down
11 changes: 9 additions & 2 deletions web/src/components/Application/src/AppLogo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
<div class="anticon" :class="getAppLogoClass" @click="goHome">
<img src="../../../assets/images/logo.png" />
<div class="ml-2 truncate md:opacity-100" :class="getTitleClass" v-show="showTitle">
{{ title }}
{{ companyTitle == undefined ? title : companyTitle}}
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, unref } from 'vue';
import {computed, onMounted, ref, unref} from 'vue';
import { useGlobSetting } from '/@/hooks/setting';
import { useGo } from '/@/hooks/web/usePage';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { useDesign } from '/@/hooks/web/useDesign';
import { PageEnum } from '/@/enums/pageEnum';
import { useUserStore } from '/@/store/modules/user';
import { getConfigInfo} from "@/api/sys/config";
const companyTitle = ref<string>('');

const props = defineProps({
/**
Expand All @@ -36,6 +38,11 @@
const { title } = useGlobSetting();
const go = useGo();

onMounted(async () => {
const res = await getConfigInfo();
companyTitle.value = res.data.companyName;
});

const getAppLogoClass = computed(() => [
prefixCls,
props.theme,
Expand Down
7 changes: 7 additions & 0 deletions web/src/components/Cropper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { withInstall } from '/@/utils';
import cropperImage from './src/Cropper.vue';
import avatarCropper from './src/CropperAvatar.vue';

export * from './src/typing';
export const CropperImage = withInstall(cropperImage);
export const CropperAvatar = withInstall(avatarCropper);
Loading