Modify the machine field

This commit is contained in:
2025-10-24 08:50:45 +08:00
parent 3d4f3e3f82
commit cbbdba2c6c
3 changed files with 97 additions and 97 deletions

View File

@@ -671,12 +671,12 @@ func AppGetMultiConfigHandler(w http.ResponseWriter, r *http.Request) {
// AppUpdateMultiConfigHandler 更新应用多开配置
func AppUpdateMultiConfigHandler(w http.ResponseWriter, r *http.Request) {
var req struct {
UUID string `json:"uuid"`
LoginType int `json:"login_type"`
MultiOpenScope int `json:"multi_open_scope"`
CleanInterval int `json:"clean_interval"`
CheckInterval int `json:"check_interval"`
MultiOpenCount int `json:"multi_open_count"`
UUID string `json:"uuid"`
LoginType int `json:"login_type"`
MultiOpenScope int `json:"multi_open_scope"`
CleanInterval int `json:"clean_interval"`
CheckInterval int `json:"check_interval"`
MultiOpenCount int `json:"multi_open_count"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@@ -801,18 +801,18 @@ func AppGetBindConfigHandler(w http.ResponseWriter, r *http.Request) {
// 返回绑定配置信息
response := map[string]interface{}{
"machine_code_verify": app.MachineCodeVerify,
"machine_code_rebind_enabled": app.MachineCodeRebindEnabled,
"machine_code_option": app.MachineCodeOption,
"machine_code_free_count": app.MachineCodeFreeCount,
"machine_code_rebind_count": app.MachineCodeRebindCount,
"machine_code_rebind_deduct": app.MachineCodeRebindDeduct,
"ip_verify": app.IPVerify,
"ip_rebind_enabled": app.IPRebindEnabled,
"ip_option": app.IPOption,
"ip_free_count": app.IPFreeCount,
"ip_rebind_count": app.IPRebindCount,
"ip_rebind_deduct": app.IPRebindDeduct,
"machine_verify": app.MachineVerify,
"machine_rebind_enabled": app.MachineRebindEnabled,
"machine_rebind_limit": app.MachineRebindLimit,
"machine_free_count": app.MachineFreeCount,
"machine_rebind_count": app.MachineRebindCount,
"machine_rebind_deduct": app.MachineRebindDeduct,
"ip_verify": app.IPVerify,
"ip_rebind_enabled": app.IPRebindEnabled,
"ip_rebind_limit": app.IPRebindLimit,
"ip_free_count": app.IPFreeCount,
"ip_rebind_count": app.IPRebindCount,
"ip_rebind_deduct": app.IPRebindDeduct,
}
w.Header().Set("Content-Type", "application/json")
@@ -827,19 +827,19 @@ func AppUpdateBindConfigHandler(w http.ResponseWriter, r *http.Request) {
}
var req struct {
UUID string `json:"uuid"`
MachineCodeVerify int `json:"machine_code_verify"`
MachineCodeRebindEnabled int `json:"machine_code_rebind_enabled"`
MachineCodeOption int `json:"machine_code_option"`
MachineCodeFreeCount int `json:"machine_code_free_count"`
MachineCodeRebindCount int `json:"machine_code_rebind_count"`
MachineCodeRebindDeduct int `json:"machine_code_rebind_deduct"`
IPVerify int `json:"ip_verify"`
IPRebindEnabled int `json:"ip_rebind_enabled"`
IPOption int `json:"ip_option"`
IPFreeCount int `json:"ip_free_count"`
IPRebindCount int `json:"ip_rebind_count"`
IPRebindDeduct int `json:"ip_rebind_deduct"`
UUID string `json:"uuid"`
MachineVerify int `json:"machine_verify"`
MachineRebindEnabled int `json:"machine_rebind_enabled"`
MachineRebindLimit int `json:"machine_rebind_limit"`
MachineFreeCount int `json:"machine_free_count"`
MachineRebindCount int `json:"machine_rebind_count"`
MachineRebindDeduct int `json:"machine_rebind_deduct"`
IPVerify int `json:"ip_verify"`
IPRebindEnabled int `json:"ip_rebind_enabled"`
IPRebindLimit int `json:"ip_rebind_limit"`
IPFreeCount int `json:"ip_free_count"`
IPRebindCount int `json:"ip_rebind_count"`
IPRebindDeduct int `json:"ip_rebind_deduct"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@@ -875,20 +875,20 @@ func AppUpdateBindConfigHandler(w http.ResponseWriter, r *http.Request) {
}
// 验证参数范围
if req.MachineCodeVerify < 0 || req.MachineCodeVerify > 1 {
if req.MachineVerify < 0 || req.MachineVerify > 1 {
response := map[string]interface{}{
"code": 1,
"msg": "机器验证参数无效",
"msg": "机器验证参数无效",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
return
}
if req.MachineCodeOption < 0 || req.MachineCodeOption > 1 {
if req.MachineRebindLimit < 0 || req.MachineRebindLimit > 1 {
response := map[string]interface{}{
"code": 1,
"msg": "机器码选项参数无效",
"msg": "机器重绑限制参数无效",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
@@ -905,20 +905,20 @@ func AppUpdateBindConfigHandler(w http.ResponseWriter, r *http.Request) {
return
}
if req.IPOption < 0 || req.IPOption > 1 {
if req.IPRebindLimit < 0 || req.IPRebindLimit > 1 {
response := map[string]interface{}{
"code": 1,
"msg": "IP地址选项参数无效",
"msg": "IP地址重绑限制参数无效",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
return
}
if req.MachineCodeRebindEnabled < 0 || req.MachineCodeRebindEnabled > 1 {
if req.MachineRebindEnabled < 0 || req.MachineRebindEnabled > 1 {
response := map[string]interface{}{
"code": 1,
"msg": "机器重绑开关参数无效",
"msg": "机器重绑开关参数无效",
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
@@ -935,7 +935,7 @@ func AppUpdateBindConfigHandler(w http.ResponseWriter, r *http.Request) {
return
}
if req.MachineCodeFreeCount < 0 || req.MachineCodeRebindCount < 0 || req.MachineCodeRebindDeduct < 0 ||
if req.MachineFreeCount < 0 || req.MachineRebindCount < 0 || req.MachineRebindDeduct < 0 ||
req.IPFreeCount < 0 || req.IPRebindCount < 0 || req.IPRebindDeduct < 0 {
response := map[string]interface{}{
"code": 1,
@@ -973,18 +973,18 @@ func AppUpdateBindConfigHandler(w http.ResponseWriter, r *http.Request) {
// 更新绑定配置
updates := map[string]interface{}{
"machine_code_verify": req.MachineCodeVerify,
"machine_code_rebind_enabled": req.MachineCodeRebindEnabled,
"machine_code_option": req.MachineCodeOption,
"machine_code_free_count": req.MachineCodeFreeCount,
"machine_code_rebind_count": req.MachineCodeRebindCount,
"machine_code_rebind_deduct": req.MachineCodeRebindDeduct,
"ip_verify": req.IPVerify,
"ip_rebind_enabled": req.IPRebindEnabled,
"ip_option": req.IPOption,
"ip_free_count": req.IPFreeCount,
"ip_rebind_count": req.IPRebindCount,
"ip_rebind_deduct": req.IPRebindDeduct,
"machine_verify": req.MachineVerify,
"machine_rebind_enabled": req.MachineRebindEnabled,
"machine_rebind_limit": req.MachineRebindLimit,
"machine_free_count": req.MachineFreeCount,
"machine_rebind_count": req.MachineRebindCount,
"machine_rebind_deduct": req.MachineRebindDeduct,
"ip_verify": req.IPVerify,
"ip_rebind_enabled": req.IPRebindEnabled,
"ip_rebind_limit": req.IPRebindLimit,
"ip_free_count": req.IPFreeCount,
"ip_rebind_count": req.IPRebindCount,
"ip_rebind_deduct": req.IPRebindDeduct,
}
if err := db.Model(&app).Updates(updates).Error; err != nil {

View File

@@ -53,27 +53,27 @@ type App struct {
// MultiOpenCount多开数量默认1
MultiOpenCount int `gorm:"default:1;not null;comment:多开数量" json:"multi_open_count"`
// 机器验证相关字段
// MachineCodeVerify机器验证0=关闭1=开启)
MachineCodeVerify int `gorm:"default:0;not null;comment:机器验证0=关闭1=开启" json:"machine_code_verify"`
// MachineCodeRebindEnabled机器重绑开关0=关闭1=开启)
MachineCodeRebindEnabled int `gorm:"default:0;not null;comment:机器重绑开关0=关闭1=开启" json:"machine_code_rebind_enabled"`
// MachineCodeOption机器码选项0=每天1=永久)
MachineCodeOption int `gorm:"default:0;not null;comment:机器码选项0=每天1=永久" json:"machine_code_option"`
// MachineCodeFreeCount机器免费次数默认0
MachineCodeFreeCount int `gorm:"default:0;not null;comment:机器免费次数" json:"machine_code_free_count"`
// MachineCodeRebindCount机器重绑次数默认0
MachineCodeRebindCount int `gorm:"default:0;not null;comment:机器重绑次数" json:"machine_code_rebind_count"`
// MachineCodeRebindDeduct机器重绑扣除默认0单位分钟
MachineCodeRebindDeduct int `gorm:"default:0;not null;comment:机器重绑扣除,单位分钟" json:"machine_code_rebind_deduct"`
// 机器验证相关字段
// MachineVerify机器验证0=关闭1=开启)
MachineVerify int `gorm:"default:0;not null;comment:机器验证0=关闭1=开启" json:"machine_verify"`
// MachineRebindEnabled机器重绑开关0=关闭1=开启)
MachineRebindEnabled int `gorm:"default:0;not null;comment:机器重绑开关0=关闭1=开启" json:"machine_rebind_enabled"`
// MachineRebindLimit机器重绑限制0=每天1=永久)
MachineRebindLimit int `gorm:"default:0;not null;comment:机器重绑限制0=每天1=永久" json:"machine_rebind_limit"`
// MachineFreeCount机器免费次数默认0
MachineFreeCount int `gorm:"default:0;not null;comment:机器免费次数" json:"machine_free_count"`
// MachineRebindCount机器重绑次数默认0
MachineRebindCount int `gorm:"default:0;not null;comment:机器重绑次数" json:"machine_rebind_count"`
// MachineRebindDeduct机器重绑扣除默认0单位分钟
MachineRebindDeduct int `gorm:"default:0;not null;comment:机器重绑扣除,单位分钟" json:"machine_rebind_deduct"`
// IP地址验证相关字段
// IPVerifyIP地址验证0=关闭1=开启2=开启(市)3=开启(省)
IPVerify int `gorm:"default:0;not null;comment:IP地址验证0=关闭1=开启2=开启(市)3=开启(省)" json:"ip_verify"`
// IPRebindEnabledIP地址重绑开关0=关闭1=开启)
IPRebindEnabled int `gorm:"default:0;not null;comment:IP地址重绑开关0=关闭1=开启" json:"ip_rebind_enabled"`
// IPOptionIP地址选项0=每天1=永久)
IPOption int `gorm:"default:0;not null;comment:IP地址选项0=每天1=永久" json:"ip_option"`
// IPRebindLimitIP地址重绑限制0=每天1=永久)
IPRebindLimit int `gorm:"default:0;not null;comment:IP地址重绑限制0=每天1=永久" json:"ip_rebind_limit"`
// IPFreeCountIP地址免费次数默认0
IPFreeCount int `gorm:"default:0;not null;comment:IP地址免费次数" json:"ip_free_count"`
// IPRebindCountIP地址重绑次数默认0

View File

@@ -146,7 +146,7 @@
{ type: 'checkbox', width: 50 },
{ field: 'id', title: 'ID', width: 80, sort: true },
{ field: 'name', title: '应用名称', minWidth: 180 },
{ field: 'uuid', title: 'UUID', minWidth: 320 },
{ field: 'uuid', title: 'UUID', minWidth: 335 },
{ field: 'version', title: '应用版本', width: 100 },
{
field: 'status',
@@ -572,45 +572,45 @@
// 机器码验证设置
'<fieldset class="layui-elem-field layui-field-title">' +
'<legend>机器验证设置</legend>' +
'<legend>机器验证设置</legend>' +
'</fieldset>' +
'<div class="layui-form-item" pane>' +
'<label class="layui-form-label">机器码验证</label>' +
'<div class="layui-input-block">' +
'<input type="radio" name="machine_code_verify" value="0" title="关闭" ' + (config.machine_code_verify === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_code_verify" value="1" title="开启" ' + (config.machine_code_verify === 1 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_verify" value="0" title="关闭" ' + (config.machine_verify === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_verify" value="1" title="开启" ' + (config.machine_verify === 1 ? 'checked' : '') + '>' +
'</div>' +
'</div>' +
'<div class="layui-form-item" pane>' +
'<label class="layui-form-label">机器码重绑</label>' +
'<div class="layui-input-block">' +
'<input type="radio" name="machine_code_rebind_enabled" value="0" title="关闭" ' + (config.machine_code_rebind_enabled === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_code_rebind_enabled" value="1" title="开启" ' + (config.machine_code_rebind_enabled === 1 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_rebind_enabled" value="0" title="关闭" ' + (config.machine_rebind_enabled === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_rebind_enabled" value="1" title="开启" ' + (config.machine_rebind_enabled === 1 ? 'checked' : '') + '>' +
'</div>' +
'</div>' +
'<div class="layui-form-item" pane>' +
'<label class="layui-form-label">机器码选项</label>' +
'<label class="layui-form-label">重绑限制</label>' +
'<div class="layui-input-block">' +
'<input type="radio" name="machine_code_option" value="0" title="每天" ' + (config.machine_code_option === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_code_option" value="1" title="永久" ' + (config.machine_code_option === 1 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_rebind_limit" value="0" title="每天" ' + (config.machine_rebind_limit === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="machine_rebind_limit" value="1" title="永久" ' + (config.machine_rebind_limit === 1 ? 'checked' : '') + '>' +
'</div>' +
'</div>' +
'<div class="layui-form-item">' +
'<label class="layui-form-label">免费次数</label>' +
'<div class="layui-input-block">' +
'<input type="number" name="machine_code_free_count" class="layui-input" value="' + config.machine_code_free_count + '" placeholder="请输入" lay-verify="number" min="0">' +
'<input type="number" name="machine_free_count" class="layui-input" value="' + config.machine_free_count + '" placeholder="请输入" lay-verify="number" min="0">' +
'</div>' +
'</div>' +
'<div class="layui-form-item">' +
'<label class="layui-form-label">重绑次数</label>' +
'<div class="layui-input-block">' +
'<input type="number" name="machine_code_rebind_count" class="layui-input" value="' + config.machine_code_rebind_count + '" placeholder="请输入" lay-verify="number" min="0">' +
'<input type="number" name="machine_rebind_count" class="layui-input" value="' + config.machine_rebind_count + '" placeholder="请输入" lay-verify="number" min="0">' +
'</div>' +
'</div>' +
'<div class="layui-form-item">' +
'<label class="layui-form-label">重绑扣除</label>' +
'<div class="layui-input-block">' +
'<input type="number" name="machine_code_rebind_deduct" class="layui-input" value="' + config.machine_code_rebind_deduct + '" placeholder="请输入重绑扣除时间(分钟)" lay-verify="number" min="0">' +
'<input type="number" name="machine_rebind_deduct" class="layui-input" value="' + config.machine_rebind_deduct + '" placeholder="请输入重绑扣除时间(分钟)" lay-verify="number" min="0">' +
'</div>' +
'</div>' +
@@ -635,10 +635,10 @@
'</div>' +
'</div>' +
'<div class="layui-form-item" pane>' +
'<label class="layui-form-label">IP地址选项</label>' +
'<label class="layui-form-label">重绑限制</label>' +
'<div class="layui-input-block">' +
'<input type="radio" name="ip_option" value="0" title="每天" ' + (config.ip_option === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="ip_option" value="1" title="永久" ' + (config.ip_option === 1 ? 'checked' : '') + '>' +
'<input type="radio" name="ip_rebind_limit" value="0" title="每天" ' + (config.ip_rebind_limit === 0 ? 'checked' : '') + '>' +
'<input type="radio" name="ip_rebind_limit" value="1" title="永久" ' + (config.ip_rebind_limit === 1 ? 'checked' : '') + '>' +
'</div>' +
'</div>' +
'<div class="layui-form-item">' +
@@ -666,31 +666,31 @@
yes: function(index, layero) {
var formData = {
uuid: obj.data.uuid,
machine_code_verify: parseInt($('input[name="machine_code_verify"]:checked').val()),
machine_code_rebind_enabled: parseInt($('input[name="machine_code_rebind_enabled"]:checked').val()),
machine_code_option: parseInt($('input[name="machine_code_option"]:checked').val()),
machine_code_free_count: parseInt($('input[name="machine_code_free_count"]').val()) || 0,
machine_code_rebind_count: parseInt($('input[name="machine_code_rebind_count"]').val()) || 0,
machine_code_rebind_deduct: parseInt($('input[name="machine_code_rebind_deduct"]').val()) || 0,
machine_verify: parseInt($('input[name="machine_verify"]:checked').val()),
machine_rebind_enabled: parseInt($('input[name="machine_rebind_enabled"]:checked').val()),
machine_rebind_limit: parseInt($('input[name="machine_rebind_limit"]:checked').val()),
machine_free_count: parseInt($('input[name="machine_free_count"]').val()) || 0,
machine_rebind_count: parseInt($('input[name="machine_rebind_count"]').val()) || 0,
machine_rebind_deduct: parseInt($('input[name="machine_rebind_deduct"]').val()) || 0,
ip_verify: parseInt($('input[name="ip_verify"]:checked').val()),
ip_rebind_enabled: parseInt($('input[name="ip_rebind_enabled"]:checked').val()),
ip_option: parseInt($('input[name="ip_option"]:checked').val()),
ip_rebind_limit: parseInt($('input[name="ip_rebind_limit"]:checked').val()),
ip_free_count: parseInt($('input[name="ip_free_count"]').val()) || 0,
ip_rebind_count: parseInt($('input[name="ip_rebind_count"]').val()) || 0,
ip_rebind_deduct: parseInt($('input[name="ip_rebind_deduct"]').val()) || 0
};
// 验证数据
if (isNaN(formData.machine_code_verify) || formData.machine_code_verify < 0 || formData.machine_code_verify > 1) {
layer.msg('请选择机器验证选项', {icon: 2});
if (isNaN(formData.machine_verify) || formData.machine_verify < 0 || formData.machine_verify > 1) {
layer.msg('请选择机器验证选项', {icon: 2});
return;
}
if (isNaN(formData.machine_code_rebind_enabled) || formData.machine_code_rebind_enabled < 0 || formData.machine_code_rebind_enabled > 1) {
layer.msg('请选择机器重绑选项', {icon: 2});
if (isNaN(formData.machine_rebind_enabled) || formData.machine_rebind_enabled < 0 || formData.machine_rebind_enabled > 1) {
layer.msg('请选择机器重绑选项', {icon: 2});
return;
}
if (isNaN(formData.machine_code_option) || formData.machine_code_option < 0 || formData.machine_code_option > 1) {
layer.msg('请选择机器码选项', {icon: 2});
if (isNaN(formData.machine_rebind_limit) || formData.machine_rebind_limit < 0 || formData.machine_rebind_limit > 1) {
layer.msg('请选择机器重绑限制', {icon: 2});
return;
}
if (isNaN(formData.ip_verify) || formData.ip_verify < 0 || formData.ip_verify > 3) {
@@ -701,8 +701,8 @@
layer.msg('请选择IP地址重绑选项', {icon: 2});
return;
}
if (isNaN(formData.ip_option) || formData.ip_option < 0 || formData.ip_option > 1) {
layer.msg('请选择IP地址选项', {icon: 2});
if (isNaN(formData.ip_rebind_limit) || formData.ip_rebind_limit < 0 || formData.ip_rebind_limit > 1) {
layer.msg('请选择IP地址重绑限制', {icon: 2});
return;
}